summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/commands.h17
-rw-r--r--modules/commands/cs_access.cpp10
-rw-r--r--modules/commands/cs_register.cpp16
-rw-r--r--modules/commands/cs_set.cpp15
-rw-r--r--modules/commands/cs_xop.cpp21
-rw-r--r--modules/commands/ms_read.cpp15
-rw-r--r--modules/commands/ns_group.cpp2
-rw-r--r--modules/commands/ns_register.cpp5
-rw-r--r--modules/commands/ns_set.cpp22
-rw-r--r--modules/extra/m_ldap_authentication.cpp2
-rw-r--r--modules/extra/m_xmlrpc_main.cpp2
-rw-r--r--modules/m_rewrite.cpp2
-rw-r--r--src/bots.cpp2
-rw-r--r--src/command.cpp27
14 files changed, 113 insertions, 45 deletions
diff --git a/include/commands.h b/include/commands.h
index d4de074fe..06bb74c7b 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -163,8 +163,21 @@ class CoreExport Command : public Service
* @param subcommand The subcommand the user tried to use
*/
virtual void OnSyntaxError(CommandSource &source, const Anope::string &subcommand);
-};
-extern CoreExport void RunCommand(CommandSource &source, const Anope::string &message);
+ /** Runs a command
+ * @param source The source of the command
+ * @param message The full message to run, the command is at the beginning of the message
+ */
+ static void Run(CommandSource &source, const Anope::string &message);
+
+ /** Looks up a command name from the service name.
+ * Note that if the same command exists multiple places this will return the first one encountered
+ * @param command_service The command service to lookup, eg, nickserv/register
+ * @param bot If found, is set to the bot the command is on, eg NickServ
+ * @param name If found, is set to the comand name, eg REGISTER
+ * @return true if the given command service exists
+ */
+ static bool FindCommandFromService(const Anope::string &command_service, BotInfo* &bi, Anope::string &name);
+};
#endif // COMMANDS_H
diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp
index 88dd751c3..f8356b383 100644
--- a/modules/commands/cs_access.cpp
+++ b/modules/commands/cs_access.cpp
@@ -554,9 +554,13 @@ class CommandCSAccess : public Command
"The \002ACCESS CLEAR\002 command clears all entries of the\n"
"access list."));
source.Reply(" ");
- source.Reply(_("\002User access levels\002 can be seen by using the\n"
- "\002LEVELS\002 command; type \002%s%s HELP LEVELS\002 for\n"
- "information."), source.service->nick.c_str(), Config->StrictPrivmsg.c_str(), source.service->nick.c_str());
+
+ BotInfo *bi;
+ Anope::string cmd;
+ if (Command::FindCommandFromService("chanserv/levels", bi, cmd))
+ source.Reply(_("\002User access levels\002 can be seen by using the\n"
+ "\002%s\002 command; type \002%s%s HELP LEVELS\002 for\n"
+ "information."), cmd.c_str(), Config->StrictPrivmsg.c_str(), bi->nick.c_str());
return true;
}
};
diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp
index feeb605bc..ff2fbf69c 100644
--- a/modules/commands/cs_register.cpp
+++ b/modules/commands/cs_register.cpp
@@ -103,14 +103,16 @@ class CommandCSRegister : public Command
"\"founder\" of the channel. The channel founder is allowed\n"
"to change all of the channel settings for the channel;\n"
"%s will also automatically give the founder\n"
- "channel-operator privileges when s/he enters the channel.\n"
- "See the \002ACCESS\002 command (\002%s%s HELP ACCESS\002) for\n"
- "information on giving a subset of these privileges to\n"
- "other channel users.\n"
- " \n"
+ "channel-operator privileges when s/he enters the channel."));
+ BotInfo *bi;
+ Anope::string cmd;
+ if (Command::FindCommandFromService("chanserv/access", bi, cmd))
+ source.Reply(_("See the \002%s002 command (\002%s%s HELP ACCESS\002) for\n"
+ "information on giving a subset of these privileges to\n"
+ "other channel users.\n"), cmd.c_str(), Config->StrictPrivmsg.c_str(), bi->nick.c_str());
+ source.Reply(_(" \n"
"NOTICE: In order to register a channel, you must have\n"
- "first registered your nickname."),
- source.service->nick.c_str(), source.service->nick.c_str(), Config->StrictPrivmsg.c_str(), source.service->nick.c_str());
+ "first registered your nickname."));
return true;
}
};
diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp
index 0de1a39ad..4c49c9a21 100644
--- a/modules/commands/cs_set.cpp
+++ b/modules/commands/cs_set.cpp
@@ -106,8 +106,8 @@ class CommandCSSetAutoOp : public Command
source.Reply(" ");
source.Reply(_("Enables or disables %s's autoop feature for a\n"
"channel. When disabled, users who join the channel will\n"
- "not automatically gain any status from %s."), ChanServ->nick.c_str(),
- ChanServ->nick.c_str(), this->name.c_str());
+ "not automatically gain any status from %s."), source.service->nick.c_str(),
+ source.service->nick.c_str(), this->name.c_str());
return true;
}
};
@@ -652,10 +652,13 @@ class CommandCSSetPrivate : public Command
{
this->SendSyntax(source);
source.Reply(" ");
- source.Reply(_("Enables or disables the \002private\002 option for a channel.\n"
- "When \002private\002 is set, a \002%s%s LIST\002 will not\n"
- "include the channel in any lists."),
- Config->StrictPrivmsg.c_str(), source.service->nick.c_str());
+ source.Reply(_("Enables or disables the \002private\002 option for a channel."));
+
+ BotInfo *bi;
+ Anope::string cmd;
+ if (Command::FindCommandFromService("chanserv/list", bi, cmd))
+ source.Reply(_("When \002private\002 is set, the channel will not appear in\n"
+ "%s's %s command."), bi->nick.c_str(), cmd.c_str());
return true;
}
};
diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp
index 9efde866c..192eb4529 100644
--- a/modules/commands/cs_xop.cpp
+++ b/modules/commands/cs_xop.cpp
@@ -524,12 +524,21 @@ class CommandCSXOP : public Command
"(unless SECUREOPS is off). However, any user on the\n"
"VOP list or above may use the \002%s LIST\002 command.\n"
" \n"), cmd.c_str(), cmd.c_str());
- source.Reply(_("Alternative methods of modifying channel access lists are\n"
- "available. See \002%s%s HELP ACCESS\002 for information\n"
- "about the access list, and \002%s%s HELP FLAGS\002 for\n"
- "information about the flags based system."),
- Config->StrictPrivmsg.c_str(), source.service->nick.c_str(),
- Config->StrictPrivmsg.c_str(), source.service->nick.c_str());
+ BotInfo *access_bi, *flags_bi;
+ Anope::string access_cmd, flags_cmd;
+ Command::FindCommandFromService("chanserv/access", access_bi, access_cmd);
+ Command::FindCommandFromService("chanserv/flags", flags_bi, access_cmd);
+ if (!access_cmd.empty() || !flags_cmd.empty())
+ {
+ source.Reply(_("Alternative methods of modifying channel access lists are\n"
+ "available. "));
+ if (!access_cmd.empty())
+ source.Reply(_("See \002%s%s HELP %s\002 for more information\n"
+ "about the access list."), Config->StrictPrivmsg.c_str(), access_bi->nick.c_str(), access_cmd.c_str());
+ if (!flags_cmd.empty())
+ source.Reply(_("See \002%s%s HELP %s\002 for more information\n"
+ "about the flags system."), Config->StrictPrivmsg.c_str(), flags_bi->nick.c_str(), flags_cmd.c_str());
+ }
return true;
}
};
diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp
index 7e1e89236..b25b4fc4b 100644
--- a/modules/commands/ms_read.cpp
+++ b/modules/commands/ms_read.cpp
@@ -72,11 +72,20 @@ class MemoListCallback : public NumberList
Memo *m = mi->GetMemo(index);
if (!m)
return;
-
+
if (ci)
- source.Reply(_("Memo %d from %s (%s). To delete, type: \002%s%s DEL %s %d\002"), index + 1, m->sender.c_str(), Anope::strftime(m->time).c_str(), Config->StrictPrivmsg.c_str(), MemoServ->nick.c_str(), ci->name.c_str(), index + 1);
+ source.Reply(_("Memo %d from %s (%s)."), index + 1, m->sender.c_str(), Anope::strftime(m->time).c_str());
else
- source.Reply(_("Memo %d from %s (%s). To delete, type: \002%s%s DEL %d\002"), index + 1, m->sender.c_str(), Anope::strftime(m->time).c_str(), Config->StrictPrivmsg.c_str(), MemoServ->nick.c_str(), index + 1);
+ source.Reply(_("Memo %d from %s (%s)."), index + 1, m->sender.c_str(), Anope::strftime(m->time).c_str());
+
+ BotInfo *bi;
+ Anope::string cmd;
+ if (Command::FindCommandFromService("memoserv/del", bi, cmd))
+ if (ci)
+ source.Reply(_("To delete, type: \002%s%s %s %s %d\002"), Config->StrictPrivmsg.c_str(), bi->nick.c_str(), cmd.c_str(), ci->name.c_str(), index + 1);
+ else
+ source.Reply(_("To delete, type: \002%s%s %s %d\002"), Config->StrictPrivmsg.c_str(), bi->nick.c_str(), cmd.c_str(), index + 1);
+
source.Reply("%s", m->text.c_str());
m->unread = false;
diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp
index 97551cfcb..a744b9afc 100644
--- a/modules/commands/ns_group.cpp
+++ b/modules/commands/ns_group.cpp
@@ -131,7 +131,7 @@ class CommandNSGroup : public Command
else if (na && *target->nc == *na->nc)
source.Reply(_("You are already a member of the group of \002%s\002."), target->nick.c_str());
else if (na && na->nc != u->Account())
- source.Reply(NICK_IDENTIFY_REQUIRED, Config->StrictPrivmsg.c_str(), NickServ->nick.c_str());
+ source.Reply(NICK_IDENTIFY_REQUIRED);
else if (na && Config->GetModule(this->owner)->Get<bool>("nogroupchange"))
source.Reply(_("Your nick is already registered."));
else if (target->nc->aliases->size() >= Config->GetModule(this->owner)->Get<unsigned>("maxaliases") && !target->nc->IsServicesOper())
diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp
index da2f6de59..2d2f59877 100644
--- a/modules/commands/ns_register.cpp
+++ b/modules/commands/ns_register.cpp
@@ -220,7 +220,10 @@ class CommandNSRegister : public Command
if (SendRegmail(u, na, source.service))
{
time_t unconfirmed_expire = Config->GetModule("nickserv")->Get<time_t>("unconfirmedexpire", "1d");
- source.Reply(_("A passcode has been sent to %s, please type \002%s%s CONFIRM <passcode>\002 to confirm your email address."), email.c_str(), Config->StrictPrivmsg.c_str(), NickServ->nick.c_str());
+ BotInfo *bi;
+ Anope::string cmd;
+ if (Command::FindCommandFromService("nickserv/confirm", bi, cmd))
+ source.Reply(_("A passcode has been sent to %s, please type \002%s%s %s <passcode>\002 to confirm your email address."), email.c_str(), Config->StrictPrivmsg.c_str(), bi->nick.c_str(), cmd.c_str());
source.Reply(_("If you do not confirm your email address within %s your account will expire."), Anope::Duration(unconfirmed_expire).c_str());
}
}
diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp
index 93024b437..3dac72f71 100644
--- a/modules/commands/ns_set.cpp
+++ b/modules/commands/ns_set.cpp
@@ -98,7 +98,7 @@ class CommandNSSASet : public Command
source.Reply(_("Type \002%s%s HELP %s \037option\037\002 for more information\n"
"on a specific option. The options will be set on the given\n"
- "\037nickname\037."), Config->StrictPrivmsg.c_str(), NickServ->nick.c_str(), this_name.c_str());
+ "\037nickname\037."), Config->StrictPrivmsg.c_str(), source.service->nick.c_str(), this_name.c_str());
return true;
}
};
@@ -724,13 +724,13 @@ class CommandNSSetHide : public Command
{
Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change hide " << param << " to " << arg << " for " << nc->display;
nc->ExtendMetadata(flag);
- source.Reply(onmsg.c_str(), nc->display.c_str(), NickServ->nick.c_str());
+ source.Reply(onmsg.c_str(), nc->display.c_str(), source.service->nick.c_str());
}
else if (arg.equals_ci("OFF"))
{
Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to change hide " << param << " to " << arg << " for " << nc->display;
nc->Shrink(flag);
- source.Reply(offmsg.c_str(), nc->display.c_str(), NickServ->nick.c_str());
+ source.Reply(offmsg.c_str(), nc->display.c_str(), source.service->nick.c_str());
}
else
this->OnSyntaxError(source, "HIDE");
@@ -753,7 +753,7 @@ class CommandNSSetHide : public Command
"user@host mask (\002USERMASK\002), your services access status\n"
"(\002STATUS\002) and last quit message (\002QUIT\002).\n"
"The second parameter specifies whether the information should\n"
- "be displayed (\002OFF\002) or hidden (\002ON\002)."), NickServ->nick.c_str());
+ "be displayed (\002OFF\002) or hidden (\002ON\002)."), source.service->nick.c_str());
return true;
}
};
@@ -782,7 +782,7 @@ class CommandNSSASetHide : public CommandNSSetHide
"user@host mask (\002USERMASK\002), the services access status\n"
"(\002STATUS\002) and last quit message (\002QUIT\002).\n"
"The second parameter specifies whether the information should\n"
- "be displayed (\002OFF\002) or hidden (\002ON\002)."), NickServ->nick.c_str());
+ "be displayed (\002OFF\002) or hidden (\002ON\002)."), source.service->nick.c_str());
return true;
}
};
@@ -880,7 +880,7 @@ class CommandNSSetKill : public Command
"\002IMMED\002, user's nick will be changed immediately \037without\037 being\n"
"warned first or given a chance to change their nick; please\n"
"do not use this option unless necessary. Also, your\n"
- "network's administrators may have disabled this option."), NickServ->nick.c_str());
+ "network's administrators may have disabled this option."), source.service->nick.c_str());
return true;
}
};
@@ -914,7 +914,7 @@ class CommandNSSASetKill : public CommandNSSetKill
"\002IMMED\002, the user's nick will be changed immediately \037without\037 being\n"
"warned first or given a chance to change their nick; please\n"
"do not use this option unless necessary. Also, your\n"
- "network's administrators may have disabled this option."), NickServ->nick.c_str());
+ "network's administrators may have disabled this option."), source.service->nick.c_str());
return true;
}
};
@@ -1172,7 +1172,7 @@ class CommandNSSetPrivate : public Command
"nickname lists generated with %s's \002LIST\002 command.\n"
"(However, anyone who knows your nickname can still get\n"
"information on it using the \002INFO\002 command.)"),
- NickServ->nick.c_str(), NickServ->nick.c_str());
+ source.service->nick.c_str(), source.service->nick.c_str());
return true;
}
};
@@ -1200,7 +1200,7 @@ class CommandNSSASetPrivate : public CommandNSSetPrivate
"nickname lists generated with %s's \002LIST\002 command.\n"
"(However, anyone who knows the nickname can still get\n"
"information on it using the \002INFO\002 command.)"),
- NickServ->nick.c_str(), NickServ->nick.c_str());
+ source.service->nick.c_str(), source.service->nick.c_str());
return true;
}
};
@@ -1260,7 +1260,7 @@ class CommandNSSetSecure : public Command
"regardless of whether your address is on the access\n"
"list. However, if you are on the access list, %s\n"
"will not auto-kill you regardless of the setting of the\n"
- "\002KILL\002 option."), NickServ->nick.c_str(), NickServ->nick.c_str());
+ "\002KILL\002 option."), source.service->nick.c_str(), source.service->nick.c_str());
return true;
}
};
@@ -1289,7 +1289,7 @@ class CommandNSSASetSecure : public CommandNSSetSecure
"regardless of whether your address is on the access\n"
"list. However, if you are on the access list, %s\n"
"will not auto-kill you regardless of the setting of the\n"
- "\002KILL\002 option."), NickServ->nick.c_str(), NickServ->nick.c_str());
+ "\002KILL\002 option."), source.service->nick.c_str(), source.service->nick.c_str());
return true;
}
};
diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp
index 08f070bb8..935ba76d5 100644
--- a/modules/extra/m_ldap_authentication.cpp
+++ b/modules/extra/m_ldap_authentication.cpp
@@ -235,7 +235,7 @@ class NSIdentifyLDAP : public Module
if (!email_attribute.empty())
/* Don't complain to users about how they need to update their email, we will do it for them */
- Config->GetBlock("nickserv")->Set("forceemail", "false");
+ config->GetBlock("nickserv")->Set("forceemail", "false");
}
EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) anope_override
diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp
index b6b47c6f4..b697a2c8c 100644
--- a/modules/extra/m_xmlrpc_main.cpp
+++ b/modules/extra/m_xmlrpc_main.cpp
@@ -99,7 +99,7 @@ class MyXMLRPCEvent : public XMLRPCEvent
reply(out);
CommandSource source(user, NULL, na ? *na->nc : NULL, &reply, bi);
- RunCommand(source, command);
+ Command::Run(source, command);
if (!out.empty())
request.reply("return", iface->Sanitize(out));
diff --git a/modules/m_rewrite.cpp b/modules/m_rewrite.cpp
index 8131a1729..f2f3c8690 100644
--- a/modules/m_rewrite.cpp
+++ b/modules/m_rewrite.cpp
@@ -118,7 +118,7 @@ class RewriteCommand : public Command
source.service = BotInfo::Find(r->client);
if (!source.service)
return;
- RunCommand(source, new_message);
+ Command::Run(source, new_message);
}
else
Log() << "m_rewrite: Unable to rewrite '" << source.command << (!params.empty() ? " " + params[0] : "") << "'";
diff --git a/src/bots.cpp b/src/bots.cpp
index fcbedeeb3..332bd151d 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -201,7 +201,7 @@ void BotInfo::OnMessage(User *u, const Anope::string &message)
return;
CommandSource source(u->nick, u, u->Account(), u, this);
- RunCommand(source, message);
+ Command::Run(source, message);
}
CommandInfo& BotInfo::SetCommand(const Anope::string &cname, const Anope::string &sname, const Anope::string &permission)
diff --git a/src/command.cpp b/src/command.cpp
index b7289b848..421c90b93 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -194,7 +194,7 @@ void Command::OnSyntaxError(CommandSource &source, const Anope::string &subcomma
source.Reply(MORE_INFO, Config->StrictPrivmsg.c_str(), source.service->nick.c_str(), source.command.c_str());
}
-void RunCommand(CommandSource &source, const Anope::string &message)
+void Command::Run(CommandSource &source, const Anope::string &message)
{
std::vector<Anope::string> params;
spacesepstream(message).GetTokens(params);
@@ -282,3 +282,28 @@ void RunCommand(CommandSource &source, const Anope::string &message)
FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, c, params));
}
+bool Command::FindCommandFromService(const Anope::string &command_service, BotInfo* &bot, Anope::string &name)
+{
+ bot = NULL;
+
+ for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
+ {
+ BotInfo *bi = it->second;
+
+ for (CommandInfo::map::const_iterator cit = bi->commands.begin(), cit_end = bi->commands.end(); cit != cit_end; ++cit)
+ {
+ const Anope::string &c_name = cit->first;
+ const CommandInfo &info = cit->second;
+
+ if (info.name != command_service)
+ continue;
+
+ bot = bi;
+ name = c_name;
+ return true;
+ }
+ }
+
+ return false;
+}
+