From cb6ef574e3df5cc846247450b74ca37d265f319e Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 24 Nov 2010 21:40:56 -0600 Subject: Send replies from fantasy commands back to the channel, this will be expanded on later --- modules/core/bs_act.cpp | 11 +- modules/core/bs_assign.cpp | 25 ++-- modules/core/bs_badwords.cpp | 112 +++++++-------- modules/core/bs_bot.cpp | 117 ++++++++-------- modules/core/bs_botlist.cpp | 17 +-- modules/core/bs_help.cpp | 3 +- modules/core/bs_info.cpp | 111 +++++++-------- modules/core/bs_kick.cpp | 93 ++++++------- modules/core/bs_say.cpp | 16 +-- modules/core/bs_set.cpp | 55 ++++---- modules/core/bs_unassign.cpp | 17 +-- modules/core/cs_access.cpp | 249 +++++++++++++++++++--------------- modules/core/cs_akick.cpp | 153 ++++++++++++--------- modules/core/cs_ban.cpp | 35 ++--- modules/core/cs_clearusers.cpp | 18 +-- modules/core/cs_clone.cpp | 22 +-- modules/core/cs_drop.cpp | 16 ++- modules/core/cs_forbid.cpp | 17 +-- modules/core/cs_getkey.cpp | 14 +- modules/core/cs_help.cpp | 4 +- modules/core/cs_info.cpp | 32 +++-- modules/core/cs_invite.cpp | 22 +-- modules/core/cs_kick.cpp | 35 ++--- modules/core/cs_list.cpp | 24 ++-- modules/core/cs_mode.cpp | 42 +++--- modules/core/cs_modes.cpp | 32 +++-- modules/core/cs_register.cpp | 30 ++-- modules/core/cs_saset.cpp | 14 +- modules/core/cs_saset_noexpire.cpp | 9 +- modules/core/cs_set.cpp | 16 ++- modules/core/cs_set_bantype.cpp | 8 +- modules/core/cs_set_description.cpp | 5 +- modules/core/cs_set_founder.cpp | 13 +- modules/core/cs_set_keeptopic.cpp | 9 +- modules/core/cs_set_opnotice.cpp | 9 +- modules/core/cs_set_peace.cpp | 9 +- modules/core/cs_set_persist.cpp | 9 +- modules/core/cs_set_private.cpp | 9 +- modules/core/cs_set_restricted.cpp | 9 +- modules/core/cs_set_secure.cpp | 9 +- modules/core/cs_set_securefounder.cpp | 11 +- modules/core/cs_set_secureops.cpp | 9 +- modules/core/cs_set_signkick.cpp | 11 +- modules/core/cs_set_successor.cpp | 17 +-- modules/core/cs_set_topiclock.cpp | 9 +- modules/core/cs_set_xop.cpp | 12 +- modules/core/cs_status.cpp | 26 ++-- modules/core/cs_suspend.cpp | 41 ++---- modules/core/cs_topic.cpp | 12 +- modules/core/cs_unban.cpp | 27 ++-- modules/core/cs_xop.cpp | 155 +++++++++++---------- modules/core/hs_del.cpp | 16 ++- modules/core/hs_delall.cpp | 16 ++- modules/core/hs_group.cpp | 9 +- modules/core/hs_help.cpp | 4 +- modules/core/hs_list.cpp | 24 ++-- modules/core/hs_off.cpp | 7 +- modules/core/hs_on.cpp | 9 +- modules/core/hs_set.cpp | 30 ++-- modules/core/hs_setall.cpp | 32 +++-- modules/core/ms_cancel.cpp | 19 +-- modules/core/ms_check.cpp | 30 ++-- modules/core/ms_del.cpp | 33 ++--- modules/core/ms_help.cpp | 4 +- modules/core/ms_ignore.cpp | 24 ++-- modules/core/ms_info.cpp | 80 +++++------ modules/core/ms_list.cpp | 42 +++--- modules/core/ms_read.cpp | 31 +++-- modules/core/ms_rsend.cpp | 14 +- modules/core/ms_send.cpp | 7 +- modules/core/ms_sendall.cpp | 7 +- modules/core/ms_set.cpp | 73 +++++----- modules/core/ms_staff.cpp | 7 +- modules/core/ns_access.cpp | 65 ++++----- modules/core/ns_alist.cpp | 18 +-- modules/core/ns_drop.cpp | 27 ++-- modules/core/ns_forbid.cpp | 18 +-- modules/core/ns_getemail.cpp | 9 +- modules/core/ns_getpass.cpp | 17 +-- modules/core/ns_ghost.cpp | 22 +-- modules/core/ns_group.cpp | 68 +++++----- modules/core/ns_help.cpp | 4 +- modules/core/ns_identify.cpp | 26 ++-- modules/core/ns_info.cpp | 51 +++---- modules/core/ns_list.cpp | 18 +-- modules/core/ns_logout.cpp | 18 +-- modules/core/ns_recover.cpp | 26 ++-- modules/core/ns_register.cpp | 68 +++++----- modules/core/ns_release.cpp | 21 +-- modules/core/ns_resetpass.cpp | 19 +-- modules/core/ns_saset.cpp | 37 ++--- modules/core/ns_saset_noexpire.cpp | 7 +- modules/core/ns_sendpass.cpp | 15 +- modules/core/ns_set.cpp | 30 ++-- modules/core/ns_set_autoop.cpp | 7 +- modules/core/ns_set_email.cpp | 13 +- modules/core/ns_set_greet.cpp | 6 +- modules/core/ns_set_hide.cpp | 7 +- modules/core/ns_set_kill.cpp | 13 +- modules/core/ns_set_language.cpp | 5 +- modules/core/ns_set_message.cpp | 11 +- modules/core/ns_set_private.cpp | 7 +- modules/core/ns_set_secure.cpp | 7 +- modules/core/ns_status.cpp | 19 +-- modules/core/ns_suspend.cpp | 41 +++--- modules/core/ns_update.cpp | 3 +- modules/core/os_akill.cpp | 117 ++++++++-------- modules/core/os_chankill.cpp | 7 +- modules/core/os_chanlist.cpp | 15 +- modules/core/os_defcon.cpp | 17 +-- modules/core/os_global.cpp | 5 +- modules/core/os_help.cpp | 4 +- modules/core/os_ignore.cpp | 48 ++++--- modules/core/os_jupe.cpp | 11 +- modules/core/os_kick.cpp | 13 +- modules/core/os_mode.cpp | 10 +- modules/core/os_modinfo.cpp | 64 ++++----- modules/core/os_modlist.cpp | 27 ++-- modules/core/os_modload.cpp | 11 +- modules/core/os_modreload.cpp | 17 +-- modules/core/os_modunload.cpp | 15 +- modules/core/os_news.cpp | 72 +++++----- modules/core/os_noop.cpp | 11 +- modules/core/os_oline.cpp | 13 +- modules/core/os_quit.cpp | 3 +- modules/core/os_reload.cpp | 4 +- modules/core/os_restart.cpp | 3 +- modules/core/os_session.cpp | 129 ++++++++++-------- modules/core/os_set.cpp | 98 ++++++------- modules/core/os_shutdown.cpp | 3 +- modules/core/os_snline.cpp | 120 ++++++++-------- modules/core/os_sqline.cpp | 113 +++++++-------- modules/core/os_staff.cpp | 9 +- modules/core/os_stats.cpp | 140 +++++++++---------- modules/core/os_svsnick.cpp | 19 +-- modules/core/os_szline.cpp | 110 ++++++++------- modules/core/os_umode.cpp | 11 +- modules/core/os_update.cpp | 3 +- modules/core/os_userlist.cpp | 15 +- modules/core/ss_main.cpp | 3 +- 140 files changed, 2256 insertions(+), 2025 deletions(-) (limited to 'modules/core') diff --git a/modules/core/bs_act.cpp b/modules/core/bs_act.cpp index b575f5030..87c7125ee 100644 --- a/modules/core/bs_act.cpp +++ b/modules/core/bs_act.cpp @@ -20,26 +20,27 @@ class CommandBSAct : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { - ChannelInfo *ci = cs_findchan(params[0]); + User *u = source.u; + ChannelInfo *ci = source.ci; Anope::string message = params[1]; if (!check_access(u, ci, CA_SAY)) { - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); return MOD_CONT; } if (!ci->bi) { - u->SendMessage(BotServ, BOT_NOT_ASSIGNED); + source.Reply(BOT_NOT_ASSIGNED); return MOD_CONT; } if (!ci->c || !ci->c->FindUser(ci->bi)) { - u->SendMessage(BotServ, BOT_NOT_ON_CHANNEL, ci->name.c_str()); + source.Reply(BOT_NOT_ON_CHANNEL, ci->name.c_str()); return MOD_CONT; } diff --git a/modules/core/bs_assign.cpp b/modules/core/bs_assign.cpp index c328c2f51..a390d952c 100644 --- a/modules/core/bs_assign.cpp +++ b/modules/core/bs_assign.cpp @@ -20,42 +20,41 @@ class CommandBSAssign : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { - Anope::string chan = params[0]; - Anope::string nick = params[1]; - BotInfo *bi; - ChannelInfo *ci; + const Anope::string &chan = params[0]; + const Anope::string &nick = params[1]; + User *u = source.u; + ChannelInfo *ci = source.ci; if (readonly) { - u->SendMessage(BotServ, BOT_ASSIGN_READONLY); + source.Reply(BOT_ASSIGN_READONLY); return MOD_CONT; } - if (!(bi = findbot(nick))) + BotInfo *bi = findbot(nick); + if (!bi) { - u->SendMessage(BotServ, BOT_DOES_NOT_EXIST, nick.c_str()); + source.Reply(BOT_DOES_NOT_EXIST, nick.c_str()); return MOD_CONT; } - ci = cs_findchan(chan); - if (ci->botflags.HasFlag(BS_NOBOT) || (!check_access(u, ci, CA_ASSIGN) && !u->Account()->HasPriv("botserv/administration"))) { - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); return MOD_CONT; } if (bi->HasFlag(BI_PRIVATE) && !u->Account()->HasCommand("botserv/assign/private")) { - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); return MOD_CONT; } if (ci->bi && nick.equals_ci(ci->bi->nick)) { - u->SendMessage(BotServ, BOT_ASSIGN_ALREADY, ci->bi->nick.c_str(), chan.c_str()); + source.Reply(BOT_ASSIGN_ALREADY, ci->bi->nick.c_str(), chan.c_str()); return MOD_CONT; } diff --git a/modules/core/bs_badwords.cpp b/modules/core/bs_badwords.cpp index d6fe6bfd5..d1c3a9070 100644 --- a/modules/core/bs_badwords.cpp +++ b/modules/core/bs_badwords.cpp @@ -15,88 +15,87 @@ class BadwordsListCallback : public NumberList { - User *u; - ChannelInfo *ci; + CommandSource &source; bool SentHeader; public: - BadwordsListCallback(User *_u, ChannelInfo *_ci, const Anope::string &list) : NumberList(list, false), u(_u), ci(_ci), SentHeader(false) + BadwordsListCallback(CommandSource &_source, const Anope::string &list) : NumberList(list, false), source(_source), SentHeader(false) { } ~BadwordsListCallback() { if (!SentHeader) - u->SendMessage(BotServ, BOT_BADWORDS_NO_MATCH, ci->name.c_str()); + source.Reply(BOT_BADWORDS_NO_MATCH, source.ci->name.c_str()); } void HandleNumber(unsigned Number) { - if (!Number || Number > ci->GetBadWordCount()) + if (!Number || Number > source.ci->GetBadWordCount()) return; if (!SentHeader) { SentHeader = true; - u->SendMessage(BotServ, BOT_BADWORDS_LIST_HEADER, ci->name.c_str()); + source.Reply(BOT_BADWORDS_LIST_HEADER, source.ci->name.c_str()); } - DoList(u, ci, Number - 1, ci->GetBadWord(Number - 1)); + DoList(source, Number - 1, source.ci->GetBadWord(Number - 1)); } - static void DoList(User *u, ChannelInfo *ci, unsigned Number, BadWord *bw) + static void DoList(CommandSource &source, unsigned Number, BadWord *bw) { - u->SendMessage(BotServ, BOT_BADWORDS_LIST_FORMAT, Number + 1, bw->word.c_str(), bw->type == BW_SINGLE ? "(SINGLE)" : (bw->type == BW_START ? "(START)" : (bw->type == BW_END ? "(END)" : ""))); + source.Reply(BOT_BADWORDS_LIST_FORMAT, Number + 1, bw->word.c_str(), bw->type == BW_SINGLE ? "(SINGLE)" : (bw->type == BW_START ? "(START)" : (bw->type == BW_END ? "(END)" : ""))); } }; class BadwordsDelCallback : public NumberList { - User *u; - ChannelInfo *ci; + CommandSource &source; Command *c; unsigned Deleted; bool override; public: - BadwordsDelCallback(User *_u, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), u(_u), ci(_ci), c(_c), Deleted(0), override(false) + BadwordsDelCallback(CommandSource &_source, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), c(_c), Deleted(0), override(false) { - if (!check_access(u, ci, CA_BADWORDS) && u->Account()->HasPriv("botserv/administration")) + if (!check_access(source.u, source.ci, CA_BADWORDS) && source.u->Account()->HasPriv("botserv/administration")) this->override = true; } ~BadwordsDelCallback() { if (!Deleted) - u->SendMessage(BotServ, BOT_BADWORDS_NO_MATCH, ci->name.c_str()); + source.Reply(BOT_BADWORDS_NO_MATCH, source.ci->name.c_str()); else if (Deleted == 1) - u->SendMessage(BotServ, BOT_BADWORDS_DELETED_ONE, ci->name.c_str()); + source.Reply(BOT_BADWORDS_DELETED_ONE, source.ci->name.c_str()); else - u->SendMessage(BotServ, BOT_BADWORDS_DELETED_SEVERAL, Deleted, ci->name.c_str()); + source.Reply(BOT_BADWORDS_DELETED_SEVERAL, Deleted, source.ci->name.c_str()); } void HandleNumber(unsigned Number) { - if (!Number || Number > ci->GetBadWordCount()) + if (!Number || Number > source.ci->GetBadWordCount()) return; - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, c, ci) << "DEL " << ci->GetBadWord(Number -1 )->word; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, source.ci) << "DEL " << source.ci->GetBadWord(Number - 1)->word; ++Deleted; - ci->EraseBadWord(Number - 1); + source.ci->EraseBadWord(Number - 1); } }; class CommandBSBadwords : public Command { private: - CommandReturn DoList(User *u, ChannelInfo *ci, const Anope::string &word) + CommandReturn DoList(CommandSource &source, const Anope::string &word) { - bool override = !check_access(u, ci, CA_BADWORDS); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "LIST"; + ChannelInfo *ci = source.ci; + bool override = !check_access(source.u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "LIST"; if (!ci->GetBadWordCount()) - u->SendMessage(BotServ, BOT_BADWORDS_LIST_EMPTY, ci->name.c_str()); + source.Reply(BOT_BADWORDS_LIST_EMPTY, ci->name.c_str()); else if (!word.empty() && word.find_first_not_of("1234567890,-") == Anope::string::npos) { - BadwordsListCallback list(u, ci, word); + BadwordsListCallback list(source, word); list.Process(); } else @@ -113,21 +112,22 @@ class CommandBSBadwords : public Command if (!SentHeader) { SentHeader = true; - u->SendMessage(BotServ, BOT_BADWORDS_LIST_HEADER, ci->name.c_str()); + source.Reply(BOT_BADWORDS_LIST_HEADER, ci->name.c_str()); } - BadwordsListCallback::DoList(u, ci, i, bw); + BadwordsListCallback::DoList(source, i, bw); } if (!SentHeader) - u->SendMessage(BotServ, BOT_BADWORDS_NO_MATCH, ci->name.c_str()); + source.Reply(BOT_BADWORDS_NO_MATCH, ci->name.c_str()); } return MOD_CONT; } - CommandReturn DoAdd(User *u, ChannelInfo *ci, const Anope::string &word) + CommandReturn DoAdd(CommandSource &source, const Anope::string &word) { + ChannelInfo *ci = source.ci; size_t pos = word.rfind(' '); BadWordType type = BW_ANY; Anope::string realword = word; @@ -149,7 +149,7 @@ class CommandBSBadwords : public Command if (ci->GetBadWordCount() >= Config->BSBadWordsMax) { - u->SendMessage(BotServ, BOT_BADWORDS_REACHED_LIMIT, Config->BSBadWordsMax); + source.Reply(BOT_BADWORDS_REACHED_LIMIT, Config->BSBadWordsMax); return MOD_CONT; } @@ -159,26 +159,27 @@ class CommandBSBadwords : public Command if (!bw->word.empty() && ((Config->BSCaseSensitive && realword.equals_cs(bw->word)) || (!Config->BSCaseSensitive && realword.equals_ci(bw->word)))) { - u->SendMessage(BotServ, BOT_BADWORDS_ALREADY_EXISTS, bw->word.c_str(), ci->name.c_str()); + source.Reply(BOT_BADWORDS_ALREADY_EXISTS, bw->word.c_str(), ci->name.c_str()); return MOD_CONT; } } - bool override = !check_access(u, ci, CA_BADWORDS); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ADD " << realword; + bool override = !check_access(source.u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "ADD " << realword; ci->AddBadWord(realword, type); - u->SendMessage(BotServ, BOT_BADWORDS_ADDED, realword.c_str(), ci->name.c_str()); + source.Reply(BOT_BADWORDS_ADDED, realword.c_str(), ci->name.c_str()); return MOD_CONT; } - CommandReturn DoDelete(User *u, ChannelInfo *ci, const Anope::string &word) + CommandReturn DoDelete(CommandSource &source, const Anope::string &word) { + ChannelInfo *ci = source.ci; /* Special case: is it a number/list? Only do search if it isn't. */ if (!word.empty() && isdigit(word[0]) && word.find_first_not_of("1234567890,-") == Anope::string::npos) { - BadwordsDelCallback list(u, ci, this, word); + BadwordsDelCallback list(source, this, word); list.Process(); } else @@ -196,27 +197,28 @@ class CommandBSBadwords : public Command if (i == end) { - u->SendMessage(BotServ, BOT_BADWORDS_NOT_FOUND, word.c_str(), ci->name.c_str()); + source.Reply(BOT_BADWORDS_NOT_FOUND, word.c_str(), ci->name.c_str()); return MOD_CONT; } - bool override = !check_access(u, ci, CA_BADWORDS); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "DEL " << badword->word; + bool override = !check_access(source.u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "DEL " << badword->word; ci->EraseBadWord(i); - u->SendMessage(BotServ, BOT_BADWORDS_DELETED, badword->word.c_str(), ci->name.c_str()); + source.Reply(BOT_BADWORDS_DELETED, badword->word.c_str(), ci->name.c_str()); } return MOD_CONT; } - CommandReturn DoClear(User *u, ChannelInfo *ci) + CommandReturn DoClear(CommandSource &source) { - bool override = !check_access(u, ci, CA_BADWORDS); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "CLEAR"; + ChannelInfo *ci = source.ci; + bool override = !check_access(source.u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "CLEAR"; ci->ClearBadWords(); - u->SendMessage(BotServ, BOT_BADWORDS_CLEAR); + source.Reply(BOT_BADWORDS_CLEAR); return MOD_CONT; } public: @@ -224,12 +226,12 @@ class CommandBSBadwords : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { - Anope::string chan = params[0]; - Anope::string cmd = params[1]; - Anope::string word = params.size() > 2 ? params[2] : ""; - ChannelInfo *ci; + const Anope::string &cmd = params[1]; + const Anope::string &word = params.size() > 2 ? params[2] : ""; + User *u = source.u; + ChannelInfo *ci = source.ci; bool need_args = cmd.equals_ci("LIST") || cmd.equals_ci("CLEAR"); if (!need_args && word.empty()) @@ -238,28 +240,26 @@ class CommandBSBadwords : public Command return MOD_CONT; } - ci = cs_findchan(chan); - if (!check_access(u, ci, CA_BADWORDS) && (!need_args || !u->Account()->HasPriv("botserv/administration"))) { - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); return MOD_CONT; } if (readonly) { - u->SendMessage(BotServ, BOT_BADWORDS_DISABLED); + source.Reply(BOT_BADWORDS_DISABLED); return MOD_CONT; } if (cmd.equals_ci("ADD")) - return this->DoAdd(u, ci, word); + return this->DoAdd(source, word); else if (cmd.equals_ci("DEL")) - return this->DoDelete(u, ci, word); + return this->DoDelete(source, word); else if (cmd.equals_ci("LIST")) - return this->DoList(u, ci, word); + return this->DoList(source, word); else if (cmd.equals_ci("CLEAR")) - return this->DoClear(u, ci); + return this->DoClear(source); else this->OnSyntaxError(u, ""); diff --git a/modules/core/bs_bot.cpp b/modules/core/bs_bot.cpp index 067633964..e16c4795a 100644 --- a/modules/core/bs_bot.cpp +++ b/modules/core/bs_bot.cpp @@ -16,70 +16,70 @@ class CommandBSBot : public Command { private: - CommandReturn DoAdd(User *u, const std::vector ¶ms) + CommandReturn DoAdd(CommandSource &source, const std::vector ¶ms) { - Anope::string nick = params[1]; - Anope::string user = params[2]; - Anope::string host = params[3]; - Anope::string real = params[4]; + const Anope::string &nick = params[1]; + const Anope::string &user = params[2]; + const Anope::string &host = params[3]; + const Anope::string &real = params[4]; BotInfo *bi; if (findbot(nick)) { - u->SendMessage(BotServ, BOT_BOT_ALREADY_EXISTS, nick.c_str()); + source.Reply(BOT_BOT_ALREADY_EXISTS, nick.c_str()); return MOD_CONT; } if (nick.length() > Config->NickLen) { - u->SendMessage(BotServ, BOT_BAD_NICK); + source.Reply(BOT_BAD_NICK); return MOD_CONT; } if (user.length() > Config->UserLen) { - u->SendMessage(BotServ, BOT_LONG_IDENT, Config->UserLen); + source.Reply(BOT_LONG_IDENT, Config->UserLen); return MOD_CONT; } if (host.length() > Config->HostLen) { - u->SendMessage(BotServ, BOT_LONG_HOST, Config->HostLen); + source.Reply(BOT_LONG_HOST, Config->HostLen); return MOD_CONT; } /* Check the nick is valid re RFC 2812 */ if (isdigit(nick[0]) || nick[0] == '-') { - u->SendMessage(BotServ, BOT_BAD_NICK); + source.Reply(BOT_BAD_NICK); return MOD_CONT; } for (unsigned i = 0, end = nick.length(); i < end && i < Config->NickLen; ++i) if (!isvalidnick(nick[i])) { - u->SendMessage(BotServ, BOT_BAD_NICK); + source.Reply(BOT_BAD_NICK); return MOD_CONT; } /* check for hardcored ircd forbidden nicks */ if (!ircdproto->IsNickValid(nick)) { - u->SendMessage(BotServ, BOT_BAD_NICK); + source.Reply(BOT_BAD_NICK); return MOD_CONT; } /* Check the host is valid re RFC 2812 */ if (!isValidHost(host, 3)) { - u->SendMessage(BotServ, BOT_BAD_HOST); + source.Reply(BOT_BAD_HOST); return MOD_CONT; } for (unsigned i = 0, end = user.length(); i < end && i < Config->UserLen; ++i) if (!isalnum(user[i])) { - u->SendMessage(BotServ, BOT_BAD_IDENT, Config->UserLen); + source.Reply(BOT_BAD_IDENT, Config->UserLen); return MOD_CONT; } @@ -89,73 +89,73 @@ class CommandBSBot : public Command */ if (findnick(nick)) { - u->SendMessage(BotServ, NICK_ALREADY_REGISTERED, nick.c_str()); + source.Reply(NICK_ALREADY_REGISTERED, nick.c_str()); return MOD_CONT; } if (!(bi = new BotInfo(nick, user, host, real))) { // XXX this cant happen? - u->SendMessage(BotServ, BOT_BOT_CREATION_FAILED); + source.Reply(BOT_BOT_CREATION_FAILED); return MOD_CONT; } - Log(LOG_ADMIN, u, this) << "ADD " << bi->GetMask() << " " << bi->realname; + Log(LOG_ADMIN, source.u, this) << "ADD " << bi->GetMask() << " " << bi->realname; - u->SendMessage(BotServ, BOT_BOT_ADDED, bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); + source.Reply(BOT_BOT_ADDED, bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); FOREACH_MOD(I_OnBotCreate, OnBotCreate(bi)); return MOD_CONT; } - CommandReturn DoChange(User *u, const std::vector ¶ms) + CommandReturn DoChange(CommandSource &source, const std::vector ¶ms) { - Anope::string oldnick = params[1]; - Anope::string nick = params.size() > 2 ? params[2] : ""; - Anope::string user = params.size() > 3 ? params[3] : ""; - Anope::string host = params.size() > 4 ? params[4] : ""; - Anope::string real = params.size() > 5 ? params[5] : ""; + const Anope::string &oldnick = params[1]; + const Anope::string &nick = params.size() > 2 ? params[2] : ""; + const Anope::string &user = params.size() > 3 ? params[3] : ""; + const Anope::string &host = params.size() > 4 ? params[4] : ""; + const Anope::string &real = params.size() > 5 ? params[5] : ""; BotInfo *bi; if (oldnick.empty() || nick.empty()) { - this->OnSyntaxError(u, "CHANGE"); + this->OnSyntaxError(source.u, "CHANGE"); return MOD_CONT; } if (!(bi = findbot(oldnick))) { - u->SendMessage(BotServ, BOT_DOES_NOT_EXIST, oldnick.c_str()); + source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str()); return MOD_CONT; } if (!oldnick.equals_ci(nick) && nickIsServices(oldnick, false)) { - u->SendMessage(BotServ, BOT_DOES_NOT_EXIST, oldnick.c_str()); + source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str()); return MOD_CONT; } if (nick.length() > Config->NickLen) { - u->SendMessage(BotServ, BOT_BAD_NICK); + source.Reply(BOT_BAD_NICK); return MOD_CONT; } if (!user.empty() && user.length() > Config->UserLen) { - u->SendMessage(BotServ, BOT_LONG_IDENT, Config->UserLen); + source.Reply(BOT_LONG_IDENT, Config->UserLen); return MOD_CONT; } if (!host.empty() && host.length() > Config->HostLen) { - u->SendMessage(BotServ, BOT_LONG_HOST, Config->HostLen); + source.Reply(BOT_LONG_HOST, Config->HostLen); return MOD_CONT; } if (!oldnick.equals_ci(nick) && nickIsServices(nick, false)) { - u->SendMessage(BotServ, BOT_DOES_NOT_EXIST, oldnick.c_str()); + source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str()); return MOD_CONT; } @@ -166,34 +166,34 @@ class CommandBSBot : public Command */ if (nick.equals_cs(bi->nick) && (!user.empty() ? user.equals_cs(bi->GetIdent()) : 1) && (!host.empty() ? host.equals_cs(bi->host) : 1) && (!real.empty() ? real.equals_cs(bi->realname) : 1)) { - u->SendMessage(BotServ, BOT_BOT_ANY_CHANGES); + source.Reply(BOT_BOT_ANY_CHANGES); return MOD_CONT; } /* Check the nick is valid re RFC 2812 */ if (isdigit(nick[0]) || nick[0] == '-') { - u->SendMessage(BotServ, BOT_BAD_NICK); + source.Reply(BOT_BAD_NICK); return MOD_CONT; } for (unsigned i = 0, end = nick.length(); i < end && i < Config->NickLen; ++i) if (!isvalidnick(nick[i])) { - u->SendMessage(BotServ, BOT_BAD_NICK); + source.Reply(BOT_BAD_NICK); return MOD_CONT; } /* check for hardcored ircd forbidden nicks */ if (!ircdproto->IsNickValid(nick)) { - u->SendMessage(BotServ, BOT_BAD_NICK); + source.Reply(BOT_BAD_NICK); return MOD_CONT; } if (!host.empty() && !isValidHost(host, 3)) { - u->SendMessage(BotServ, BOT_BAD_HOST); + source.Reply(BOT_BAD_HOST); return MOD_CONT; } @@ -201,13 +201,13 @@ class CommandBSBot : public Command for (unsigned i = 0, end = user.length(); i < end && i < Config->UserLen; ++i) if (!isalnum(user[i])) { - u->SendMessage(BotServ, BOT_BAD_IDENT, Config->UserLen); + source.Reply(BOT_BAD_IDENT, Config->UserLen); return MOD_CONT; } if (!nick.equals_ci(bi->nick) && findbot(nick)) { - u->SendMessage(BotServ, BOT_BOT_ALREADY_EXISTS, nick.c_str()); + source.Reply(BOT_BOT_ALREADY_EXISTS, nick.c_str()); return MOD_CONT; } @@ -219,7 +219,7 @@ class CommandBSBot : public Command */ if (findnick(nick)) { - u->SendMessage(BotServ, NICK_ALREADY_REGISTERED, nick.c_str()); + source.Reply(NICK_ALREADY_REGISTERED, nick.c_str()); return MOD_CONT; } @@ -262,46 +262,46 @@ class CommandBSBot : public Command bi->RejoinAll(); } - u->SendMessage(BotServ, BOT_BOT_CHANGED, oldnick.c_str(), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); - Log(LOG_ADMIN, u, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; + source.Reply(BOT_BOT_CHANGED, oldnick.c_str(), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); + Log(LOG_ADMIN, source.u, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; FOREACH_MOD(I_OnBotChange, OnBotChange(bi)); return MOD_CONT; } - CommandReturn DoDel(User *u, const std::vector ¶ms) + CommandReturn DoDel(CommandSource &source, const std::vector ¶ms) { - Anope::string nick = params[1]; + const Anope::string &nick = params[1]; BotInfo *bi; if (nick.empty()) { - this->OnSyntaxError(u, "DEL"); + this->OnSyntaxError(source.u, "DEL"); return MOD_CONT; } if (!(bi = findbot(nick))) { - u->SendMessage(BotServ, BOT_DOES_NOT_EXIST, nick.c_str()); + source.Reply(BOT_DOES_NOT_EXIST, nick.c_str()); return MOD_CONT; } if (nickIsServices(nick, false)) { - u->SendMessage(BotServ, BOT_DOES_NOT_EXIST, nick.c_str()); + source.Reply(BOT_DOES_NOT_EXIST, nick.c_str()); return MOD_CONT; } FOREACH_MOD(I_OnBotDelete, OnBotDelete(bi)); - ircdproto->SendQuit(bi, "Quit: Help! I'm being deleted by %s!", u->nick.c_str()); + ircdproto->SendQuit(bi, "Quit: Help! I'm being deleted by %s!", source.u->nick.c_str()); XLine x(bi->nick); ircdproto->SendSQLineDel(&x); - Log(LOG_ADMIN, u, this) << "DEL " << bi->nick; + Log(LOG_ADMIN, source.u, this) << "DEL " << bi->nick; + source.Reply(BOT_BOT_DELETED, nick.c_str()); delete bi; - u->SendMessage(BotServ, BOT_BOT_DELETED, nick.c_str()); return MOD_CONT; } public: @@ -310,13 +310,14 @@ class CommandBSBot : public Command this->SetFlag(CFLAG_STRIP_CHANNEL); } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { - Anope::string cmd = params[0]; + const Anope::string &cmd = params[0]; + User *u = source.u; if (readonly) { - u->SendMessage(BotServ, BOT_BOT_READONLY); + source.Reply(BOT_BOT_READONLY); return MOD_CONT; } @@ -325,7 +326,7 @@ class CommandBSBot : public Command // ADD nick user host real - 5 if (!u->Account()->HasCommand("botserv/bot/add")) { - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); return MOD_CONT; } @@ -340,7 +341,7 @@ class CommandBSBot : public Command if (tempparams.size() >= 6) tempparams[4] = tempparams[4] + " " + tempparams[5]; - return this->DoAdd(u, tempparams); + return this->DoAdd(source, tempparams); } else if (cmd.equals_ci("CHANGE")) { @@ -348,7 +349,7 @@ class CommandBSBot : public Command // but only oldn and newn are required if (!u->Account()->HasCommand("botserv/bot/change")) { - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); return MOD_CONT; } @@ -358,14 +359,14 @@ class CommandBSBot : public Command return MOD_CONT; } - return this->DoChange(u, params); + return this->DoChange(source, params); } else if (cmd.equals_ci("DEL")) { // DEL nick if (!u->Account()->HasCommand("botserv/bot/del")) { - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); return MOD_CONT; } @@ -375,7 +376,7 @@ class CommandBSBot : public Command return MOD_CONT; } - return this->DoDel(u, params); + return this->DoDel(source, params); } else this->OnSyntaxError(u, ""); diff --git a/modules/core/bs_botlist.cpp b/modules/core/bs_botlist.cpp index 2fdf5ec5a..0e06db6d0 100644 --- a/modules/core/bs_botlist.cpp +++ b/modules/core/bs_botlist.cpp @@ -20,13 +20,14 @@ class CommandBSBotList : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { + User *u = source.u; unsigned count = 0; if (BotListByNick.empty()) { - u->SendMessage(BotServ, BOT_BOTLIST_EMPTY); + source.Reply(BOT_BOTLIST_EMPTY); return MOD_CONT; } @@ -37,15 +38,15 @@ class CommandBSBotList : public Command if (!bi->HasFlag(BI_PRIVATE)) { if (!count) - u->SendMessage(BotServ, BOT_BOTLIST_HEADER); + source.Reply(BOT_BOTLIST_HEADER); ++count; - u->SendMessage(Config->s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str()); + source.Reply(" %-15s (%s@%s)", bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str()); } } if (u->Account()->HasCommand("botserv/botlist") && count < BotListByNick.size()) { - u->SendMessage(BotServ, BOT_BOTLIST_PRIVATE_HEADER); + source.Reply(BOT_BOTLIST_PRIVATE_HEADER); for (patricia_tree::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { @@ -53,16 +54,16 @@ class CommandBSBotList : public Command if (bi->HasFlag(BI_PRIVATE)) { - u->SendMessage(Config->s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str()); + source.Reply(" %-15s (%s@%s)", bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str()); ++count; } } } if (!count) - u->SendMessage(BotServ, BOT_BOTLIST_EMPTY); + source.Reply(BOT_BOTLIST_EMPTY); else - u->SendMessage(BotServ, BOT_BOTLIST_FOOTER, count); + source.Reply(BOT_BOTLIST_FOOTER, count); return MOD_CONT; } diff --git a/modules/core/bs_help.cpp b/modules/core/bs_help.cpp index fec543417..12614ac55 100644 --- a/modules/core/bs_help.cpp +++ b/modules/core/bs_help.cpp @@ -22,8 +22,9 @@ class CommandBSHelp : public Command this->SetFlag(CFLAG_STRIP_CHANNEL); } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { + User *u = source.u; mod_help_cmd(findbot(Config->s_BotServ), u, params[0]); return MOD_CONT; } diff --git a/modules/core/bs_info.cpp b/modules/core/bs_info.cpp index 2cb3475d8..0a86748c3 100644 --- a/modules/core/bs_info.cpp +++ b/modules/core/bs_info.cpp @@ -17,7 +17,7 @@ class CommandBSInfo : public Command { private: - void send_bot_channels(User *u, BotInfo *bi) + void send_bot_channels(CommandSource &source, BotInfo *bi) { Anope::string buf; for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it) @@ -28,7 +28,7 @@ class CommandBSInfo : public Command { if (buf.length() + ci->name.length() > 300) { - u->SendMessage(Config->s_BotServ, "%s", buf.c_str()); + source.Reply("%s", buf.c_str()); buf.clear(); } buf += " " + ci->name + " "; @@ -36,7 +36,7 @@ class CommandBSInfo : public Command } if (!buf.empty()) - u->SendMessage(Config->s_BotServ, "%s", buf.c_str()); + source.Reply("%s", buf.c_str()); return; } public: @@ -45,159 +45,160 @@ class CommandBSInfo : public Command this->SetFlag(CFLAG_STRIP_CHANNEL); } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { - BotInfo *bi; - ChannelInfo *ci; - Anope::string query = params[0]; + const Anope::string &query = params[0]; - int need_comma = 0; + bool need_comma = false; char buf[BUFSIZE], *end; - if ((bi = findbot(query))) + User *u = source.u; + BotInfo *bi = findbot(query); + ChannelInfo *ci; + if (bi) { - u->SendMessage(BotServ, BOT_INFO_BOT_HEADER, bi->nick.c_str()); - u->SendMessage(BotServ, BOT_INFO_BOT_MASK, bi->GetIdent().c_str(), bi->host.c_str()); - u->SendMessage(BotServ, BOT_INFO_BOT_REALNAME, bi->realname.c_str()); - u->SendMessage(BotServ, BOT_INFO_BOT_CREATED, do_strftime(bi->created).c_str()); - u->SendMessage(BotServ, BOT_INFO_BOT_OPTIONS, GetString(u, (bi->HasFlag(BI_PRIVATE) ? NICK_INFO_OPT_PRIVATE : NICK_INFO_OPT_NONE)).c_str()); - u->SendMessage(BotServ, BOT_INFO_BOT_USAGE, bi->chancount); + source.Reply(BOT_INFO_BOT_HEADER, bi->nick.c_str()); + source.Reply(BOT_INFO_BOT_MASK, bi->GetIdent().c_str(), bi->host.c_str()); + source.Reply(BOT_INFO_BOT_REALNAME, bi->realname.c_str()); + source.Reply(BOT_INFO_BOT_CREATED, do_strftime(bi->created).c_str()); + source.Reply(BOT_INFO_BOT_OPTIONS, GetString(u, (bi->HasFlag(BI_PRIVATE) ? NICK_INFO_OPT_PRIVATE : NICK_INFO_OPT_NONE)).c_str()); + source.Reply(BOT_INFO_BOT_USAGE, bi->chancount); if (u->Account()->HasPriv("botserv/administration")) - this->send_bot_channels(u, bi); + this->send_bot_channels(source, bi); } else if ((ci = cs_findchan(query))) { if (!check_access(u, ci, CA_FOUNDER) && !u->Account()->HasPriv("botserv/administration")) { - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); return MOD_CONT; } - u->SendMessage(BotServ, CHAN_INFO_HEADER, ci->name.c_str()); + source.Reply(CHAN_INFO_HEADER, ci->name.c_str()); if (ci->bi) - u->SendMessage(BotServ, BOT_INFO_CHAN_BOT, ci->bi->nick.c_str()); + source.Reply(BOT_INFO_CHAN_BOT, ci->bi->nick.c_str()); else - u->SendMessage(BotServ, BOT_INFO_CHAN_BOT_NONE); + source.Reply(BOT_INFO_CHAN_BOT_NONE); if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) { if (ci->ttb[TTB_BADWORDS]) - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_BADWORDS_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_BADWORDS]); + source.Reply(BOT_INFO_CHAN_KICK_BADWORDS_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_BADWORDS]); else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_BADWORDS, GetString(u, BOT_INFO_ACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_BADWORDS, GetString(u, BOT_INFO_ACTIVE).c_str()); } else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_BADWORDS, GetString(u, BOT_INFO_INACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_BADWORDS, GetString(u, BOT_INFO_INACTIVE).c_str()); if (ci->botflags.HasFlag(BS_KICK_BOLDS)) { if (ci->ttb[TTB_BOLDS]) - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_BOLDS_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_BOLDS]); + source.Reply(BOT_INFO_CHAN_KICK_BOLDS_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_BOLDS]); else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_BOLDS, GetString(u, BOT_INFO_ACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_BOLDS, GetString(u, BOT_INFO_ACTIVE).c_str()); } else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_BOLDS, GetString(u, BOT_INFO_INACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_BOLDS, GetString(u, BOT_INFO_INACTIVE).c_str()); if (ci->botflags.HasFlag(BS_KICK_CAPS)) { if (ci->ttb[TTB_CAPS]) - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_CAPS_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_CAPS], ci->capsmin, ci->capspercent); + source.Reply(BOT_INFO_CHAN_KICK_CAPS_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_CAPS], ci->capsmin, ci->capspercent); else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_CAPS_ON, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->capsmin, ci->capspercent); + source.Reply(BOT_INFO_CHAN_KICK_CAPS_ON, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->capsmin, ci->capspercent); } else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_CAPS_OFF, GetString(u, BOT_INFO_INACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_CAPS_OFF, GetString(u, BOT_INFO_INACTIVE).c_str()); if (ci->botflags.HasFlag(BS_KICK_COLORS)) { if (ci->ttb[TTB_COLORS]) - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_COLORS_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_COLORS]); + source.Reply(BOT_INFO_CHAN_KICK_COLORS_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_COLORS]); else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_COLORS, GetString(u, BOT_INFO_ACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_COLORS, GetString(u, BOT_INFO_ACTIVE).c_str()); } else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_COLORS, GetString(u, BOT_INFO_INACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_COLORS, GetString(u, BOT_INFO_INACTIVE).c_str()); if (ci->botflags.HasFlag(BS_KICK_FLOOD)) { if (ci->ttb[TTB_FLOOD]) - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_FLOOD_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_FLOOD], ci->floodlines, ci->floodsecs); + source.Reply(BOT_INFO_CHAN_KICK_FLOOD_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_FLOOD], ci->floodlines, ci->floodsecs); else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_FLOOD_ON, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->floodlines, ci->floodsecs); + source.Reply(BOT_INFO_CHAN_KICK_FLOOD_ON, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->floodlines, ci->floodsecs); } else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_FLOOD_OFF, GetString(u, BOT_INFO_INACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_FLOOD_OFF, GetString(u, BOT_INFO_INACTIVE).c_str()); if (ci->botflags.HasFlag(BS_KICK_REPEAT)) { if (ci->ttb[TTB_REPEAT]) - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_REPEAT_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_REPEAT], ci->repeattimes); + source.Reply(BOT_INFO_CHAN_KICK_REPEAT_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_REPEAT], ci->repeattimes); else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_REPEAT_ON, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->repeattimes); + source.Reply(BOT_INFO_CHAN_KICK_REPEAT_ON, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->repeattimes); } else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_REPEAT_OFF, GetString(u, BOT_INFO_INACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_REPEAT_OFF, GetString(u, BOT_INFO_INACTIVE).c_str()); if (ci->botflags.HasFlag(BS_KICK_REVERSES)) { if (ci->ttb[TTB_REVERSES]) - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_REVERSES_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_REVERSES]); + source.Reply(BOT_INFO_CHAN_KICK_REVERSES_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_REVERSES]); else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_REVERSES, GetString(u, BOT_INFO_ACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_REVERSES, GetString(u, BOT_INFO_ACTIVE).c_str()); } else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_REVERSES, GetString(u, BOT_INFO_INACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_REVERSES, GetString(u, BOT_INFO_INACTIVE).c_str()); if (ci->botflags.HasFlag(BS_KICK_UNDERLINES)) { if (ci->ttb[TTB_UNDERLINES]) - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_UNDERLINES_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_UNDERLINES]); + source.Reply(BOT_INFO_CHAN_KICK_UNDERLINES_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_UNDERLINES]); else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_UNDERLINES, GetString(u, BOT_INFO_ACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_UNDERLINES, GetString(u, BOT_INFO_ACTIVE).c_str()); } else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_UNDERLINES, GetString(u, BOT_INFO_INACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_UNDERLINES, GetString(u, BOT_INFO_INACTIVE).c_str()); if (ci->botflags.HasFlag(BS_KICK_ITALICS)) { if (ci->ttb[TTB_ITALICS]) - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_ITALICS_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_ITALICS]); + source.Reply(BOT_INFO_CHAN_KICK_ITALICS_BAN, GetString(u, BOT_INFO_ACTIVE).c_str(), ci->ttb[TTB_ITALICS]); else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_ITALICS, GetString(u, BOT_INFO_ACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_ITALICS, GetString(u, BOT_INFO_ACTIVE).c_str()); } else - u->SendMessage(BotServ, BOT_INFO_CHAN_KICK_ITALICS, GetString(u, BOT_INFO_INACTIVE).c_str()); + source.Reply(BOT_INFO_CHAN_KICK_ITALICS, GetString(u, BOT_INFO_INACTIVE).c_str()); end = buf; *end = 0; if (ci->botflags.HasFlag(BS_DONTKICKOPS)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s", GetString(u, BOT_INFO_OPT_DONTKICKOPS).c_str()); - need_comma = 1; + need_comma = true; } if (ci->botflags.HasFlag(BS_DONTKICKVOICES)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? ", " : "", GetString(u, BOT_INFO_OPT_DONTKICKVOICES).c_str()); - need_comma = 1; + need_comma = true; } if (ci->botflags.HasFlag(BS_FANTASY)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? ", " : "", GetString(u, BOT_INFO_OPT_FANTASY).c_str()); - need_comma = 1; + need_comma = true; } if (ci->botflags.HasFlag(BS_GREET)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? ", " : "", GetString(u, BOT_INFO_OPT_GREET).c_str()); - need_comma = 1; + need_comma = true; } if (ci->botflags.HasFlag(BS_NOBOT)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? ", " : "", GetString(u, BOT_INFO_OPT_NOBOT).c_str()); - need_comma = 1; + need_comma = true; } if (ci->botflags.HasFlag(BS_SYMBIOSIS)) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? ", " : "", GetString(u, BOT_INFO_OPT_SYMBIOSIS).c_str()); - need_comma = 1; + need_comma = true; } - u->SendMessage(BotServ, BOT_INFO_CHAN_OPTIONS, *buf ? buf : GetString(u, BOT_INFO_OPT_NONE).c_str()); + source.Reply(BOT_INFO_CHAN_OPTIONS, *buf ? buf : GetString(u, BOT_INFO_OPT_NONE).c_str()); } else - u->SendMessage(BotServ, BOT_INFO_NOT_FOUND, query.c_str()); + source.Reply(BOT_INFO_NOT_FOUND, query.c_str()); return MOD_CONT; } diff --git a/modules/core/bs_kick.cpp b/modules/core/bs_kick.cpp index 380236a43..950e0b4fe 100644 --- a/modules/core/bs_kick.cpp +++ b/modules/core/bs_kick.cpp @@ -21,25 +21,26 @@ class CommandBSKick : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { - Anope::string chan = params[0]; - Anope::string option = params[1]; - Anope::string value = params[2]; - Anope::string ttb = params.size() > 3 ? params[3] : ""; + const Anope::string &chan = params[0]; + const Anope::string &option = params[1]; + const Anope::string &value = params[2]; + const Anope::string &ttb = params.size() > 3 ? params[3] : ""; - ChannelInfo *ci = cs_findchan(chan); + User *u = source.u; + ChannelInfo *ci = source.ci; if (readonly) - u->SendMessage(BotServ, BOT_KICK_DISABLED); + source.Reply(BOT_KICK_DISABLED); else if (chan.empty() || option.empty() || value.empty()) SyntaxError(BotServ, u, "KICK", BOT_KICK_SYNTAX); else if (!value.equals_ci("ON") && !value.equals_ci("OFF")) SyntaxError(BotServ, u, "KICK", BOT_KICK_SYNTAX); else if (!check_access(u, ci, CA_SET) && !u->Account()->HasPriv("botserv/administration")) - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); else if (!ci->bi) - u->SendMessage(BotServ, BOT_NOT_ASSIGNED); + source.Reply(BOT_NOT_ASSIGNED); else { bool override = !check_access(u, ci, CA_SET); @@ -60,7 +61,7 @@ class CommandBSKick : public Command Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BADWORDS]; /* reset the value back to 0 - TSL */ ci->ttb[TTB_BADWORDS] = 0; - u->SendMessage(BotServ, BOT_KICK_BAD_TTB, ttb.c_str()); + source.Reply(BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; } } @@ -68,14 +69,14 @@ class CommandBSKick : public Command ci->ttb[TTB_BADWORDS] = 0; ci->botflags.SetFlag(BS_KICK_BADWORDS); if (ci->ttb[TTB_BADWORDS]) - u->SendMessage(BotServ, BOT_KICK_BADWORDS_ON_BAN, ci->ttb[TTB_BADWORDS]); + source.Reply(BOT_KICK_BADWORDS_ON_BAN, ci->ttb[TTB_BADWORDS]); else - u->SendMessage(BotServ, BOT_KICK_BADWORDS_ON); + source.Reply(BOT_KICK_BADWORDS_ON); } else { ci->botflags.UnsetFlag(BS_KICK_BADWORDS); - u->SendMessage(BotServ, BOT_KICK_BADWORDS_OFF); + source.Reply(BOT_KICK_BADWORDS_OFF); } } else if (option.equals_ci("BOLDS")) @@ -90,7 +91,7 @@ class CommandBSKick : public Command { Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BOLDS]; ci->ttb[TTB_BOLDS] = 0; - u->SendMessage(BotServ, BOT_KICK_BAD_TTB, ttb.c_str()); + source.Reply(BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; } } @@ -98,14 +99,14 @@ class CommandBSKick : public Command ci->ttb[TTB_BOLDS] = 0; ci->botflags.SetFlag(BS_KICK_BOLDS); if (ci->ttb[TTB_BOLDS]) - u->SendMessage(BotServ, BOT_KICK_BOLDS_ON_BAN, ci->ttb[TTB_BOLDS]); + source.Reply(BOT_KICK_BOLDS_ON_BAN, ci->ttb[TTB_BOLDS]); else - u->SendMessage(BotServ, BOT_KICK_BOLDS_ON); + source.Reply(BOT_KICK_BOLDS_ON); } else { ci->botflags.UnsetFlag(BS_KICK_BOLDS); - u->SendMessage(BotServ, BOT_KICK_BOLDS_OFF); + source.Reply(BOT_KICK_BOLDS_OFF); } } else if (option.equals_ci("CAPS")) @@ -123,7 +124,7 @@ class CommandBSKick : public Command { Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_CAPS]; ci->ttb[TTB_CAPS] = 0; - u->SendMessage(BotServ, BOT_KICK_BAD_TTB, ttb.c_str()); + source.Reply(BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; } } @@ -146,14 +147,14 @@ class CommandBSKick : public Command ci->botflags.SetFlag(BS_KICK_CAPS); if (ci->ttb[TTB_CAPS]) - u->SendMessage(BotServ, BOT_KICK_CAPS_ON_BAN, ci->capsmin, ci->capspercent, ci->ttb[TTB_CAPS]); + source.Reply(BOT_KICK_CAPS_ON_BAN, ci->capsmin, ci->capspercent, ci->ttb[TTB_CAPS]); else - u->SendMessage(BotServ, BOT_KICK_CAPS_ON, ci->capsmin, ci->capspercent); + source.Reply(BOT_KICK_CAPS_ON, ci->capsmin, ci->capspercent); } else { ci->botflags.UnsetFlag(BS_KICK_CAPS); - u->SendMessage(BotServ, BOT_KICK_CAPS_OFF); + source.Reply(BOT_KICK_CAPS_OFF); } } else if (option.equals_ci("COLORS")) @@ -168,7 +169,7 @@ class CommandBSKick : public Command { Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_COLORS]; ci->ttb[TTB_COLORS] = 0; - u->SendMessage(BotServ, BOT_KICK_BAD_TTB, ttb.c_str()); + source.Reply(BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; } } @@ -176,14 +177,14 @@ class CommandBSKick : public Command ci->ttb[TTB_COLORS] = 0; ci->botflags.SetFlag(BS_KICK_COLORS); if (ci->ttb[TTB_COLORS]) - u->SendMessage(BotServ, BOT_KICK_COLORS_ON_BAN, ci->ttb[TTB_COLORS]); + source.Reply(BOT_KICK_COLORS_ON_BAN, ci->ttb[TTB_COLORS]); else - u->SendMessage(BotServ, BOT_KICK_COLORS_ON); + source.Reply(BOT_KICK_COLORS_ON); } else { ci->botflags.UnsetFlag(BS_KICK_COLORS); - u->SendMessage(BotServ, BOT_KICK_COLORS_OFF); + source.Reply(BOT_KICK_COLORS_OFF); } } else if (option.equals_ci("FLOOD")) @@ -201,7 +202,7 @@ class CommandBSKick : public Command { Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_FLOOD]; ci->ttb[TTB_FLOOD] = 0; - u->SendMessage(BotServ, BOT_KICK_BAD_TTB, ttb.c_str()); + source.Reply(BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; } } @@ -224,14 +225,14 @@ class CommandBSKick : public Command ci->botflags.SetFlag(BS_KICK_FLOOD); if (ci->ttb[TTB_FLOOD]) - u->SendMessage(BotServ, BOT_KICK_FLOOD_ON_BAN, ci->floodlines, ci->floodsecs, ci->ttb[TTB_FLOOD]); + source.Reply(BOT_KICK_FLOOD_ON_BAN, ci->floodlines, ci->floodsecs, ci->ttb[TTB_FLOOD]); else - u->SendMessage(BotServ, BOT_KICK_FLOOD_ON, ci->floodlines, ci->floodsecs); + source.Reply(BOT_KICK_FLOOD_ON, ci->floodlines, ci->floodsecs); } else { ci->botflags.UnsetFlag(BS_KICK_FLOOD); - u->SendMessage(BotServ, BOT_KICK_FLOOD_OFF); + source.Reply(BOT_KICK_FLOOD_OFF); } } else if (option.equals_ci("REPEAT")) @@ -248,7 +249,7 @@ class CommandBSKick : public Command { Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REPEAT]; ci->ttb[TTB_REPEAT] = 0; - u->SendMessage(BotServ, BOT_KICK_BAD_TTB, ttb.c_str()); + source.Reply(BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; } } @@ -264,14 +265,14 @@ class CommandBSKick : public Command ci->botflags.SetFlag(BS_KICK_REPEAT); if (ci->ttb[TTB_REPEAT]) - u->SendMessage(BotServ, BOT_KICK_REPEAT_ON_BAN, ci->repeattimes, ci->ttb[TTB_REPEAT]); + source.Reply(BOT_KICK_REPEAT_ON_BAN, ci->repeattimes, ci->ttb[TTB_REPEAT]); else - u->SendMessage(BotServ, BOT_KICK_REPEAT_ON, ci->repeattimes); + source.Reply(BOT_KICK_REPEAT_ON, ci->repeattimes); } else { ci->botflags.UnsetFlag(BS_KICK_REPEAT); - u->SendMessage(BotServ, BOT_KICK_REPEAT_OFF); + source.Reply(BOT_KICK_REPEAT_OFF); } } else if (option.equals_ci("REVERSES")) @@ -286,7 +287,7 @@ class CommandBSKick : public Command { Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REVERSES]; ci->ttb[TTB_REVERSES] = 0; - u->SendMessage(BotServ, BOT_KICK_BAD_TTB, ttb.c_str()); + source.Reply(BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; } } @@ -294,14 +295,14 @@ class CommandBSKick : public Command ci->ttb[TTB_REVERSES] = 0; ci->botflags.SetFlag(BS_KICK_REVERSES); if (ci->ttb[TTB_REVERSES]) - u->SendMessage(BotServ, BOT_KICK_REVERSES_ON_BAN, ci->ttb[TTB_REVERSES]); + source.Reply(BOT_KICK_REVERSES_ON_BAN, ci->ttb[TTB_REVERSES]); else - u->SendMessage(BotServ, BOT_KICK_REVERSES_ON); + source.Reply(BOT_KICK_REVERSES_ON); } else { ci->botflags.UnsetFlag(BS_KICK_REVERSES); - u->SendMessage(BotServ, BOT_KICK_REVERSES_OFF); + source.Reply(BOT_KICK_REVERSES_OFF); } } else if (option.equals_ci("UNDERLINES")) @@ -316,7 +317,7 @@ class CommandBSKick : public Command { Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_UNDERLINES]; ci->ttb[TTB_UNDERLINES] = 0; - u->SendMessage(BotServ, BOT_KICK_BAD_TTB, ttb.c_str()); + source.Reply(BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; } } @@ -324,14 +325,14 @@ class CommandBSKick : public Command ci->ttb[TTB_UNDERLINES] = 0; ci->botflags.SetFlag(BS_KICK_UNDERLINES); if (ci->ttb[TTB_UNDERLINES]) - u->SendMessage(BotServ, BOT_KICK_UNDERLINES_ON_BAN, ci->ttb[TTB_UNDERLINES]); + source.Reply(BOT_KICK_UNDERLINES_ON_BAN, ci->ttb[TTB_UNDERLINES]); else - u->SendMessage(BotServ, BOT_KICK_UNDERLINES_ON); + source.Reply(BOT_KICK_UNDERLINES_ON); } else { ci->botflags.UnsetFlag(BS_KICK_UNDERLINES); - u->SendMessage(BotServ, BOT_KICK_UNDERLINES_OFF); + source.Reply(BOT_KICK_UNDERLINES_OFF); } } else if (option.equals_ci("ITALICS")) @@ -346,7 +347,7 @@ class CommandBSKick : public Command { Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_ITALICS]; ci->ttb[TTB_ITALICS] = 0; - u->SendMessage(BotServ, BOT_KICK_BAD_TTB, ttb.c_str()); + source.Reply(BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; } } @@ -354,18 +355,18 @@ class CommandBSKick : public Command ci->ttb[TTB_ITALICS] = 0; ci->botflags.SetFlag(BS_KICK_ITALICS); if (ci->ttb[TTB_ITALICS]) - u->SendMessage(BotServ, BOT_KICK_ITALICS_ON_BAN, ci->ttb[TTB_ITALICS]); + source.Reply(BOT_KICK_ITALICS_ON_BAN, ci->ttb[TTB_ITALICS]); else - u->SendMessage(BotServ, BOT_KICK_ITALICS_ON); + source.Reply(BOT_KICK_ITALICS_ON); } else { ci->botflags.UnsetFlag(BS_KICK_ITALICS); - u->SendMessage(BotServ, BOT_KICK_ITALICS_OFF); + source.Reply(BOT_KICK_ITALICS_OFF); } } else - u->SendMessage(BotServ, BOT_KICK_UNKNOWN, option.c_str()); + source.Reply(BOT_KICK_UNKNOWN, option.c_str()); } return MOD_CONT; } diff --git a/modules/core/bs_say.cpp b/modules/core/bs_say.cpp index a829cf368..aedcf05e8 100644 --- a/modules/core/bs_say.cpp +++ b/modules/core/bs_say.cpp @@ -20,30 +20,28 @@ class CommandBSSay : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { - ChannelInfo *ci; + const Anope::string &text = params[1]; - Anope::string chan = params[0]; - Anope::string text = params[1]; - - ci = cs_findchan(chan); + User *u = source.u; + ChannelInfo *ci = source.ci; if (!check_access(u, ci, CA_SAY)) { - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); return MOD_CONT; } if (!ci->bi) { - u->SendMessage(BotServ, BOT_NOT_ASSIGNED); + source.Reply(BOT_NOT_ASSIGNED); return MOD_CONT; } if (!ci->c || !ci->c->FindUser(ci->bi)) { - u->SendMessage(BotServ, BOT_NOT_ON_CHANNEL, ci->name.c_str()); + source.Reply(BOT_NOT_ON_CHANNEL, ci->name.c_str()); return MOD_CONT; } diff --git a/modules/core/bs_set.cpp b/modules/core/bs_set.cpp index 7f9acc5ed..99cf6c415 100644 --- a/modules/core/bs_set.cpp +++ b/modules/core/bs_set.cpp @@ -21,47 +21,45 @@ class CommandBSSet : public Command this->SetFlag(CFLAG_STRIP_CHANNEL); } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { - Anope::string chan = params[0]; - Anope::string option = params[1]; - Anope::string value = params[2]; + const Anope::string &chan = params[0]; + const Anope::string &option = params[1]; + const Anope::string &value = params[2]; + + User *u = source.u; ChannelInfo *ci; if (readonly) - { - u->SendMessage(BotServ, BOT_SET_DISABLED); - return MOD_CONT; - } - - if (u->Account()->HasCommand("botserv/set/private") && option.equals_ci("PRIVATE")) + source.Reply(BOT_SET_DISABLED); + else if (u->Account()->HasCommand("botserv/set/private") && option.equals_ci("PRIVATE")) { BotInfo *bi; if (!(bi = findbot(chan))) { - u->SendMessage(BotServ, BOT_DOES_NOT_EXIST, chan.c_str()); + source.Reply(BOT_DOES_NOT_EXIST, chan.c_str()); return MOD_CONT; } if (value.equals_ci("ON")) { bi->SetFlag(BI_PRIVATE); - u->SendMessage(BotServ, BOT_SET_PRIVATE_ON, bi->nick.c_str()); + source.Reply(BOT_SET_PRIVATE_ON, bi->nick.c_str()); } else if (value.equals_ci("OFF")) { bi->UnsetFlag(BI_PRIVATE); - u->SendMessage(BotServ, BOT_SET_PRIVATE_OFF, bi->nick.c_str()); + source.Reply(BOT_SET_PRIVATE_OFF, bi->nick.c_str()); } else SyntaxError(BotServ, u, "SET PRIVATE", BOT_SET_PRIVATE_SYNTAX); return MOD_CONT; } else if (!(ci = cs_findchan(chan))) - u->SendMessage(BotServ, CHAN_X_NOT_REGISTERED, chan.c_str()); + source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); else if (!u->Account()->HasPriv("botserv/administration") && !check_access(u, ci, CA_SET)) - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); else { bool override = !check_access(u, ci, CA_SET); @@ -72,12 +70,12 @@ class CommandBSSet : public Command if (value.equals_ci("ON")) { ci->botflags.SetFlag(BS_DONTKICKOPS); - u->SendMessage(BotServ, BOT_SET_DONTKICKOPS_ON, ci->name.c_str()); + source.Reply(BOT_SET_DONTKICKOPS_ON, ci->name.c_str()); } else if (value.equals_ci("OFF")) { ci->botflags.UnsetFlag(BS_DONTKICKOPS); - u->SendMessage(BotServ, BOT_SET_DONTKICKOPS_OFF, ci->name.c_str()); + source.Reply(BOT_SET_DONTKICKOPS_OFF, ci->name.c_str()); } else SyntaxError(BotServ, u, "SET DONTKICKOPS", BOT_SET_DONTKICKOPS_SYNTAX); @@ -87,12 +85,12 @@ class CommandBSSet : public Command if (value.equals_ci("ON")) { ci->botflags.SetFlag(BS_DONTKICKVOICES); - u->SendMessage(BotServ, BOT_SET_DONTKICKVOICES_ON, ci->name.c_str()); + source.Reply(BOT_SET_DONTKICKVOICES_ON, ci->name.c_str()); } else if (value.equals_ci("OFF")) { ci->botflags.UnsetFlag(BS_DONTKICKVOICES); - u->SendMessage(BotServ, BOT_SET_DONTKICKVOICES_OFF, ci->name.c_str()); + source.Reply(BOT_SET_DONTKICKVOICES_OFF, ci->name.c_str()); } else SyntaxError(BotServ, u, "SET DONTKICKVOICES", BOT_SET_DONTKICKVOICES_SYNTAX); @@ -102,12 +100,12 @@ class CommandBSSet : public Command if (value.equals_ci("ON")) { ci->botflags.SetFlag(BS_FANTASY); - u->SendMessage(BotServ, BOT_SET_FANTASY_ON, ci->name.c_str()); + source.Reply(BOT_SET_FANTASY_ON, ci->name.c_str()); } else if (value.equals_ci("OFF")) { ci->botflags.UnsetFlag(BS_FANTASY); - u->SendMessage(BotServ, BOT_SET_FANTASY_OFF, ci->name.c_str()); + source.Reply(BOT_SET_FANTASY_OFF, ci->name.c_str()); } else SyntaxError(BotServ, u, "SET FANTASY", BOT_SET_FANTASY_SYNTAX); @@ -117,12 +115,12 @@ class CommandBSSet : public Command if (value.equals_ci("ON")) { ci->botflags.SetFlag(BS_GREET); - u->SendMessage(BotServ, BOT_SET_GREET_ON, ci->name.c_str()); + source.Reply(BOT_SET_GREET_ON, ci->name.c_str()); } else if (value.equals_ci("OFF")) { ci->botflags.UnsetFlag(BS_GREET); - u->SendMessage(BotServ, BOT_SET_GREET_OFF, ci->name.c_str()); + source.Reply(BOT_SET_GREET_OFF, ci->name.c_str()); } else SyntaxError(BotServ, u, "SET GREET", BOT_SET_GREET_SYNTAX); @@ -134,12 +132,12 @@ class CommandBSSet : public Command ci->botflags.SetFlag(BS_NOBOT); if (ci->bi) ci->bi->UnAssign(u, ci); - u->SendMessage(BotServ, BOT_SET_NOBOT_ON, ci->name.c_str()); + source.Reply(BOT_SET_NOBOT_ON, ci->name.c_str()); } else if (value.equals_ci("OFF")) { ci->botflags.UnsetFlag(BS_NOBOT); - u->SendMessage(BotServ, BOT_SET_NOBOT_OFF, ci->name.c_str()); + source.Reply(BOT_SET_NOBOT_OFF, ci->name.c_str()); } else SyntaxError(BotServ, u, "SET NOBOT", BOT_SET_NOBOT_SYNTAX); @@ -149,19 +147,20 @@ class CommandBSSet : public Command if (value.equals_ci("ON")) { ci->botflags.SetFlag(BS_SYMBIOSIS); - u->SendMessage(BotServ, BOT_SET_SYMBIOSIS_ON, ci->name.c_str()); + source.Reply(BOT_SET_SYMBIOSIS_ON, ci->name.c_str()); } else if (value.equals_ci("OFF")) { ci->botflags.UnsetFlag(BS_SYMBIOSIS); - u->SendMessage(BotServ, BOT_SET_SYMBIOSIS_OFF, ci->name.c_str()); + source.Reply(BOT_SET_SYMBIOSIS_OFF, ci->name.c_str()); } else SyntaxError(BotServ, u, "SET SYMBIOSIS", BOT_SET_SYMBIOSIS_SYNTAX); } else - u->SendMessage(BotServ, BOT_SET_UNKNOWN, option.c_str()); + source.Reply(BOT_SET_UNKNOWN, option.c_str()); } + return MOD_CONT; } diff --git a/modules/core/bs_unassign.cpp b/modules/core/bs_unassign.cpp index c381ec61a..b1962c51f 100644 --- a/modules/core/bs_unassign.cpp +++ b/modules/core/bs_unassign.cpp @@ -20,27 +20,28 @@ class CommandBSUnassign : public Command { } - CommandReturn Execute(User *u, const std::vector ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector ¶ms) { - Anope::string chan = params[0]; - ChannelInfo *ci = cs_findchan(chan); ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_PERM); + User *u = source.u; + ChannelInfo *ci = source.ci; + if (readonly) - u->SendMessage(BotServ, BOT_ASSIGN_READONLY); + source.Reply(BOT_ASSIGN_READONLY); else if (!u->Account()->HasPriv("botserv/administration") && !check_access(u, ci, CA_ASSIGN)) - u->SendMessage(BotServ, ACCESS_DENIED); + source.Reply(ACCESS_DENIED); else if (!ci->bi) - u->SendMessage(BotServ, BOT_NOT_ASSIGNED); + source.Reply(BOT_NOT_ASSIGNED); else if (ci->HasFlag(CI_PERSIST) && !cm) - u->SendMessage(BotServ, BOT_UNASSIGN_PERSISTANT_CHAN); + source.Reply(BOT_UNASSIGN_PERSISTANT_CHAN); else { bool override = !check_access(u, ci, CA_ASSIGN); Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << ci->bi->nick; ci->bi->UnAssign(u, ci); - u->SendMessage(BotServ, BOT_UNASSIGN_UNASSIGNED, ci->name.c_str()); + source.Reply(BOT_UNASSIGN_UNASSIGNED, ci->name.c_str()); } return MOD_CONT; } diff --git a/modules/core/cs_access.cpp b/modules/core/cs_access.cpp index 77f63ac09..2878ef