diff options
author | adam- <adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-06-28 18:49:07 +0000 |
---|---|---|
committer | adam- <adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-06-28 18:49:07 +0000 |
commit | 712cbb540c41e56115061be296f419e21111bedd (patch) | |
tree | 90c3173ffc6818b8bfff7cf7abb677c6b9f6c1c5 /src | |
parent | 108cf5e60d43486235349bce3ae7aa8b2b4dae7f (diff) |
Add ability for fantasy to be disabled for some commands and strip the channel name from them
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2341 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r-- | src/botserv.c | 33 | ||||
-rw-r--r-- | src/core/cs_help.c | 1 | ||||
-rw-r--r-- | src/core/cs_list.c | 1 |
3 files changed, 30 insertions, 5 deletions
diff --git a/src/botserv.c b/src/botserv.c index b9019dd65..c3c63735d 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -136,6 +136,8 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) char *cmd; UserData *ud; bool was_action = false; + Command *command; + std::string bbuf; if (!u || !buf || !ci) { return; @@ -426,13 +428,34 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) if (check_access(u, ci, CA_FANTASIA)) { - std::string bbuf = std::string(cmd) + " " + ci->name; - if (params) + if ((command = findCommand(CHANSERV, cmd))) { - bbuf += " "; - bbuf += params; + /* Command exists but can not be called by fantasy */ + if (command->HasFlag(CFLAG_DISABLE_FANTASY)) + notice_lang(s_ChanServ, u, UNKNOWN_COMMAND_HELP, cmd, s_ChanServ); + else + { + bbuf = std::string(cmd); + + /* Some commands don't need the channel name added.. eg !help */ + if (!command->HasFlag(CFLAG_STRIP_CHANNEL)) + { + bbuf += " "; + bbuf += ci->name; + } + + if (params) + { + bbuf += " "; + bbuf += params; + } + + chanserv(u, const_cast<char *>(bbuf.c_str())); // XXX Unsafe cast, this needs reviewing -- CyberBotX + } } - chanserv(u, const_cast<char *>(bbuf.c_str())); // XXX Unsafe cast, this needs reviewing -- CyberBotX + else + notice_lang(s_ChanServ, u, UNKNOWN_COMMAND_HELP, cmd, s_ChanServ); + FOREACH_MOD(I_OnBotFantasy, OnBotFantasy(cmd, u, ci, params)); } else diff --git a/src/core/cs_help.c b/src/core/cs_help.c index 4d7011440..2cc334f65 100644 --- a/src/core/cs_help.c +++ b/src/core/cs_help.c @@ -21,6 +21,7 @@ class CommandCSHelp : public Command CommandCSHelp() : Command("HELP", 1, 1) { this->SetFlag(CFLAG_ALLOW_UNREGISTERED); + this->SetFlag(CFLAG_STRIP_CHANNEL); } CommandReturn Execute(User *u, std::vector<std::string> ¶ms) diff --git a/src/core/cs_list.c b/src/core/cs_list.c index ef1aa4a49..793490755 100644 --- a/src/core/cs_list.c +++ b/src/core/cs_list.c @@ -21,6 +21,7 @@ class CommandCSList : public Command public: CommandCSList() : Command("LIST",1,2) { + this->SetFlag(CFLAG_STRIP_CHANNEL); } CommandReturn Execute(User *u, std::vector<std::string> ¶ms) |