summaryrefslogtreecommitdiff
path: root/modules/pseudoclients
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-10-08 20:58:47 -0400
committerAdam <Adam@anope.org>2012-10-08 20:58:47 -0400
commit3af786d4c97e8ee99ea122a5c058d82e6222f295 (patch)
tree750c5de0ec2c001b6366fd5137478e6944cdc296 /modules/pseudoclients
parente57b470e83fac205a354138b1daccec654214e39 (diff)
Fix fantasy !help & give it its own help header, not ChanServ's
Diffstat (limited to 'modules/pseudoclients')
-rw-r--r--modules/pseudoclients/botserv.cpp190
-rw-r--r--modules/pseudoclients/chanserv.cpp4
-rw-r--r--modules/pseudoclients/global.cpp2
-rw-r--r--modules/pseudoclients/hostserv.cpp2
-rw-r--r--modules/pseudoclients/memoserv.cpp4
-rw-r--r--modules/pseudoclients/nickserv.cpp4
-rw-r--r--modules/pseudoclients/operserv.cpp2
7 files changed, 114 insertions, 94 deletions
diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp
index ec4bac11d..f165423fc 100644
--- a/modules/pseudoclients/botserv.cpp
+++ b/modules/pseudoclients/botserv.cpp
@@ -46,105 +46,106 @@ class BotServCore : public Module
Anope::string realbuf = msg;
- bool was_action = false;
if (realbuf.substr(0, 8).equals_ci("\1ACTION ") && realbuf[realbuf.length() - 1] == '\1')
{
realbuf.erase(0, 8);
realbuf.erase(realbuf.length() - 1);
- was_action = true;
+ return;
}
- if (realbuf.empty())
+ if (realbuf.empty() || !c->ci->botflags.HasFlag(BS_FANTASY))
return;
- /* Fantaisist commands */
- if (c->ci->botflags.HasFlag(BS_FANTASY) && (Config->BSFantasyCharacter.empty() || realbuf.find_first_of(Config->BSFantasyCharacter) == 0) && !was_action)
- {
- /* Strip off the fantasy character */
- if (!Config->BSFantasyCharacter.empty())
- realbuf.erase(realbuf.begin());
+ std::vector<Anope::string> params = BuildStringVector(realbuf);
- std::vector<Anope::string> params = BuildStringVector(realbuf);
+ if (!realbuf.find_first_of(c->ci->bi->nick))
+ params.erase(params.begin());
+ else if (Config->BSFantasyCharacter.empty())
+ ;
+ else if (!realbuf.find_first_of(Config->BSFantasyCharacter))
+ params[0].erase(params[0].begin());
+ else
+ return;
+
+ if (params.empty())
+ return;
- ServerConfig::fantasy_map::const_iterator it = Config->Fantasy.end();
- unsigned count = 0;
- for (unsigned max = params.size(); it == Config->Fantasy.end() && max > 0; --max)
- {
- Anope::string full_command;
- for (unsigned i = 0; i < max; ++i)
- full_command += " " + params[i];
- full_command.erase(full_command.begin());
+ CommandInfo::map::const_iterator it = Config->Fantasy.end();
+ unsigned count = 0;
+ for (unsigned max = params.size(); it == Config->Fantasy.end() && max > 0; --max)
+ {
+ Anope::string full_command;
+ for (unsigned i = 0; i < max; ++i)
+ full_command += " " + params[i];
+ full_command.erase(full_command.begin());
- ++count;
- it = Config->Fantasy.find(full_command);
- }
+ ++count;
+ it = Config->Fantasy.find(full_command);
+ }
- if (it == Config->Fantasy.end())
- return;
+ if (it == Config->Fantasy.end())
+ return;
- const CommandInfo &info = it->second;
- service_reference<Command> cmd("Command", info.name);
- if (!cmd)
- {
- Log(LOG_DEBUG) << "Fantasy command " << it->first << " exists for nonexistant service " << info.name << "!";
- return;
- }
+ const CommandInfo &info = it->second;
+ service_reference<Command> cmd("Command", info.name);
+ if (!cmd)
+ {
+ Log(LOG_DEBUG) << "Fantasy command " << it->first << " exists for nonexistant service " << info.name << "!";
+ return;
+ }
- for (unsigned i = 0, j = params.size() - (count - 1); i < j; ++i)
- params.erase(params.begin());
+ for (unsigned i = 0, j = params.size() - (count - 1); i < j; ++i)
+ params.erase(params.begin());
- while (cmd->MaxParams > 0 && params.size() > cmd->MaxParams)
- {
- params[cmd->MaxParams - 1] += " " + params[cmd->MaxParams];
- params.erase(params.begin() + cmd->MaxParams);
- }
+ while (cmd->MaxParams > 0 && params.size() > cmd->MaxParams)
+ {
+ params[cmd->MaxParams - 1] += " " + params[cmd->MaxParams];
+ params.erase(params.begin() + cmd->MaxParams);
+ }
- /* All ChanServ commands take the channel as a first parameter */
- if (cmd->name.find("chanserv/") == 0)
- params.insert(params.begin(), c->ci->name);
+ /* All ChanServ commands take the channel as a first parameter */
+ if (cmd->name.find("chanserv/") == 0 && !cmd->HasFlag(CFLAG_STRIP_CHANNEL))
+ params.insert(params.begin(), c->ci->name);
- // Command requires registered users only
- if (!cmd->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !u->Account())
- return;
+ // Command requires registered users only
+ if (!cmd->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !u->Account())
+ return;
- if (params.size() < cmd->MinParams)
- return;
+ if (params.size() < cmd->MinParams)
+ return;
- CommandSource source(u->nick, u, u->Account(), u);
- source.c = c;
- source.owner = c->ci->bi;
- source.service = c->ci->bi;
- source.command = it->first;
- source.permission = info.permission;
+ CommandSource source(u->nick, u, u->Account(), u, c->ci->bi);
+ source.c = c;
+ source.command = it->first;
+ source.permission = info.permission;
- EventReturn MOD_RESULT;
- if (c->ci->AccessFor(u).HasPriv("FANTASIA"))
- {
- FOREACH_RESULT(I_OnBotFantasy, OnBotFantasy(source, cmd, c->ci, params));
- }
- else
- {
- FOREACH_RESULT(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(source, cmd, c->ci, params));
- }
+ EventReturn MOD_RESULT;
+ if (c->ci->AccessFor(u).HasPriv("FANTASIA"))
+ {
+ FOREACH_RESULT(I_OnBotFantasy, OnBotFantasy(source, cmd, c->ci, params));
+ }
+ else
+ {
+ FOREACH_RESULT(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(source, cmd, c->ci, params));
+ }
- if (MOD_RESULT == EVENT_STOP || !c->ci->AccessFor(u).HasPriv("FANTASIA"))
- return;
+ if (MOD_RESULT == EVENT_STOP || !c->ci->AccessFor(u).HasPriv("FANTASIA"))
+ return;
- if (MOD_RESULT != EVENT_ALLOW && !info.permission.empty() && !source.HasCommand(info.permission))
- return;
+ if (MOD_RESULT != EVENT_ALLOW && !info.permission.empty() && !source.HasCommand(info.permission))
+ return;
- FOREACH_RESULT(I_OnPreCommand, OnPreCommand(source, cmd, params));
- if (MOD_RESULT == EVENT_STOP)
- return;
+ FOREACH_RESULT(I_OnPreCommand, OnPreCommand(source, cmd, params));
+ if (MOD_RESULT == EVENT_STOP)
+ return;
- dynamic_reference<User> user_reference(u);
- dynamic_reference<NickCore> nc_reference(u->Account());
- cmd->Execute(source, params);
+ dynamic_reference<User> user_reference(u);
+ dynamic_reference<NickCore> nc_reference(u->Account());
+ cmd->Execute(source, params);
- if (user_reference && nc_reference)
- {
- FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, cmd, params));
- }
+ if (user_reference && nc_reference)
+ {
+ FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, cmd, params));
}
}
@@ -200,24 +201,43 @@ class BotServCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.owner->nick != Config->BotServ)
+ if (!params.empty())
return EVENT_CONTINUE;
- source.Reply(_("\002%s\002 allows you to have a bot on your own channel.\n"
- "It has been created for users that can't host or\n"
- "configure a bot, or for use on networks that don't\n"
- "allow user bots. Available commands are listed \n"
- "below; to use them, type \002%s%s \037command\037\002. For\n"
- "more information on a specific command, type\n"
- "\002%s%s %s \037command\037\002.\n "),
- Config->BotServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->BotServ.c_str(),
- Config->UseStrictPrivMsgString.c_str(), Config->BotServ.c_str(), source.command.c_str());
+
+ if (source.c)
+ {
+ source.Reply(_("\2%s\2 allows you to execute \"fantasy\" commands in the channel.\n"
+ "Fantasy commands are tied to existing commands, usually on \2%s\2,\n"
+ "and provide a more convenient way to execute commands. Commands that\n"
+ "require a channel as a parameter will automatically have that parameter\n"
+ "given.\n"), source.service->nick.c_str(), Config->ChanServ.c_str());
+ if (!Config->BSFantasyCharacter.empty())
+ source.Reply(_(" \n"
+ "Fantasy commands may be prefixed with one of the following characters: %s\n"), Config->BSFantasyCharacter.c_str());
+ source.Reply(_(" \n"
+ "Available commands are:"));
+ }
+ else if (source.service->nick == Config->BotServ)
+ {
+ source.Reply(_("\002%s\002 allows you to have a bot on your own channel.\n"
+ "It has been created for users that can't host or\n"
+ "configure a bot, or for use on networks that don't\n"
+ "allow user bots. Available commands are listed \n"
+ "below; to use them, type \002%s%s \037command\037\002. For\n"
+ "more information on a specific command, type\n"
+ "\002%s%s %s \037command\037\002.\n "),
+ Config->BotServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->BotServ.c_str(),
+ Config->UseStrictPrivMsgString.c_str(), Config->BotServ.c_str(), source.command.c_str());
+ }
+
return EVENT_CONTINUE;
}
void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.owner->nick != Config->BotServ)
+ if (!params.empty() || source.c || source.service->nick != Config->BotServ)
return;
+
source.Reply(_(" \n"
"Bot will join a channel whenever there is at least\n"
"\002%d\002 user(s) on it."), Config->BSMinUsers);
diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp
index 181baa7b8..c3a6e6479 100644
--- a/modules/pseudoclients/chanserv.cpp
+++ b/modules/pseudoclients/chanserv.cpp
@@ -151,7 +151,7 @@ class ChanServCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.owner->nick != Config->ChanServ)
+ if (!params.empty() || source.c || source.service->nick != Config->ChanServ)
return EVENT_CONTINUE;
source.Reply(_("\002%s\002 allows you to register and control various\n"
"aspects of channels. %s can often prevent\n"
@@ -166,7 +166,7 @@ class ChanServCore : public Module
void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.owner->nick != Config->ChanServ)
+ if (!params.empty() || source.c || source.service->nick != Config->ChanServ)
return;
if (Config->CSExpire >= 86400)
source.Reply(_(" \n"
diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp
index 3fdfbf4e0..13e7570ce 100644
--- a/modules/pseudoclients/global.cpp
+++ b/modules/pseudoclients/global.cpp
@@ -81,7 +81,7 @@ class GlobalCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.owner->nick != Config->Global)
+ if (!params.empty() || source.c || source.service->nick != Config->Global)
return EVENT_CONTINUE;
source.Reply(_("%s commands:"), Config->Global.c_str());
return EVENT_CONTINUE;
diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp
index 33d183b9a..d0d078a79 100644
--- a/modules/pseudoclients/hostserv.cpp
+++ b/modules/pseudoclients/hostserv.cpp
@@ -67,7 +67,7 @@ class HostServCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.owner->nick != Config->HostServ)
+ if (!params.empty() || source.c || source.service->nick != Config->HostServ)
return EVENT_CONTINUE;
source.Reply(_("%s commands:"), Config->HostServ.c_str());
return EVENT_CONTINUE;
diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp
index f24b69edf..faeeae1fc 100644
--- a/modules/pseudoclients/memoserv.cpp
+++ b/modules/pseudoclients/memoserv.cpp
@@ -202,7 +202,7 @@ class MemoServCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.owner->nick != Config->MemoServ)
+ if (!params.empty() || source.c || source.service->nick != Config->MemoServ)
return EVENT_CONTINUE;
source.Reply(_("\002%s\002 is a utility allowing IRC users to send short\n"
"messages to other IRC users, whether they are online at\n"
@@ -215,7 +215,7 @@ class MemoServCore : public Module
void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.owner->nick != Config->MemoServ)
+ if (!params.empty() || source.c || source.service->nick != Config->MemoServ)
return;
source.Reply(_(" \n"
"Type \002%s%s HELP \037command\037\002 for help on any of the\n"
diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp
index cda719a33..caffd74d4 100644
--- a/modules/pseudoclients/nickserv.cpp
+++ b/modules/pseudoclients/nickserv.cpp
@@ -320,7 +320,7 @@ class NickServCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.owner->nick != Config->NickServ)
+ if (!params.empty() || source.c || source.service->nick != Config->NickServ)
return EVENT_CONTINUE;
source.Reply(_("\002%s\002 allows you to \"register\" a nickname and\n"
"prevent others from using it. The following\n"
@@ -333,7 +333,7 @@ class NickServCore : public Module
void OnPostHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.owner->nick != Config->NickServ)
+ if (!params.empty() || source.c || source.service->nick != Config->NickServ)
return;
if (source.IsServicesOper())
source.Reply(_(" \n"
diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp
index b02120e91..cc051d685 100644
--- a/modules/pseudoclients/operserv.cpp
+++ b/modules/pseudoclients/operserv.cpp
@@ -249,7 +249,7 @@ class OperServCore : public Module
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- if (!params.empty() || source.owner->nick != Config->OperServ)
+ if (!params.empty() || source.c || source.service->nick != Config->OperServ)
return EVENT_CONTINUE;
source.Reply(_("%s commands:"), Config->OperServ.c_str());
return EVENT_CONTINUE;