diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/commands.h | 30 | ||||
| -rw-r--r-- | include/lists.h | 4 | ||||
| -rw-r--r-- | include/logger.h | 3 | ||||
| -rw-r--r-- | include/modules.h | 38 | ||||
| -rw-r--r-- | include/users.h | 9 |
5 files changed, 56 insertions, 28 deletions
diff --git a/include/commands.h b/include/commands.h index cfd46d644..d644ea8cb 100644 --- a/include/commands.h +++ b/include/commands.h @@ -33,11 +33,23 @@ struct CommandInfo Anope::string permission; }; +struct CommandReply +{ + virtual void SendMessage(const BotInfo *source, const Anope::string &msg) = 0; +}; + /* The source for a command */ -struct CoreExport CommandSource +class CoreExport CommandSource { - /* User executing the command */ + /* The nick executing the command */ + Anope::string nick; + /* User executing the command, may be NULL */ User *u; + public: + /* The account executing the command */ + NickCore *nc; + /* Where the reply should go */ + CommandReply *reply; /* Channel the command was executed on (fantasy) */ Channel *c; /* The service this command is on */ @@ -49,8 +61,20 @@ struct CoreExport CommandSource /* The permission of the command being executed */ Anope::string permission; + CommandSource(const Anope::string &n, User *user, NickCore *core, CommandReply *reply); + + const Anope::string &GetNick() const; + User *GetUser() const; + AccessGroup AccessFor(ChannelInfo *ci) const; + bool IsFounder(ChannelInfo *ci) const; + void Reply(const char *message, ...); void Reply(const Anope::string &message); + + bool HasCommand(const Anope::string &cmd); + bool HasPriv(const Anope::string &cmd); + bool IsServicesOper() const; + bool IsOper() const; }; /** Every services command is a class, inheriting from Command. @@ -118,4 +142,6 @@ class CoreExport Command : public Service, public Flags<CommandFlag> virtual void OnSyntaxError(CommandSource &source, const Anope::string &subcommand); }; +extern void RunCommand(CommandSource &source, const Anope::string &message); + #endif // COMMANDS_H diff --git a/include/lists.h b/include/lists.h index 308080c93..841faf7a9 100644 --- a/include/lists.h +++ b/include/lists.h @@ -81,11 +81,11 @@ class CoreExport ListFormatter */ class CoreExport InfoFormatter { - User *user; + NickCore *nc; std::vector<std::pair<Anope::string, Anope::string> > replies; unsigned longest; public: - InfoFormatter(User *u); + InfoFormatter(NickCore *nc); void Process(std::vector<Anope::string> &); Anope::string &operator[](const Anope::string &key); }; diff --git a/include/logger.h b/include/logger.h index 8cb54a754..9364cfb7c 100644 --- a/include/logger.h +++ b/include/logger.h @@ -50,6 +50,7 @@ class CoreExport Log public: const BotInfo *bi; const User *u; + const NickCore *nc; Command *c; Channel *chan; const ChannelInfo *ci; @@ -63,7 +64,7 @@ class CoreExport Log Log(LogType type = LOG_NORMAL, const Anope::string &category = "", const BotInfo *bi = NULL); /* LOG_COMMAND/OVERRIDE/ADMIN */ - Log(LogType type, const User *u, Command *c, const ChannelInfo *ci = NULL); + Log(LogType type, const CommandSource &source, Command *c, const ChannelInfo *ci = NULL); /* LOG_CHANNEL */ Log(const User *u, Channel *c, const Anope::string &category = ""); diff --git a/include/modules.h b/include/modules.h index d44cbf8d9..ae7ab139a 100644 --- a/include/modules.h +++ b/include/modules.h @@ -499,25 +499,25 @@ class CoreExport Module : public Extensible virtual EventReturn OnExceptionAdd(Exception *ex) { return EVENT_CONTINUE; } /** Called before an exception is deleted - * @param u The user who is deleting it + * @param source The source deleting it * @param ex The exceotion */ - virtual void OnExceptionDel(User *u, Exception *ex) { } + virtual void OnExceptionDel(CommandSource &source, Exception *ex) { } /** Called before a XLine is added - * @param u The user adding the XLine + * @param source The source of the XLine * @param x The XLine * @param xlm The xline manager it was added to * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnAddXLine(User *u, const XLine *x, XLineManager *xlm) { return EVENT_CONTINUE; } + virtual EventReturn OnAddXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { return EVENT_CONTINUE; } /** Called before a XLine is deleted - * @param u The user deleting the XLine + * @param source The source of the XLine * @param x The XLine * @param xlm The xline manager it was deleted from */ - virtual void OnDelXLine(User *u, const XLine *x, XLineManager *xlm) { } + virtual void OnDelXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { } /** Called when a user is checked for whether they are a services oper * @param u The user @@ -558,31 +558,31 @@ class CoreExport Module : public Extensible /** Called when access is deleted from a channel * @param ci The channel - * @param u The user who removed the access + * @param source The source of the command * @param access The access entry being removed */ - virtual void OnAccessDel(ChannelInfo *ci, User *u, ChanAccess *access) { } + virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { } /** Called when access is added * @param ci The channel - * @param u The user who added the access + * @param source The source of the command * @param access The access changed */ - virtual void OnAccessAdd(ChannelInfo *ci, User *u, ChanAccess *access) { } + virtual void OnAccessAdd(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { } /** Called when the access list is cleared * @param ci The channel * @param u The user who cleared the access */ - virtual void OnAccessClear(ChannelInfo *ci, User *u) { } + virtual void OnAccessClear(ChannelInfo *ci, CommandSource &source) { } /** Called when a level for a channel is changed - * @param u The user changing the level + * @param source The source of the command * @param ci The channel the level was changed on * @param priv The privilege changed * @param what The new level */ - virtual void OnLevelChange(User *u, ChannelInfo *ci, const Anope::string &priv, int16_t what) { } + virtual void OnLevelChange(CommandSource &source, ChannelInfo *ci, const Anope::string &priv, int16_t what) { } /** Called right before a channel is dropped * @param ci The channel @@ -625,18 +625,18 @@ class CoreExport Module : public Extensible virtual void OnChannelDelete(Channel *c) { } /** Called after adding an akick to a channel - * @param u The user adding the akick + * @param source The source of the command * @param ci The channel * @param ak The akick */ - virtual void OnAkickAdd(User *u, ChannelInfo *ci, const AutoKick *ak) { } + virtual void OnAkickAdd(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { } /** Called before removing an akick from a channel - * @param u The user removing the akick + * @param source The source of the command * @param ci The channel * @param ak The akick */ - virtual void OnAkickDel(User *u, ChannelInfo *ci, const AutoKick *ak) { } + virtual void OnAkickDel(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { } /** Called after a user join a channel when we decide whether to kick them or not * @param u The user @@ -669,10 +669,10 @@ class CoreExport Module : public Extensible virtual EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) { return EVENT_CONTINUE; } /** Called when a nick is dropped - * @param u The user dropping the nick + * @param source The source of the command * @param na The nick */ - virtual void OnNickDrop(User *u, NickAlias *na) { } + virtual void OnNickDrop(CommandSource &source, NickAlias *na) { } /** Called when a nick is forbidden * @param na The nick alias of the forbidden nick diff --git a/include/users.h b/include/users.h index e69c9d30b..d0b38025e 100644 --- a/include/users.h +++ b/include/users.h @@ -12,6 +12,7 @@ #include "modes.h" #include "extensible.h" #include "serialize.h" +#include "commands.h" extern CoreExport Anope::insensitive_map<User *> UserListByNick; extern CoreExport Anope::map<User *> UserListByUID; @@ -37,7 +38,7 @@ typedef std::list<ChannelContainer *> UChannelList; /* Online user and channel data. */ -class CoreExport User : public virtual Base, public Extensible +class CoreExport User : public virtual Base, public Extensible, public CommandReply { protected: Anope::string vident; @@ -161,7 +162,7 @@ class CoreExport User : public virtual Base, public Extensible * @param ... any number of parameters */ void SendMessage(const BotInfo *source, const char *fmt, ...); - virtual void SendMessage(const BotInfo *source, Anope::string msg); + void SendMessage(const BotInfo *source, const Anope::string &msg) anope_override; /** Collide a nick * See the comment in users.cpp @@ -194,13 +195,13 @@ class CoreExport User : public virtual Base, public Extensible * @param CheckNick True to check if the user is identified to the nickname they are on too * @return true or false */ - virtual bool IsIdentified(bool CheckNick = false) const; + bool IsIdentified(bool CheckNick = false) const; /** Check if the user is recognized for their nick (on the nicks access list) * @param CheckSecure Only returns true if the user has secure off * @return true or false */ - virtual bool IsRecognized(bool CheckSecure = true) const; + bool IsRecognized(bool CheckSecure = true) const; /** Check if the user is a services oper * @return true if they are an oper |
