summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-11-17 22:06:36 +0000
committerPeter Powell <petpow@saberuk.com>2019-11-17 22:17:42 +0000
commit687778b72e31322a73b2e2e17af6bd0f2a2561bc (patch)
treed492c428f43378723357a0f82a2cb73ba994ad83
parentb443df39386c77cf2d027e2b45c4d629261e0100 (diff)
Allow Channel::WriteNotice send to other servers and status ranks.
-rw-r--r--include/channels.h3
-rw-r--r--src/channels.cpp5
-rw-r--r--src/modules/m_ojoin.cpp6
-rw-r--r--src/modules/m_spanningtree/fjoin.cpp9
-rw-r--r--src/modules/m_timedbans.cpp8
-rw-r--r--src/modules/m_uninvite.cpp5
6 files changed, 16 insertions, 20 deletions
diff --git a/include/channels.h b/include/channels.h
index d346db8ef..5957ae668 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -283,8 +283,9 @@ class CoreExport Channel : public Extensible
/** Write a NOTICE to all local users on the channel
* @param text Text to send
+ * @param status The minimum status rank to send this message to.
*/
- void WriteNotice(const std::string& text);
+ void WriteNotice(const std::string& text, char status = 0);
};
inline bool Channel::HasUser(User* user)
diff --git a/src/channels.cpp b/src/channels.cpp
index 282199718..5baaf03ee 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -473,10 +473,11 @@ const char* Channel::ChanModes(bool showsecret)
return scratch.c_str();
}
-void Channel::WriteNotice(const std::string& text)
+void Channel::WriteNotice(const std::string& text, char status)
{
- ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, this, text, MSG_NOTICE);
+ ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, this, text, MSG_NOTICE, status);
Write(ServerInstance->GetRFCEvents().privmsg, privmsg);
+ ServerInstance->PI->SendMessage(this, status, text, MSG_NOTICE);
}
/* returns the status character for a given user on a channel, e.g. @ for op,
diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp
index c0626ec69..e3366056d 100644
--- a/src/modules/m_ojoin.cpp
+++ b/src/modules/m_ojoin.cpp
@@ -57,11 +57,7 @@ class CommandOjoin : public SplitCommand
ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used OJOIN to join "+channel->name);
if (notice)
- {
- const std::string msg = user->nick + " joined on official network business.";
- channel->WriteNotice(msg);
- ServerInstance->PI->SendChannelNotice(channel, 0, msg);
- }
+ channel->WriteNotice(user->nick + " joined on official network business.");
}
else
{
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp
index 6305e5af8..02d985ef3 100644
--- a/src/modules/m_spanningtree/fjoin.cpp
+++ b/src/modules/m_spanningtree/fjoin.cpp
@@ -276,8 +276,13 @@ void CommandFJoin::RemoveStatus(Channel* c)
void CommandFJoin::LowerTS(Channel* chan, time_t TS, const std::string& newname)
{
if (Utils->AnnounceTSChange)
- chan->WriteNotice(InspIRCd::Format("Creation time of %s changed from %s to %s", newname.c_str(),
- InspIRCd::TimeString(chan->age).c_str(), InspIRCd::TimeString(TS).c_str()));
+ {
+ // WriteNotice is not used here because the message only needs to go to the local server.
+ const std::string tsmessage = InspIRCd::Format("Creation time of %s changed from %s to %s", newname.c_str(),
+ InspIRCd::TimeString(chan->age).c_str(), InspIRCd::TimeString(TS).c_str());
+ ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, chan, tsmessage, MSG_NOTICE);
+ chan->Write(ServerInstance->GetRFCEvents().privmsg, privmsg);
+ }
// While the name is equal in case-insensitive compare, it might differ in case; use the remote version
chan->name = newname;
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index ef3382e4b..eb3c47527 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -128,9 +128,7 @@ class CommandTban : public Command
PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h');
char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';
- ClientProtocol::Messages::Privmsg notice(ServerInstance->FakeClient, channel, message, MSG_NOTICE);
- channel->Write(ServerInstance->GetRFCEvents().privmsg, notice, pfxchar);
- ServerInstance->PI->SendChannelNotice(channel, pfxchar, message);
+ channel->WriteNotice(message, pfxchar);
return CMD_SUCCESS;
}
@@ -221,9 +219,7 @@ class ModuleTimedBans : public Module
PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h');
char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';
- ClientProtocol::Messages::Privmsg notice(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, cr, message, MSG_NOTICE);
- cr->Write(ServerInstance->GetRFCEvents().privmsg, notice, pfxchar);
- ServerInstance->PI->SendChannelNotice(cr, pfxchar, message);
+ cr->WriteNotice(message, pfxchar);
Modes::ChangeList setban;
setban.push_remove(ServerInstance->Modes->FindMode('b', MODETYPE_CHANNEL), mask);
diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp
index ae1553a23..ec5653806 100644
--- a/src/modules/m_uninvite.cpp
+++ b/src/modules/m_uninvite.cpp
@@ -100,10 +100,7 @@ class CommandUninvite : public Command
user->WriteRemoteNumeric(n);
lu->WriteNumeric(RPL_UNINVITED, InspIRCd::Format("You were uninvited from %s by %s", c->name.c_str(), user->nick.c_str()));
-
- std::string msg = "*** " + user->nick + " uninvited " + u->nick + ".";
- c->WriteNotice(msg);
- ServerInstance->PI->SendChannelNotice(c, 0, msg);
+ c->WriteNotice(InspIRCd::Format("*** %s uninvited %s.", user->nick.c_str(), u->nick.c_str()));
}
return CMD_SUCCESS;