summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/channels.h5
-rw-r--r--modules/commands/ns_recover.cpp2
-rw-r--r--modules/commands/os_mode.cpp4
-rw-r--r--modules/protocol/inspircd12.cpp2
-rw-r--r--modules/protocol/inspircd3.cpp2
-rw-r--r--modules/protocol/unreal.cpp2
-rw-r--r--modules/pseudoclients/chanserv.cpp4
-rw-r--r--src/channels.cpp23
-rw-r--r--src/logger.cpp2
-rw-r--r--src/modes.cpp2
-rw-r--r--src/regchannel.cpp5
-rw-r--r--src/servers.cpp4
12 files changed, 39 insertions, 18 deletions
diff --git a/include/channels.h b/include/channels.h
index c6f9b66ad..e3ce9acf1 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -289,6 +289,11 @@ class CoreExport Channel : public Base, public Extensible
*/
bool CheckKick(User *user);
+ /** Find which bot should send mode/topic/etc changes for this channel
+ * @return The bot
+ */
+ BotInfo *WhoSends() const;
+
/** Finds a channel
* @param name The channel to find
* @return The channel, if found
diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp
index 20309cf86..67994a983 100644
--- a/modules/commands/ns_recover.cpp
+++ b/modules/commands/ns_recover.cpp
@@ -284,7 +284,7 @@ class NSRecover : public Module
if (it != ei->end())
{
for (size_t i = 0; i < it->second.Modes().length(); ++i)
- c->SetMode(c->ci->WhoSends(), ModeManager::FindChannelModeByChar(it->second.Modes()[i]), u->GetUID());
+ c->SetMode(c->WhoSends(), ModeManager::FindChannelModeByChar(it->second.Modes()[i]), u->GetUID());
ei->erase(it);
if (ei->empty())
diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp
index 11fd8da03..0710065ea 100644
--- a/modules/commands/os_mode.cpp
+++ b/modules/commands/os_mode.cpp
@@ -37,7 +37,7 @@ class CommandOSMode : public Command
const Channel::ModeList chmodes = c->GetModes();
for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end && c; ++it)
- c->RemoveMode(c->ci->WhoSends(), it->first, it->second, false);
+ c->RemoveMode(c->WhoSends(), it->first, it->second, false);
if (!c)
{
@@ -55,7 +55,7 @@ class CommandOSMode : public Command
continue;
for (size_t i = uc->status.Modes().length(); i > 0; --i)
- c->RemoveMode(c->ci->WhoSends(), ModeManager::FindChannelModeByChar(uc->status.Modes()[i - 1]), uc->user->GetUID(), false);
+ c->RemoveMode(c->WhoSends(), ModeManager::FindChannelModeByChar(uc->status.Modes()[i - 1]), uc->user->GetUID(), false);
}
source.Reply(_("All modes cleared on %s."), c->name.c_str());
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index f4fe73ecc..8b1a18bb2 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -144,7 +144,7 @@ class InspIRCd12Proto : public IRCDProto
{
if (Servers::Capab.count("SVSTOPIC"))
{
- UplinkSocket::Message(c->ci->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic;
+ UplinkSocket::Message(c->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic;
}
else
{
diff --git a/modules/protocol/inspircd3.cpp b/modules/protocol/inspircd3.cpp
index 6329d5c8c..c58e55519 100644
--- a/modules/protocol/inspircd3.cpp
+++ b/modules/protocol/inspircd3.cpp
@@ -179,7 +179,7 @@ class InspIRCd3Proto : public IRCDProto
{
if (Servers::Capab.count("SVSTOPIC"))
{
- UplinkSocket::Message(c->ci->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic;
+ UplinkSocket::Message(c->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic;
}
else
{
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index 4f484c603..ed4b95142 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -362,7 +362,7 @@ class UnrealIRCdProto : public IRCDProto
/* Unreal does not support updating a channels TS without actually joining a user,
* so we will join and part us now
*/
- BotInfo *bi = c->ci->WhoSends();
+ BotInfo *bi = c->WhoSends();
if (!bi)
;
else if (c->FindUser(bi) == NULL)
diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp
index 90f63b108..0809a25b3 100644
--- a/modules/pseudoclients/chanserv.cpp
+++ b/modules/pseudoclients/chanserv.cpp
@@ -288,7 +288,7 @@ class ChanServCore : public Module, public ChanServService
if (c->ci)
c->SetMode(c->ci->WhoSends(), "REGISTERED", "", false);
else
- c->RemoveMode(c->ci->WhoSends(), "REGISTERED", "", false);
+ c->RemoveMode(c->WhoSends(), "REGISTERED", "", false);
const Anope::string &require = Config->GetModule(this)->Get<const Anope::string>("require");
if (!require.empty())
@@ -296,7 +296,7 @@ class ChanServCore : public Module, public ChanServService
if (c->ci)
c->SetModes(c->ci->WhoSends(), false, "+%s", require.c_str());
else
- c->SetModes(c->ci->WhoSends(), false, "-%s", require.c_str());
+ c->SetModes(c->WhoSends(), false, "-%s", require.c_str());
}
}
diff --git a/src/channels.cpp b/src/channels.cpp
index 6fcd62b67..8a1f89081 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -783,7 +783,7 @@ bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...)
return false;
if (bi == NULL)
- bi = this->ci->WhoSends();
+ bi = this->WhoSends();
EventReturn MOD_RESULT;
FOREACH_RESULT(OnBotKick, MOD_RESULT, (bi, this, u, buf));
@@ -812,7 +812,7 @@ void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtop
this->topic_setter = user;
this->topic_ts = ts;
- IRCD->SendTopic(this->ci->WhoSends(), this);
+ IRCD->SendTopic(this->WhoSends(), this);
/* Now that the topic is set update the time set. This is *after* we set it so the protocol modules are able to tell the old last set time */
this->topic_time = Anope::CurTime;
@@ -911,8 +911,10 @@ bool Channel::CheckKick(User *user)
if (MOD_RESULT != EVENT_STOP)
return false;
- if (mask.empty())
+ if (mask.empty() && this->ci)
mask = this->ci->GetIdealBan(user);
+ if (mask.empty())
+ mask = "*!*@" + user->GetDisplayedHost();
if (reason.empty())
reason = Language::Translate(user->Account(), CHAN_NOT_ALLOWED_TO_JOIN);
@@ -924,6 +926,21 @@ bool Channel::CheckKick(User *user)
return true;
}
+BotInfo* Channel::WhoSends() const
+{
+ if (ci)
+ return ci->WhoSends();
+
+ BotInfo *ChanServ = Config->GetClient("ChanServ");
+ if (ChanServ)
+ return ChanServ;
+
+ if (!BotListByNick->empty())
+ return BotListByNick->begin()->second;
+
+ return NULL;
+}
+
Channel* Channel::Find(const Anope::string &name)
{
channel_map::const_iterator it = ChannelList.find(name);
diff --git a/src/logger.cpp b/src/logger.cpp
index 244cacdba..acacda286 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -369,7 +369,7 @@ void LogInfo::ProcessMessage(const Log *l)
if (!bi)
bi = this->bot;
if (!bi)
- bi = c->ci->WhoSends();
+ bi = c->WhoSends();
if (bi)
IRCD->SendPrivmsg(bi, c->name, "%s", buffer.c_str());
}
diff --git a/src/modes.cpp b/src/modes.cpp
index c5675b119..5f950df57 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -617,7 +617,7 @@ void ModeManager::StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set,
if (bi)
s->bi = bi;
else
- s->bi = c->ci->WhoSends();
+ s->bi = c->WhoSends();
if (!modePipe)
modePipe = new ModePipe();
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index d420ab0df..984da55ab 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -355,7 +355,7 @@ NickCore *ChannelInfo::GetSuccessor() const
BotInfo *ChannelInfo::WhoSends() const
{
- if (this && this->bi)
+ if (this->bi)
return this->bi;
BotInfo *ChanServ = Config->GetClient("ChanServ");
@@ -629,8 +629,7 @@ void ChannelInfo::ClearLevels()
Anope::string ChannelInfo::GetIdealBan(User *u) const
{
- int bt = this ? this->bantype : -1;
- switch (bt)
+ switch (this->bantype)
{
case 0:
return "*!" + u->GetVIdent() + "@" + u->GetDisplayedHost();
diff --git a/src/servers.cpp b/src/servers.cpp
index 54dd853b5..23ea18139 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -121,11 +121,11 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano
ChannelMode *cm = ModeManager::FindChannelModeByName(it2->first);
if (!cm || cm->type != MODE_LIST)
continue;
- ModeManager::StackerAdd(c->ci->WhoSends(), c, cm, true, it2->second);
+ ModeManager::StackerAdd(c->WhoSends(), c, cm, true, it2->second);
}
if (!c->topic.empty() && !c->topic_setter.empty())
- IRCD->SendTopic(c->ci->WhoSends(), c);
+ IRCD->SendTopic(c->WhoSends(), c);
c->syncing = true;
}