diff options
Diffstat (limited to 'modules/commands')
100 files changed, 197 insertions, 371 deletions
diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp index bbac6e689..9a0b638c7 100644 --- a/modules/commands/bs_assign.cpp +++ b/modules/commands/bs_assign.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandBSAssign : public Command diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index 31dee8f8e..22fa74714 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -215,7 +215,6 @@ class CommandBSBadwords : public Command ci->ClearBadWords(); source.Reply(_("Bad words list is now empty.")); - return; } public: diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index 16fd9f2f2..aa3cf378d 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandBSBot : public Command diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp index e682bd47d..2714c3fdc 100644 --- a/modules/commands/bs_botlist.cpp +++ b/modules/commands/bs_botlist.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandBSBotList : public Command diff --git a/modules/commands/bs_control.cpp b/modules/commands/bs_control.cpp index 32e9392d7..94186c13b 100644 --- a/modules/commands/bs_control.cpp +++ b/modules/commands/bs_control.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandBSSay : public Command diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp index 6c017dc55..8bbfd0b18 100644 --- a/modules/commands/bs_info.cpp +++ b/modules/commands/bs_info.cpp @@ -10,8 +10,6 @@ * * */ -/*************************************************************************/ - #include "module.h" class CommandBSInfo : public Command diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index 5c1bdc6a8..4b869421d 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -74,7 +74,7 @@ class CommandBSKickBase : public Command virtual bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override = 0; protected: - bool CheckArguments(CommandSource &source, const std::vector<Anope::string> ¶ms, ChannelInfo* &ci) anope_override + bool CheckArguments(CommandSource &source, const std::vector<Anope::string> ¶ms, ChannelInfo* &ci) { const Anope::string &chan = params[0]; const Anope::string &option = params[1]; diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index f8356b383..64b2386fb 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static std::map<Anope::string, int16_t, ci::less> defaultLevels; diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 51665d309..1cce6afbe 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSAKick : public Command diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index c3fffecd9..fbd9833a5 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -9,7 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ #include "module.h" diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index e4c1ac7f6..d7045123f 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSClone : public Command @@ -75,14 +73,7 @@ public: target_ci->c->CheckModes(); - target_ci->c->SetCorrectModes(u, true, true); - - /* Mark the channel as persistent */ - if (target_ci->c->HasMode("PERM")) - target_ci->ExtendMetadata("PERSIST"); - /* Persist may be in def cflags, set it here */ - else if (target_ci->HasExt("PERSIST")) - target_ci->c->SetMode(NULL, "PERM"); + target_ci->c->SetCorrectModes(u, true); } if (target_ci->c && !target_ci->c->topic.empty()) diff --git a/modules/commands/cs_drop.cpp b/modules/commands/cs_drop.cpp index 433e35799..998dd8ab0 100644 --- a/modules/commands/cs_drop.cpp +++ b/modules/commands/cs_drop.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSDrop : public Command diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp index 0579ebb2b..e40676186 100644 --- a/modules/commands/cs_enforce.cpp +++ b/modules/commands/cs_enforce.cpp @@ -33,7 +33,7 @@ class CommandCSEnforce : public Command { ChanUserContainer *uc = it->second; - ci->c->SetCorrectModes(uc->user, false, false); + ci->c->SetCorrectModes(uc->user, false); } if (!hadsecureops) diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index da764d81c..c5e31f122 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" struct EntryMsg : Serializable diff --git a/modules/commands/cs_fantasy_stats.cpp b/modules/commands/cs_fantasy_stats.cpp index b8c83e73b..a7324bf9f 100644 --- a/modules/commands/cs_fantasy_stats.cpp +++ b/modules/commands/cs_fantasy_stats.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" #include "modules/sql.h" diff --git a/modules/commands/cs_fantasy_top.cpp b/modules/commands/cs_fantasy_top.cpp index 7f82ba221..ca2e67ab9 100644 --- a/modules/commands/cs_fantasy_top.cpp +++ b/modules/commands/cs_fantasy_top.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" #include "modules/sql.h" diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index 18b72ef29..4867b9029 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -9,11 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference<ChanServService> chanserv("ChanServService", "ChanServ"); static std::map<Anope::string, char> defaultFlags; class FlagsChanAccess : public ChanAccess diff --git a/modules/commands/cs_getkey.cpp b/modules/commands/cs_getkey.cpp index ec64b45f8..d22cd2319 100644 --- a/modules/commands/cs_getkey.cpp +++ b/modules/commands/cs_getkey.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSGetKey : public Command @@ -50,7 +48,6 @@ class CommandCSGetKey : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci); source.Reply(_("Key for channel \002%s\002 is \002%s\002."), chan.c_str(), key.c_str()); - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp index 61511aaaf..3f9a014bb 100644 --- a/modules/commands/cs_info.cpp +++ b/modules/commands/cs_info.cpp @@ -9,12 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference<ChanServService> chanserv("ChanServService", "ChanServ"); - class CommandCSInfo : public Command { void CheckOptStr(Anope::string &buf, const Anope::string &opt, const char *str, const ChannelInfo *ci, const NickCore *nc) @@ -116,8 +112,6 @@ class CommandCSInfo : public Command for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); - - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override diff --git a/modules/commands/cs_invite.cpp b/modules/commands/cs_invite.cpp index 4b204bfc4..d5d42c65f 100644 --- a/modules/commands/cs_invite.cpp +++ b/modules/commands/cs_invite.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSInvite : public Command @@ -83,7 +81,6 @@ class CommandCSInvite : public Command } u2->SendMessage(ci->WhoSends(), _("You have been invited to \002%s\002."), c->name.c_str()); } - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override diff --git a/modules/commands/cs_kick.cpp b/modules/commands/cs_kick.cpp index f1a632af3..8d6749540 100644 --- a/modules/commands/cs_kick.cpp +++ b/modules/commands/cs_kick.cpp @@ -9,12 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference<ChanServService> chanserv("ChanServService", "ChanServ"); - class CommandCSKick : public Command { public: diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index 13492c007..9e2df0a62 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSList : public Command @@ -117,7 +115,6 @@ class CommandCSList : public Command source.Reply(replies[i]); source.Reply(_("End of list - %d/%d matches shown."), nchans > listmax ? listmax : nchans, nchans); - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index b3ad62859..a7987a740 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSLog : public Command diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index ef43d1061..895bd3d5b 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSMode : public Command diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp index ff2fbf69c..4d4bc9353 100644 --- a/modules/commands/cs_register.cpp +++ b/modules/commands/cs_register.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSRegister : public Command @@ -74,19 +72,11 @@ class CommandCSRegister : public Command { c->CheckModes(); if (u) - c->SetCorrectModes(u, true, true); - - /* Mark the channel as persistent */ - if (c->HasMode("PERM")) - ci->Extend("PERSIST"); - /* Persist may be in def cflags, set it here */ - else if (ci->HasExt("PERSIST")) - c->SetMode(NULL, "PERM"); + c->SetCorrectModes(u, true); } FOREACH_MOD(I_OnChanRegistered, OnChanRegistered(ci)); } - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override @@ -103,7 +93,8 @@ 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.")); + "channel-operator privileges when s/he enters the channel."), + source.service->nick.c_str(), source.service->nick.c_str()); BotInfo *bi; Anope::string cmd; if (Command::FindCommandFromService("chanserv/access", bi, cmd)) diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 610ad4475..aacd3c168 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" @@ -290,14 +288,28 @@ class CommandSeen : public Command } }; -class DataBasePurger : public Timer +class CSSeen : public Module { + Serialize::Type seeninfo_type; + CommandSeen commandseen; + CommandOSSeen commandosseen; public: - DataBasePurger(Module *o) : Timer(o, 300, Anope::CurTime, true) { } + CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this) + { + + Implementation eventlist[] = { I_OnExpireTick, + I_OnUserConnect, + I_OnUserNickChange, + I_OnUserQuit, + I_OnJoinChannel, + I_OnPartChannel, + I_OnPreUserKicked }; + ModuleManager::Attach(eventlist, this, sizeof(eventlist) / sizeof(Implementation)); + } - void Tick(time_t) anope_override + void OnExpireTick() anope_override { - size_t previous_size = database.size(), purgetime = Config->GetModule(this->GetOwner())->Get<time_t>("purgetime"); + size_t previous_size = database.size(), purgetime = Config->GetModule(this)->Get<time_t>("purgetime"); if (!purgetime) purgetime = Anope::DoTime("30d"); for (database_map::iterator it = database.begin(), it_end = database.end(); it != it_end;) @@ -314,37 +326,6 @@ class DataBasePurger : public Timer } Log(LOG_DEBUG) << "cs_seen: Purged database, checked " << previous_size << " nicks and removed " << (previous_size - database.size()) << " old entries."; } -}; - -class CSSeen : public Module -{ - Serialize::Type seeninfo_type; - CommandSeen commandseen; - CommandOSSeen commandosseen; - DataBasePurger purger; - public: - CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this), purger(this) - { - - Implementation eventlist[] = { I_OnReload, - I_OnUserConnect, - I_OnUserNickChange, - I_OnUserQuit, - I_OnJoinChannel, - I_OnPartChannel, - I_OnPreUserKicked }; - ModuleManager::Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); - } - - void OnReload(Configuration::Conf *conf) anope_override - { - time_t expiretimeout = conf->GetModule(this)->Get<time_t>("expiretimeout"); - if (!expiretimeout) - expiretimeout = Anope::DoTime("1d"); - - if (purger.GetSecs() != expiretimeout) - purger.SetSecs(expiretimeout); - } void OnUserConnect(User *u, bool &exempt) anope_override { diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 028ff0069..45373e254 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -23,7 +23,6 @@ class CommandCSSet : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { this->OnSyntaxError(source, ""); - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override @@ -515,11 +514,13 @@ class CommandCSSetPersist : public Command */ if (!ci->bi && !cm) { + BotInfo *ChanServ = Config->GetClient("ChanServ"); if (!ChanServ) { source.Reply(_("ChanServ is required to enable persist on this network.")); return; } + ChanServ->Assign(NULL, ci); if (!ci->c->FindUser(ChanServ)) { @@ -559,6 +560,8 @@ class CommandCSSetPersist : public Command /* No channel mode, no BotServ, but using ChanServ as the botserv bot * which was assigned when persist was set on */ + BotInfo *ChanServ = Config->GetClient("ChanServ"), + *BotServ = Config->GetClient("BotServ"); if (!cm && !BotServ && ci->bi) { if (!ChanServ) @@ -576,8 +579,6 @@ class CommandCSSetPersist : public Command } else this->OnSyntaxError(source, "PERSIST"); - - return; } bool OnHelp(CommandSource &source, const Anope::string &) anope_override @@ -1105,7 +1106,6 @@ class CSSet : public Module CommandCSSetAutoOp commandcssetautoop; CommandCSSetBanType commandcssetbantype; CommandCSSetChanstats commandcssetchanstats; - bool CSDefChanstats; CommandCSSetDescription commandcssetdescription; CommandCSSetFounder commandcssetfounder; CommandCSSetKeepTopic commandcssetkeeptopic; @@ -1123,13 +1123,14 @@ class CSSet : public Module public: CSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsset(this), commandcssetautoop(this), commandcssetbantype(this), commandcssetchanstats(this), - CSDefChanstats(false), commandcssetdescription(this), commandcssetfounder(this), commandcssetkeeptopic(this), + commandcssetdescription(this), commandcssetfounder(this), commandcssetkeeptopic(this), commandcssetpeace(this), commandcssetpersist(this), commandcssetprivate(this), commandcssetrestricted(this), commandcssetsecure(this), commandcssetsecurefounder(this), commandcssetsecureops(this), commandcssetsignkick(this), commandcssetsuccessor(this), commandcssetnoexpire(this) { - Implementation i[] = { I_OnCheckKick, I_OnDelChan }; + Implementation i[] = { I_OnCheckKick, I_OnDelChan, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnCheckDelete, I_OnJoinChannel, + I_OnSetCorrectModes }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } @@ -1148,6 +1149,62 @@ class CSSet : public Module { if (ci->c && ci->HasExt("PERSIST")) ci->c->RemoveMode(ci->WhoSends(), "PERM", "", false); + ci->Shrink("PERSIST"); + } + + EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, const Anope::string &mname, const Anope::string ¶m) anope_override + { + /* Channel mode +P or so was set, mark this channel as persistent */ + if (mname == "PERM" && c->ci) + { + c->ci->ExtendMetadata("PERSIST"); + } + + return EVENT_CONTINUE; + } + + EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, const Anope::string &mname, const Anope::string ¶m) anope_override + { + if (mname == "PERM") + { + if (c->ci) + c->ci->Shrink("PERSIST"); + + if (c->users.empty() && !c->syncing && c->CheckDelete()) + { + delete c; + return EVENT_STOP; + } + } + + return EVENT_CONTINUE; + } + + EventReturn OnCheckDelete(Channel *c) anope_override + { + if (c->ci && c->ci->HasExt("PERSIST")) + return EVENT_STOP; + return EVENT_CONTINUE; + } + + void OnJoinChannel(User *u, Channel *c) anope_override + { + if (c->ci && c->ci->HasExt("PERSIST") && c->creation_time > c->ci->time_registered) + { + Log(LOG_DEBUG) << "Changing TS of " << c->name << " from " << c->creation_time << " to " << c->ci->time_registered; + c->creation_time = c->ci->time_registered; + IRCD->SendChannel(c); + c->Reset(); + } + } + + void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_override + { + if (chan->ci) + { + give_modes &= !chan->ci->HasExt("NOAUTOOP"); + take_modes |= chan->ci->HasExt("SECUREOPS"); + } } }; diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index 9402f5b78..5f1359f18 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -8,8 +8,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static std::map<Anope::string, Anope::string> descriptions; diff --git a/modules/commands/cs_status.cpp b/modules/commands/cs_status.cpp index 50f7080ac..5529e6148 100644 --- a/modules/commands/cs_status.cpp +++ b/modules/commands/cs_status.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSStatus : public Command diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index e19710e60..88a369e58 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSSuspend : public Command @@ -205,7 +203,7 @@ class CSSuspend : public Module ci->Shrink("suspend:reason"); ci->Shrink("suspend:time"); - Log(LOG_NORMAL, "expire", ChanServ) << "Expiring suspend for " << ci->name; + Log(this) << "Expiring suspend for " << ci->name; } } catch (const ConvertException &) { } diff --git a/modules/commands/cs_sync.cpp b/modules/commands/cs_sync.cpp index 9e6dfb0ec..4b854bd45 100644 --- a/modules/commands/cs_sync.cpp +++ b/modules/commands/cs_sync.cpp @@ -35,7 +35,7 @@ class CommandCSSync : public Command Log(LOG_COMMAND, source, this, ci); for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) - ci->c->SetCorrectModes(it->second->user, true, false); + ci->c->SetCorrectModes(it->second->user, true); source.Reply(_("All user modes on \002%s\002 have been synced."), ci->name.c_str()); } diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp index 8b90ee93d..59d2dfeaa 100644 --- a/modules/commands/cs_unban.cpp +++ b/modules/commands/cs_unban.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSUnban : public Command diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp index 8a8f3f336..ab00d5d5d 100644 --- a/modules/commands/cs_updown.cpp +++ b/modules/commands/cs_updown.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandCSUp : public Command @@ -31,7 +29,7 @@ class CommandCSUp : public Command for (User::ChanUserList::iterator it = source.GetUser()->chans.begin(); it != source.GetUser()->chans.end(); ++it) { Channel *c = it->second->chan; - c->SetCorrectModes(source.GetUser(), true, false); + c->SetCorrectModes(source.GetUser(), true); } } else @@ -58,6 +56,11 @@ class CommandCSUp : public Command source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); return; } + else if (!u->FindChannel(c)) + { + source.Reply(NICK_X_NOT_ON_CHAN, nick.c_str(), channel.c_str()); + return; + } else if (source.GetUser() && u != source.GetUser() && c->ci->HasExt("PEACE")) { if (c->ci->AccessFor(u) > c->ci->AccessFor(source.GetUser())) @@ -67,7 +70,7 @@ class CommandCSUp : public Command } } - c->SetCorrectModes(u, true, false); + c->SetCorrectModes(u, true); } } @@ -136,6 +139,11 @@ class CommandCSDown : public Command source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); return; } + else if (!u->FindChannel(c)) + { + source.Reply(NICK_X_NOT_ON_CHAN, nick.c_str(), channel.c_str()); + return; + } else if (source.GetUser() && u != source.GetUser() && c->ci->HasExt("PEACE")) { if (c->ci->AccessFor(u) > c->ci->AccessFor(source.GetUser())) diff --git a/modules/commands/gl_global.cpp b/modules/commands/gl_global.cpp index 70dd4d324..a02c1cccd 100644 --- a/modules/commands/gl_global.cpp +++ b/modules/commands/gl_global.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandGLGlobal : public Command @@ -33,7 +31,7 @@ class CommandGLGlobal : public Command else { Log(LOG_ADMIN, source, this); - GService->SendGlobal(Global, source.GetNick(), msg); + GService->SendGlobal(NULL, source.GetNick(), msg); } } diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp index eaf45ebf4..47ce98825 100644 --- a/modules/commands/help.cpp +++ b/modules/commands/help.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHelp : public Command diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp index ad9347ce0..1fa4f7b31 100644 --- a/modules/commands/hs_del.cpp +++ b/modules/commands/hs_del.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSDel : public Command diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp index 13062fc9e..c07ce297a 100644 --- a/modules/commands/hs_group.cpp +++ b/modules/commands/hs_group.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSGroup : public Command diff --git a/modules/commands/hs_list.cpp b/modules/commands/hs_list.cpp index 6bf6d49a9..aa712008f 100644 --- a/modules/commands/hs_list.cpp +++ b/modules/commands/hs_list.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSList : public Command diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp index 13a64c9d9..433fff675 100644 --- a/modules/commands/hs_off.cpp +++ b/modules/commands/hs_off.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSOff : public Command diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp index fb3ca1396..95e685309 100644 --- a/modules/commands/hs_on.cpp +++ b/modules/commands/hs_on.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSOn : public Command diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index 99c5a4811..d12973e01 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -193,7 +193,7 @@ class CommandHSActivate : public Command FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); if (Config->GetModule(this->owner)->Get<bool>("memouser") && memoserv) - memoserv->Send(HostServ->nick, na->nick, _("[auto memo] Your requested vHost has been approved."), true); + memoserv->Send(source.service->nick, na->nick, _("[auto memo] Your requested vHost has been approved."), true); source.Reply(_("vHost for %s has been activated."), na->nick.c_str()); Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host; @@ -244,7 +244,7 @@ class CommandHSReject : public Command else message = _("[auto memo] Your requested vHost has been rejected."); - memoserv->Send(HostServ->nick, nick, message, true); + memoserv->Send(source.service->nick, nick, message, true); } source.Reply(_("vHost for %s has been rejected."), nick.c_str()); @@ -380,7 +380,7 @@ static void req_send_memos(Module *me, CommandSource &source, const Anope::strin Anope::string message = Anope::printf(_("[auto memo] vHost \002%s\002 has been requested by %s."), host.c_str(), source.GetNick().c_str()); - memoserv->Send(HostServ->nick, na->nick, message, true); + memoserv->Send(source.service->nick, na->nick, message, true); } } diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index 8e83ae8a8..834ac5fc1 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandHSSet : public Command diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp index 2ab605f40..cf1a0809f 100644 --- a/modules/commands/ms_cancel.cpp +++ b/modules/commands/ms_cancel.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandMSCancel : public Command diff --git a/modules/commands/ms_check.cpp b/modules/commands/ms_check.cpp index 9a24e9973..b912777fe 100644 --- a/modules/commands/ms_check.cpp +++ b/modules/commands/ms_check.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandMSCheck : public Command diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp index 18927f8ee..dac5ae43e 100644 --- a/modules/commands/ms_del.cpp +++ b/modules/commands/ms_del.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class MemoDelCallback : public NumberList diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index 056b20128..28dd6514d 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -9,13 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - - #include "module.h" -static ServiceReference<MemoServService> MemoServService("MemoServService", "MemoServ"); - class CommandMSIgnore : public Command { public: @@ -29,10 +24,6 @@ class CommandMSIgnore : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (!MemoServService) - return; - - Anope::string channel = params[0]; Anope::string command = (params.size() > 1 ? params[1] : ""); Anope::string param = (params.size() > 2 ? params[2] : ""); @@ -123,9 +114,6 @@ class MSIgnore : public Module MSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandmsignore(this) { - - if (!MemoServService) - throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_info.cpp b/modules/commands/ms_info.cpp index 517e6b1ac..67a504117 100644 --- a/modules/commands/ms_info.cpp +++ b/modules/commands/ms_info.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandMSInfo : public Command diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp index 8b7ebeb62..dff88667b 100644 --- a/modules/commands/ms_list.cpp +++ b/modules/commands/ms_list.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandMSList : public Command diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp index b25b4fc4b..8c1ebc9ba 100644 --- a/modules/commands/ms_read.cpp +++ b/modules/commands/ms_read.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static ServiceReference<MemoServService> MemoServService("MemoServService", "MemoServ"); diff --git a/modules/commands/ms_rsend.cpp b/modules/commands/ms_rsend.cpp index a9372c328..235fb06d0 100644 --- a/modules/commands/ms_rsend.cpp +++ b/modules/commands/ms_rsend.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" namespace diff --git a/modules/commands/ms_send.cpp b/modules/commands/ms_send.cpp index d4d63a383..87603025a 100644 --- a/modules/commands/ms_send.cpp +++ b/modules/commands/ms_send.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" namespace diff --git a/modules/commands/ms_sendall.cpp b/modules/commands/ms_sendall.cpp index b19b96036..803fbf6ba 100644 --- a/modules/commands/ms_sendall.cpp +++ b/modules/commands/ms_sendall.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" namespace diff --git a/modules/commands/ms_set.cpp b/modules/commands/ms_set.cpp index d1edaecca..9bf63b15d 100644 --- a/modules/commands/ms_set.cpp +++ b/modules/commands/ms_set.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandMSSet : public Command @@ -20,6 +18,10 @@ class CommandMSSet : public Command { const Anope::string ¶m = params[1]; NickCore *nc = source.nc; + BotInfo *MemoServ = Config->GetClient("MemoServ"); + + if (!MemoServ) + return; if (param.equals_ci("ON")) { diff --git a/modules/commands/ms_staff.cpp b/modules/commands/ms_staff.cpp index 30ec92b16..20ce265a4 100644 --- a/modules/commands/ms_staff.cpp +++ b/modules/commands/ms_staff.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" namespace diff --git a/modules/commands/ns_access.cpp b/modules/commands/ns_access.cpp index 7de20b9b7..4fa3a2074 100644 --- a/modules/commands/ns_access.cpp +++ b/modules/commands/ns_access.cpp @@ -9,12 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); - class CommandNSAccess : public Command { private: diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index ba7e53912..0de8b43ff 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" struct AJoinEntry; @@ -250,6 +248,7 @@ class NSAJoin : public Module void OnNickIdentify(User *u) anope_override { + BotInfo *NickServ = Config->GetClient("NickServ"); if (!NickServ) return; diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp index 9c673a7fc..591af44c3 100644 --- a/modules/commands/ns_alist.cpp +++ b/modules/commands/ns_alist.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandNSAList : public Command diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp index 71836481a..022d803ea 100644 --- a/modules/commands/ns_cert.cpp +++ b/modules/commands/ns_cert.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static unsigned accessmax; @@ -169,8 +167,6 @@ class CommandNSCert : public Command return this->DoList(source, nc); else this->OnSyntaxError(source, cmd); - - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override @@ -180,8 +176,8 @@ class CommandNSCert : public Command source.Reply(_("Modifies or displays the certificate list for your nick.\n" "If you connect to IRC and provide a client certificate with a\n" "matching fingerprint in the cert list, your nick will be\n" - "automatically identified to %s.\n" - " \n"), NickServ ? NickServ->nick.c_str() : source.service->nick.c_str()); + "automatically identified to services.\n" + " \n")); source.Reply(_("Examples:\n" " \n" " \002CERT ADD <fingerprint>\002\n" @@ -205,6 +201,7 @@ class NSCert : public Module void DoAutoIdentify(User *u) { NickAlias *na = NickAlias::Find(u->nick); + BotInfo *NickServ = Config->GetClient("NickServ"); if (!NickServ || !na) return; if (u->IsIdentified() && u->Account() == na->nc) diff --git a/modules/commands/ns_drop.cpp b/modules/commands/ns_drop.cpp index 023d696f6..a21cac709 100644 --- a/modules/commands/ns_drop.cpp +++ b/modules/commands/ns_drop.cpp @@ -9,12 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); - class CommandNSDrop : public Command { public: diff --git a/modules/commands/ns_getemail.cpp b/modules/commands/ns_getemail.cpp index 386940a0a..8139139e1 100644 --- a/modules/commands/ns_getemail.cpp +++ b/modules/commands/ns_getemail.cpp @@ -13,8 +13,6 @@ * Cards are not excepted. Must use user@email-host. */ -/*************************************************************************/ - #include "module.h" class CommandNSGetEMail : public Command diff --git a/modules/commands/ns_getpass.cpp b/modules/commands/ns_getpass.cpp index a99181b3f..cb320ad76 100644 --- a/modules/commands/ns_getpass.cpp +++ b/modules/commands/ns_getpass.cpp @@ -9,12 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); - class CommandNSGetPass : public Command { public: diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp index a744b9afc..9b202b31c 100644 --- a/modules/commands/ns_group.cpp +++ b/modules/commands/ns_group.cpp @@ -9,12 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); - class NSGroupRequest : public IdentifyRequest { CommandSource source; @@ -48,8 +44,6 @@ class NSGroupRequest : public IdentifyRequest u->Login(target->nc); IRCD->SendLogin(u); - if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && na->nc == u->Account() && na->nc->HasExt("UNCONFIRMED") == false) - u->SetMode(NickServ, "REGISTERED"); FOREACH_MOD(I_OnNickGroup, OnNickGroup(u, target)); Log(LOG_COMMAND, source, cmd) << "makes " << nick << " join group of " << target->nick << " (" << target->nc->display << ") (email: " << (!target->nc->email.empty() ? target->nc->email : "none") << ")"; @@ -251,10 +245,8 @@ class CommandNSUngroup : public Command User *user = User::Find(na->nick); if (user) /* The user on the nick who was ungrouped may be identified to the old group, set -r */ - user->RemoveMode(NickServ, "REGISTERED"); + user->RemoveMode(source.service, "REGISTERED"); } - - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp index 037072728..aec43c1be 100644 --- a/modules/commands/ns_identify.cpp +++ b/modules/commands/ns_identify.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class NSIdentifyRequest : public IdentifyRequest @@ -39,7 +37,6 @@ class NSIdentifyRequest : public IdentifyRequest Log(LOG_COMMAND, source, cmd) << "and identified for account " << na->nc->display; source.Reply(_("Password accepted - you are now recognized.")); u->Identify(na); - na->Release(); } } diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp index 3e946a1f1..f1de95275 100644 --- a/modules/commands/ns_info.cpp +++ b/modules/commands/ns_info.cpp @@ -9,12 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" -static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); - class CommandNSInfo : public Command { private: diff --git a/modules/commands/ns_list.cpp b/modules/commands/ns_list.cpp index 69648c2f4..a4e73e857 100644 --- a/modules/commands/ns_list.cpp +++ b/modules/commands/ns_list.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandNSList : public Command diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp index c149dc1f2..d5765b0f6 100644 --- a/modules/commands/ns_logout.cpp +++ b/modules/commands/ns_logout.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static ServiceReference<NickServService> NickServService("NickServService", "NickServ"); @@ -52,7 +50,7 @@ class CommandNSLogout : public Command source.Reply(_("Your nick has been logged out.")); IRCD->SendLogout(u2); - u2->RemoveMode(NickServ, "REGISTERED"); + u2->RemoveMode(source.service, "REGISTERED"); u2->Logout(); /* Send out an event */ diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp index e9455f88a..33bc9d19e 100644 --- a/modules/commands/ns_recover.cpp +++ b/modules/commands/ns_recover.cpp @@ -9,10 +9,10 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" +static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); + struct NSRecoverExtensibleInfo : ExtensibleItem, std::map<Anope::string, ChannelStatus> { }; class NSRecoverRequest : public IdentifyRequest @@ -39,7 +39,7 @@ class NSRecoverRequest : public IdentifyRequest /* Nick is being held by us, release it */ if (na->HasExt("HELD")) { - na->Release(); + nickserv->Release(na); source.Reply(_("Service's hold on \002%s\002 has been released."), na->nick.c_str()); } else if (!u) @@ -68,7 +68,7 @@ class NSRecoverRequest : public IdentifyRequest } } - u->SendMessage(NickServ, _("This nickname has been recovered by %s. If you did not do\n" + u->SendMessage(source.service, _("This nickname has been recovered by %s. If you did not do\n" "this then %s may have your password, and you should change it.\n"), source.GetNick().c_str(), source.GetNick().c_str()); @@ -89,13 +89,14 @@ class NSRecoverRequest : public IdentifyRequest Log(LOG_COMMAND, source, cmd) << "and was automatically identified to " << na->nick << " (" << na->nc->display << ")"; } - u->SendMessage(NickServ, _("This nickname has been recovered by %s."), source.GetNick().c_str()); - u->Collide(na); + u->SendMessage(source.service, _("This nickname has been recovered by %s."), source.GetNick().c_str()); + if (nickserv) + nickserv->Collide(u, na); if (IRCD->CanSVSNick) { /* If we can svsnick then release our hold and svsnick the user using the command */ - na->Release(); + nickserv->Release(na); IRCD->SendForceNickChange(source.GetUser(), GetAccount(), Anope::CurTime); } else @@ -226,7 +227,7 @@ class NSRecover : public Module * because some IRCds do not allow us to have these automatically expire */ for (nickalias_map::const_iterator it = NickAliasList->begin(); it != NickAliasList->end(); ++it) - it->second->Release(); + nickserv->Release(it->second); } void OnRestart() anope_override { OnShutdown(); } @@ -236,8 +237,9 @@ class NSRecover : public Module if (Config->GetModule(this)->Get<bool>("restoreonrecover")) { NSRecoverExtensibleInfo *ei = u->GetExt<NSRecoverExtensibleInfo *>("ns_recover_info"); + BotInfo *NickServ = Config->GetClient("NickServ"); - if (ei != NULL) + if (ei != NULL && NickServ != NULL) for (std::map<Anope::string, ChannelStatus>::iterator it = ei->begin(), it_end = ei->end(); it != it_end;) { Channel *c = Channel::Find(it->first); diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index 2d2f59877..ac1c55696 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static bool SendRegmail(User *u, const NickAlias *na, const BotInfo *bi); @@ -59,7 +57,7 @@ class CommandNSConfirm : public Command IRCD->SendLogin(source.GetUser()); const NickAlias *na = NickAlias::Find(source.GetNick()); if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && na != NULL && na->nc == source.GetAccount() && na->nc->HasExt("UNCONFIRMED") == false) - source.GetUser()->SetMode(NickServ, "REGISTERED"); + source.GetUser()->SetMode(source.service, "REGISTERED"); } } else @@ -192,8 +190,6 @@ class CommandNSRegister : public Command { na->last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost(); na->last_realname = u->realname; - - u->Login(nc); } Log(LOG_COMMAND, source, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; @@ -227,18 +223,14 @@ class CommandNSRegister : public Command source.Reply(_("If you do not confirm your email address within %s your account will expire."), Anope::Duration(unconfirmed_expire).c_str()); } } - else if (nsregister.equals_ci("none")) - { - if (u) - { - IRCD->SendLogin(u); - if (!Config->GetBlock("options")->Get<bool>("nonicknameownership") && na->nc == u->Account() && na->nc->HasExt("UNCONFIRMED") == false) - u->SetMode(NickServ, "REGISTERED"); - } - } if (u) + { + u->Login(nc); + if (!nc->HasExt("UNCONFIRMED")) + IRCD->SendLogin(u); u->lastnickreg = Anope::CurTime; + } } } diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp index bf1e8dacf..44d941662 100644 --- a/modules/commands/ns_resetpass.cpp +++ b/modules/commands/ns_resetpass.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static bool SendResetEmail(User *u, const NickAlias *na, const BotInfo *bi); diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index 3dac72f71..fd32fb2be 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -11,8 +11,6 @@ #include "module.h" -static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); - class CommandNSSet : public Command { public: @@ -1350,7 +1348,6 @@ class NSSet : public Module CommandNSSetChanstats commandnssetchanstats; CommandNSSASetChanstats commandnssasetchanstats; - bool NSDefChanstats; CommandNSSetDisplay commandnssetdisplay; CommandNSSASetDisplay commandnssasetdisplay; @@ -1388,7 +1385,7 @@ class NSSet : public Module NSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandnsset(this), commandnssaset(this), commandnssetautoop(this), commandnssasetautoop(this), - commandnssetchanstats(this), commandnssasetchanstats(this), NSDefChanstats(false), + commandnssetchanstats(this), commandnssasetchanstats(this), commandnssetdisplay(this), commandnssasetdisplay(this), commandnssetemail(this), commandnssasetemail(this), commandnssetgreet(this), commandnssasetgreet(this), @@ -1402,7 +1399,7 @@ class NSSet : public Module commandnssasetnoexpire(this) { - Implementation i[] = { I_OnPreCommand }; + Implementation i[] = { I_OnPreCommand, I_OnSetCorrectModes }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } @@ -1429,6 +1426,15 @@ class NSSet : public Module return EVENT_CONTINUE; } + + void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) anope_override + { + if (chan->ci) + { + /* Only give modes if autoop is set */ + give_modes &= !user->Account() || user->Account()->HasExt("AUTOOP"); + } + } }; MODULE_INIT(NSSet) diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index ae7c2cb53..753450414 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static std::map<Anope::string, Anope::string> descriptions; diff --git a/modules/commands/ns_status.cpp b/modules/commands/ns_status.cpp index 68568de0a..3bfeab888 100644 --- a/modules/commands/ns_status.cpp +++ b/modules/commands/ns_status.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandNSStatus : public Command diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index 5ca9ca81d..eadb35d7d 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); @@ -87,7 +85,8 @@ class CommandNSSuspend : public Command if (u2) { u2->Logout(); - u2->Collide(na2); + if (nickserv) + nickserv->Collide(u2, na2); } } } @@ -96,8 +95,6 @@ class CommandNSSuspend : public Command source.Reply(_("Nick %s is now suspended."), nick.c_str()); FOREACH_MOD(I_OnNickSuspended, OnNickSuspend(na)); - - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override @@ -218,7 +215,7 @@ class NSSuspend : public Module na->nc->Shrink("suspend:reason"); na->nc->Shrink("suspend:time"); - Log(LOG_NORMAL, "expire", NickServ) << "Expiring suspend for " << na->nick; + Log(LOG_NORMAL, "expire", Config->GetClient("NickServ")) << "Expiring suspend for " << na->nick; } } catch (const ConvertException &) { } diff --git a/modules/commands/ns_update.cpp b/modules/commands/ns_update.cpp index ee8a2c8cb..b56f8eded 100644 --- a/modules/commands/ns_update.cpp +++ b/modules/commands/ns_update.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandNSUpdate : public Command diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp index b7433d0eb..34e6dbd2b 100644 --- a/modules/commands/os_akill.cpp +++ b/modules/commands/os_akill.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sgline"); diff --git a/modules/commands/os_chankill.cpp b/modules/commands/os_chankill.cpp index 713b5922f..1304dd75c 100644 --- a/modules/commands/os_chankill.cpp +++ b/modules/commands/os_chankill.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sgline"); diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp index 391d36157..a9ff515fb 100644 --- a/modules/commands/os_config.cpp +++ b/modules/commands/os_config.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSConfig : public Command diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index 236cf2e2f..ba695649d 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" #include "modules/os_session.h" @@ -128,17 +126,17 @@ class DefConTimeout : public Timer { DConfig.defaultlevel = level; FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(level)); - Log(OperServ, "operserv/defcon") << "Defcon level timeout, returning to level " << level; + Log(Config->GetClient("OperServ"), "operserv/defcon") << "Defcon level timeout, returning to level " << level; if (DConfig.globalondefcon) { if (!DConfig.offmessage.empty()) - GlobalService->SendGlobal(Global, "", DConfig.offmessage); + GlobalService->SendGlobal(NULL, "", DConfig.offmessage); else - GlobalService->SendGlobal(Global, "", Anope::printf(Language::Translate(_("The Defcon Level is now at Level: \002%d\002")), DConfig.defaultlevel)); + GlobalService->SendGlobal(NULL, "", Anope::printf(Language::Translate(_("The Defcon Level is now at Level: \002%d\002")), DConfig.defaultlevel)); if (!DConfig.message.empty()) - GlobalService->SendGlobal(Global, "", DConfig.message); + GlobalService->SendGlobal(NULL, "", DConfig.message); } runDefCon(); @@ -221,12 +219,12 @@ class CommandOSDefcon : public Command if (DConfig.globalondefcon) { if (DConfig.defaultlevel == 5 && !DConfig.offmessage.empty()) - GlobalService->SendGlobal(Global, "", DConfig.offmessage); + GlobalService->SendGlobal(NULL, "", DConfig.offmessage); else if (DConfig.defaultlevel != 5) { - GlobalService->SendGlobal(Global, "", Anope::printf(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel)); + GlobalService->SendGlobal(NULL, "", Anope::printf(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel)); if (!DConfig.message.empty()) - GlobalService->SendGlobal(Global, "", DConfig.message); + GlobalService->SendGlobal(NULL, "", DConfig.message); } } @@ -417,7 +415,7 @@ class OSDefcon : public Module if (DConfig.Check(DEFCON_FORCE_CHAN_MODES) && cm && DConfig.DefConModesOff.count(mname)) { - c->RemoveMode(OperServ, cm, param); + c->RemoveMode(Config->GetClient("OperServ"), cm, param); return EVENT_STOP; } @@ -434,9 +432,9 @@ class OSDefcon : public Module Anope::string param; if (DConfig.GetDefConParam(mname, param)) - c->SetMode(OperServ, cm, param); + c->SetMode(Config->GetClient("OperServ"), cm, param); else - c->SetMode(OperServ, cm); + c->SetMode(Config->GetClient("OperServ"), cm); return EVENT_STOP; @@ -488,6 +486,7 @@ class OSDefcon : public Module if (exempt || u->Quitting() || !u->server->IsSynced() || u->server->IsULined()) return; + BotInfo *OperServ = Config->GetClient("OperServ"); if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills) { Log(OperServ, "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; @@ -548,12 +547,13 @@ class OSDefcon : public Module void OnChannelSync(Channel *c) anope_override { if (DConfig.Check(DEFCON_FORCE_CHAN_MODES)) - c->SetModes(OperServ, false, "%s", DConfig.chanmodes.c_str()); + c->SetModes(Config->GetClient("OperServ"), false, "%s", DConfig.chanmodes.c_str()); } }; static void runDefCon() { + BotInfo *OperServ = Config->GetClient("OperServ"); if (DConfig.Check(DEFCON_FORCE_CHAN_MODES)) { if (!DConfig.chanmodes.empty() && !DefConModesSet) diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index c7c147c7e..a56d08219 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -9,11 +9,11 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" #include "modules/os_forbid.h" +static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); + class MyForbidService : public ForbidService { Serialize::Checker<std::vector<ForbidData *>[FT_SIZE - 1]> forbid_data; @@ -271,6 +271,7 @@ class OSForbid : public Module ForbidData *d = this->forbidService.FindForbid(u->nick, FT_NICK); if (d != NULL) { + BotInfo *OperServ = Config->GetClient("OperServ"); if (OperServ) { if (d->reason.empty()) @@ -278,12 +279,14 @@ class OSForbid : public Module else u->SendMessage(OperServ, _("This nickname has been forbidden: %s"), d->reason.c_str()); } - u->Collide(NULL); + if (nickserv) + nickserv->Collide(u, NULL); } } void OnJoinChannel(User *u, Channel *c) anope_override { + BotInfo *OperServ = Config->GetClient("OperServ"); if (u->HasMode("OPER") || !OperServ) return; diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp index b7dda73a3..56c784856 100644 --- a/modules/commands/os_ignore.cpp +++ b/modules/commands/os_ignore.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" #include "modules/os_ignore.h" diff --git a/modules/commands/os_jupe.cpp b/modules/commands/os_jupe.cpp index 4f40a5495..fbade0e82 100644 --- a/modules/commands/os_jupe.cpp +++ b/modules/commands/os_jupe.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSJupe : public Command diff --git a/modules/commands/os_kick.cpp b/modules/commands/os_kick.cpp index d9ac75c9a..ea382a453 100644 --- a/modules/commands/os_kick.cpp +++ b/modules/commands/os_kick.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSKick : public Command diff --git a/modules/commands/os_kill.cpp b/modules/commands/os_kill.cpp index 99a65ae4b..972092ef9 100644 --- a/modules/commands/os_kill.cpp +++ b/modules/commands/os_kill.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSKill : public Command diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp index dc1fd15ed..f0005e1da 100644 --- a/modules/commands/os_list.cpp +++ b/modules/commands/os_list.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSChanList : public Command diff --git a/modules/commands/os_login.cpp b/modules/commands/os_login.cpp index 30172a0f3..573379236 100644 --- a/modules/commands/os_login.cpp +++ b/modules/commands/os_login.cpp @@ -10,8 +10,6 @@ * * */ -/*************************************************************************/ - #include "module.h" class CommandOSLogin : public Command diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp index 8af247da5..7057ead72 100644 --- a/modules/commands/os_mode.cpp +++ b/modules/commands/os_mode.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSMode : public Command diff --git a/modules/commands/os_modinfo.cpp b/modules/commands/os_modinfo.cpp index b6f793796..1ad03c7c0 100644 --- a/modules/commands/os_modinfo.cpp +++ b/modules/commands/os_modinfo.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSModInfo : public Command diff --git a/modules/commands/os_module.cpp b/modules/commands/os_module.cpp index 0de03971e..8ff7498a7 100644 --- a/modules/commands/os_module.cpp +++ b/modules/commands/os_module.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSModLoad : public Command diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index e9f70b693..1d55df843 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" #include "modules/os_news.h" @@ -342,6 +340,14 @@ class OSNews : public Module if (newsList.empty()) return; + BotInfo *bi = NULL; + if (Type == NEWS_OPER) + bi = BotInfo::Find(Config->GetModule(this)->Get<const Anope::string>("oper_announcer", "OperServ"), true); + else + bi = BotInfo::Find(Config->GetModule(this)->Get<const Anope::string>("announcer", "Global"), true); + if (bi == NULL) + return; + Anope::string msg; if (Type == NEWS_LOGON) msg = _("[\002Logon News\002 - %s] %s"); @@ -357,14 +363,7 @@ class OSNews : public Module if (Type == NEWS_RANDOM && i != cur_rand_news) continue; - const BotInfo *gl = Global; - if (!gl && !BotListByNick->empty()) - gl = BotListByNick->begin()->second; - const BotInfo *os = OperServ; - if (!os) - os = gl; - if (gl) - u->SendMessage(Type != NEWS_OPER ? gl : os, msg.c_str(), Anope::strftime(newsList[i]->time).c_str(), newsList[i]->text.c_str()); + u->SendMessage(bi, msg.c_str(), Anope::strftime(newsList[i]->time).c_str(), newsList[i]->text.c_str()); ++displayed; diff --git a/modules/commands/os_noop.cpp b/modules/commands/os_noop.cpp index 204b0e6e8..239b09a32 100644 --- a/modules/commands/os_noop.cpp +++ b/modules/commands/os_noop.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSNOOP : public Command @@ -95,6 +93,7 @@ class OSNOOP : public Module if (setter) { Anope::string reason = "NOOP command used by " + *setter; + BotInfo *OperServ = Config->GetClient("OperServ"); u->Kill(OperServ ? OperServ->nick : "", reason); } } diff --git a/modules/commands/os_oline.cpp b/modules/commands/os_oline.cpp index e8f7cee9d..a2da17406 100644 --- a/modules/commands/os_oline.cpp +++ b/modules/commands/os_oline.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSOLine : public Command diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp index c3327dd4b..66a76334a 100644 --- a/modules/commands/os_oper.cpp +++ b/modules/commands/os_oper.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" struct MyOper : Oper, Serializable diff --git a/modules/commands/os_reload.cpp b/modules/commands/os_reload.cpp index ed04fbea3..d3521eef1 100644 --- a/modules/commands/os_reload.cpp +++ b/modules/commands/os_reload.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSReload : public Command diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 656e046af..af6a547f5 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" #include "modules/os_session.h" @@ -90,7 +88,7 @@ class MySessionService : public SessionService return this->Exceptions; } - void DelSession(Session *s) anope_override + void DelSession(Session *s) { this->Sessions.erase(s->addr); } @@ -125,28 +123,6 @@ class MySessionService : public SessionService } }; -class ExpireTimer : public Timer -{ - public: - ExpireTimer() : Timer(Config->GetBlock("options")->Get<time_t>("expiretimeout"), Anope::CurTime, true) { } - - void Tick(time_t) anope_override - { - if (!session_service || Anope::NoExpire) - return; - for (unsigned i = session_service->GetExceptions().size(); i > 0; --i) - { - Exception *e = session_service->GetExceptions()[i - 1]; - - if (!e->expires || e->expires > Anope::CurTime) - continue; - Log(OperServ, "expire/exception") << "Session exception for " << e->mask << "has expired."; - session_service->DelException(e); - delete e; - } - } -}; - class ExceptionDelCallback : public NumberList { protected: @@ -633,7 +609,6 @@ class OSSession : public Module { Serialize::Type exception_type; MySessionService ss; - ExpireTimer expiretimer; CommandOSSession commandossession; CommandOSException commandosexception; ServiceReference<XLineManager> akills; @@ -644,7 +619,7 @@ class OSSession : public Module { this->SetPermanent(true); - Implementation i[] = { I_OnReload, I_OnUserConnect, I_OnUserQuit }; + Implementation i[] = { I_OnReload, I_OnUserConnect, I_OnUserQuit, I_OnExpireTick }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); ModuleManager::SetPriority(this, PRIORITY_FIRST); } @@ -706,6 +681,7 @@ class OSSession : public Module if (kill && !exempt) { + BotInfo *OperServ = Config->GetClient("OperServ"); if (OperServ) { if (!sle_reason.empty()) @@ -760,6 +736,23 @@ class OSSession : public Module delete session; sessions.erase(sit); } + + void OnExpireTick() anope_override + { + if (!Anope::NoExpire) + return; + for (unsigned i = this->ss.GetExceptions().size(); i > 0; --i) + { + Exception *e = this->ss.GetExceptions()[i - 1]; + + if (!e->expires || e->expires > Anope::CurTime) + continue; + BotInfo *OperServ = Config->GetClient("OperServ"); + Log(OperServ, "expire/exception") << "Session exception for " << e->mask << "has expired."; + this->ss.DelException(e); + delete e; + } + } }; MODULE_INIT(OSSession) diff --git a/modules/commands/os_set.cpp b/modules/commands/os_set.cpp index 6fc05ab60..f30d3723e 100644 --- a/modules/commands/os_set.cpp +++ b/modules/commands/os_set.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSSet : public Command diff --git a/modules/commands/os_shutdown.cpp b/modules/commands/os_shutdown.cpp index 833c78491..f4fceada7 100644 --- a/modules/commands/os_shutdown.cpp +++ b/modules/commands/os_shutdown.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSQuit : public Command diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index 8b975a6c7..1ce27f501 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" #include "modules/os_session.h" diff --git a/modules/commands/os_svs.cpp b/modules/commands/os_svs.cpp index 9fb1d63c3..4e9a31e6b 100644 --- a/modules/commands/os_svs.cpp +++ b/modules/commands/os_svs.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSSVSNick : public Command @@ -101,7 +99,7 @@ class CommandOSSVSJoin : public Command source.Reply(_("\002%s\002 is already in \002%s\002."), target->nick.c_str(), c->name.c_str()); else { - IRCD->SendSVSJoin(OperServ, target, params[1], ""); + IRCD->SendSVSJoin(source.service, target, params[1], ""); Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to join " << params[1]; source.Reply(_("\002%s\002 has been joined to \002%s\002."), target->nick.c_str(), params[1].c_str()); } @@ -145,7 +143,7 @@ class CommandOSSVSPart : public Command source.Reply(_("\002%s\002 is not in \002%s\002."), target->nick.c_str(), c->name.c_str()); else { - IRCD->SendSVSPart(OperServ, target, params[1], ""); + IRCD->SendSVSPart(source.service, target, params[1], ""); Log(LOG_ADMIN, source, this) << "to force " << target->nick << " to part " << c->name; source.Reply(_("\002%s\002 has been parted from \002%s\002."), target->nick.c_str(), c->name.c_str()); } diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp index dcf7863fe..d12237c93 100644 --- a/modules/commands/os_sxline.cpp +++ b/modules/commands/os_sxline.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class SXLineDelCallback : public NumberList diff --git a/modules/commands/os_update.cpp b/modules/commands/os_update.cpp index bce2feeed..3e411cbc8 100644 --- a/modules/commands/os_update.cpp +++ b/modules/commands/os_update.cpp @@ -9,8 +9,6 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" class CommandOSUpdate : public Command |
