summaryrefslogtreecommitdiff
path: root/include/commands.h
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-06-18 05:04:30 -0400
committerAdam <Adam@anope.org>2012-06-18 05:04:30 -0400
commit2dec8e767a70def4b9b04a96ae4f75e4d1013038 (patch)
tree36f5b551ff359a578e17d5e7d2f486970d759a7b /include/commands.h
parent873d4287de57f7f9caa23cb2c9265d1ad2804aba (diff)
Allow userless command sources
Diffstat (limited to 'include/commands.h')
-rw-r--r--include/commands.h30
1 files changed, 28 insertions, 2 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