diff options
Diffstat (limited to 'modules/botserv')
-rw-r--r-- | modules/botserv/assign.cpp | 22 | ||||
-rw-r--r-- | modules/botserv/control.cpp | 6 | ||||
-rw-r--r-- | modules/botserv/kick.cpp | 15 | ||||
-rw-r--r-- | modules/botserv/main/botserv.cpp | 31 |
4 files changed, 42 insertions, 32 deletions
diff --git a/modules/botserv/assign.cpp b/modules/botserv/assign.cpp index 26a448216..469f1f051 100644 --- a/modules/botserv/assign.cpp +++ b/modules/botserv/assign.cpp @@ -248,20 +248,22 @@ class BSAssign : public Module void OnInvite(User *source, Channel *c, User *targ) override { - ServiceBot *bi; - if (Anope::ReadOnly || !c->ci || targ->server != Me || !(bi = ServiceBot::Find(targ->nick, true))) + ServiceBot *bi = ServiceBot::Find(targ->nick, true); + ChanServ::Channel *ci = c->GetChannel(); + + if (Anope::ReadOnly || !ci || targ->server != Me || !bi) return; - ChanServ::AccessGroup access = c->ci->AccessFor(source); + ChanServ::AccessGroup access = ci->AccessFor(source); if (!access.HasPriv("ASSIGN") && !source->HasPriv("botserv/administration")) { - targ->SendMessage(bi, _("Access denied. You do not have privilege \002ASSIGN\002 on \002{0}\002."), c->ci->GetName()); + targ->SendMessage(bi, _("Access denied. You do not have privilege \002ASSIGN\002 on \002{0}\002."), ci->GetName()); return; } - if (nobot.HasExt(c->ci)) + if (nobot.HasExt(ci)) { - targ->SendMessage(bi, _("Access denied. \002{0}\002 may not have a bot assigned to it because a Services Operator has disallowed it."), c->ci->GetName()); + targ->SendMessage(bi, _("Access denied. \002{0}\002 may not have a bot assigned to it because a Services Operator has disallowed it."), ci->GetName()); return; } @@ -271,14 +273,14 @@ class BSAssign : public Module return; } - if (c->ci->GetBot() == bi) + if (ci->GetBot() == bi) { - targ->SendMessage(bi, _("Bot \002{0}\002 is already assigned to \002{1}\002."), bi->nick, c->ci->GetName()); + targ->SendMessage(bi, _("Bot \002{0}\002 is already assigned to \002{1}\002."), bi->nick, ci->GetName()); return; } - bi->Assign(source, c->ci); - targ->SendMessage(bi, _("Bot \002{0}\002 has been assigned to \002{1}\002."), bi->nick, c->ci->GetName()); + bi->Assign(source, ci); + targ->SendMessage(bi, _("Bot \002{0}\002 has been assigned to \002{1}\002."), bi->nick, ci->GetName()); } void OnServiceBot(CommandSource &source, ServiceBot *bi, ChanServ::Channel *ci, InfoFormatter &info) override diff --git a/modules/botserv/control.cpp b/modules/botserv/control.cpp index 584e8eded..758f795f2 100644 --- a/modules/botserv/control.cpp +++ b/modules/botserv/control.cpp @@ -59,7 +59,8 @@ class CommandBSSay : public Command return; } - if (!ci->c || !ci->c->FindUser(ci->GetBot())) + Channel *c = ci->GetChannel(); + if (!c || !c->FindUser(ci->GetBot())) { source.Reply(_("Bot \002{0}\002 is not on channel \002{1}\002."), ci->GetBot()->nick, ci->GetName()); return; @@ -130,7 +131,8 @@ class CommandBSAct : public Command return; } - if (!ci->c || !ci->c->FindUser(ci->GetBot())) + Channel *c = ci->GetChannel(); + if (!c || !c->FindUser(ci->GetBot())) { source.Reply(_("Bot \002{0}\002 is not on channel \002{1}\002."), ci->GetBot()->nick, ci->GetName()); return; diff --git a/modules/botserv/kick.cpp b/modules/botserv/kick.cpp index b90a6e48e..2fbaf4c1b 100644 --- a/modules/botserv/kick.cpp +++ b/modules/botserv/kick.cpp @@ -1323,7 +1323,8 @@ class BSKick : public Module if (u->IsProtected()) return; - BanData::Data &bd = this->GetBanData(u, ci->c); + Channel *c = ci->GetChannel(); + BanData::Data &bd = this->GetBanData(u, c); ++bd.ttb[ttbtype]; if (ttb && bd.ttb[ttbtype] >= ttb) @@ -1332,15 +1333,15 @@ class BSKick : public Module Anope::string mask = ci->GetIdealBan(u); - ci->c->SetMode(NULL, "BAN", mask); + c->SetMode(NULL, "BAN", mask); EventManager::Get()->Dispatch(&Event::BotBan::OnBotBan, u, ci, mask); } - if (!ci->c->FindUser(u)) + if (!c->FindUser(u)) return; Anope::string buf = Anope::Format(message, std::forward<Args>(args)...); - ci->c->Kick(ci->GetBot(), u, buf); + c->Kick(ci->GetBot(), u, buf); } public: @@ -1518,10 +1519,10 @@ class BSKick : public Module * But FIRST we check whether the user is protected in any * way. */ - ChanServ::Channel *ci = c->ci; + ChanServ::Channel *ci = c->GetChannel(); if (ci == NULL) return; - KickerData *kd = c->ci->GetRef<KickerData *>(); + KickerData *kd = ci->GetRef<KickerData *>(); if (kd == NULL) return; @@ -1734,7 +1735,7 @@ class BSKick : public Module Channel *chan = it->second->chan; ++it; - if (chan->ci && kd->GetAmsgs() && !chan->ci->AccessFor(u).HasPriv("NOKICK")) + if (chan->GetChannel() && kd->GetAmsgs() && !chan->GetChannel()->AccessFor(u).HasPriv("NOKICK")) { TakeAction(ci, u, kd->GetTTBAmsgs(), TTB_AMSGS, _("Don't use AMSGs!")); return; diff --git a/modules/botserv/main/botserv.cpp b/modules/botserv/main/botserv.cpp index 8fb71f498..59a3e0ee1 100644 --- a/modules/botserv/main/botserv.cpp +++ b/modules/botserv/main/botserv.cpp @@ -52,21 +52,22 @@ class BotServCore : public Module, public BotServ::BotServService void OnSetCorrectModes(User *user, Channel *chan, ChanServ::AccessGroup &access, bool &give_modes, bool &take_modes) override { /* Do not allow removing bot modes on our service bots */ - if (chan->ci && chan->ci->GetBot() == user) + ChanServ::Channel *ci = chan->GetChannel(); + if (ci && ci->GetBot() == user) { const Anope::string &botmodes = Config->GetModule(this)->Get<Anope::string>("botmodes"); for (unsigned i = 0; i < botmodes.length(); ++i) - chan->SetMode(chan->ci->GetBot(), ModeManager::FindChannelModeByChar(botmodes[i]), chan->ci->GetBot()->GetUID()); + chan->SetMode(ci->GetBot(), ModeManager::FindChannelModeByChar(botmodes[i]), ci->GetBot()->GetUID()); } } void OnBotAssign(User *sender, ChanServ::Channel *ci, ServiceBot *bi) override { - printf("on bot assign !\n"); - if (ci->c && ci->c->users.size() >= Config->GetModule(this)->Get<unsigned>("minusers")) + Channel *c = ci->GetChannel(); + if (c && c->users.size() >= Config->GetModule(this)->Get<unsigned>("minusers")) { ChannelStatus status(Config->GetModule(this)->Get<Anope::string>("botmodes")); - bi->Join(ci->c, &status); + bi->Join(c, &status); } } @@ -108,7 +109,8 @@ class BotServCore : public Module, public BotServ::BotServService ModeManager::ProcessModes(); } - if (user->server != Me && c->ci && c->ci->GetBot()) + ChanServ::Channel *ci = c->GetChannel(); + if (user->server != Me && ci && ci->GetBot()) { /** * We let the bot join even if it was an ignored user, as if we don't, @@ -117,18 +119,20 @@ class BotServCore : public Module, public BotServ::BotServService * legit users - Rob **/ /* This is before the user has joined the channel, so check usercount + 1 */ - if (c->users.size() + 1 >= Config->GetModule(this)->Get<unsigned>("minusers") && !c->FindUser(c->ci->GetBot())) + if (c->users.size() + 1 >= Config->GetModule(this)->Get<unsigned>("minusers") && !c->FindUser(ci->GetBot())) { ChannelStatus status(Config->GetModule(this)->Get<Anope::string>("botmodes")); - c->ci->GetBot()->Join(c, &status); + ci->GetBot()->Join(c, &status); } } } void OnLeaveChannel(User *u, Channel *c) override { + ChanServ::Channel *ci = c->GetChannel(); + /* Channel is persistent, it shouldn't be deleted and the service bot should stay */ - if (c->ci && c->ci->IsPersist()) + if (ci && ci->IsPersist()) return; /* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediately @@ -141,9 +145,9 @@ class BotServCore : public Module, public BotServ::BotServService if (inhabit && inhabit->HasExt(c)) return; - if (c->ci) + if (ci) { - ServiceBot *bot = c->ci->GetBot(); + ServiceBot *bot = ci->GetBot(); /* This is called prior to removing the user from the channnel, so c->users.size() - 1 should be safe */ if (bot && u != bot && c->users.size() - 1 <= Config->GetModule(this)->Get<unsigned>("minusers") && c->FindUser(bot)) @@ -203,9 +207,10 @@ class BotServCore : public Module, public BotServ::BotServService EventReturn OnChannelModeSet(Channel *c, const MessageSource &source, ChannelMode *mode, const Anope::string ¶m) override { - if (source.GetUser() && !source.GetBot() && Config->GetModule(this)->Get<bool>("smartjoin") && mode->name == "BAN" && c->ci && c->ci->GetBot() && c->FindUser(c->ci->GetBot())) + ChanServ::Channel *ci = c->GetChannel(); + if (source.GetUser() && !source.GetBot() && Config->GetModule(this)->Get<bool>("smartjoin") && mode->name == "BAN" && ci && ci->GetBot() && c->FindUser(ci->GetBot())) { - ServiceBot *bi = c->ci->GetBot(); + ServiceBot *bi = ci->GetBot(); Entry ban("BAN", param); if (ban.Matches(bi)) |