summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/protocol.h3
-rw-r--r--modules/chanserv/cs_entrymsg.cpp12
-rw-r--r--src/protocol.cpp14
3 files changed, 26 insertions, 3 deletions
diff --git a/include/protocol.h b/include/protocol.h
index cb646aa59..911c78d68 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -194,6 +194,9 @@ public:
virtual void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) = 0;
virtual void SendGlobalPrivmsg(BotInfo *bi, const Server *desc, const Anope::string &msg) = 0;
+ virtual void SendContextNotice(BotInfo *bi, User *target, Channel *context, const Anope::string &msg);
+ virtual void SendContextPrivmsg(BotInfo *bi, User *target, Channel *context, const Anope::string &msg);
+
virtual void SendQuit(User *u, const char *fmt, ...) ATTR_FORMAT(3, 4);
virtual void SendPing(const Anope::string &servname, const Anope::string &who);
virtual void SendPong(const Anope::string &servname, const Anope::string &who);
diff --git a/modules/chanserv/cs_entrymsg.cpp b/modules/chanserv/cs_entrymsg.cpp
index 0b5469661..c28c58bc9 100644
--- a/modules/chanserv/cs_entrymsg.cpp
+++ b/modules/chanserv/cs_entrymsg.cpp
@@ -283,10 +283,16 @@ public:
if (u && c && c->ci && u->server->IsSynced())
{
EntryMessageList *messages = c->ci->GetExt<EntryMessageList>("entrymsg");
+ if (!messages)
+ return;
- if (messages != NULL)
- for (const auto &message : *(*messages))
- u->SendMessage(c->ci->WhoSends(), "[%s] %s", c->ci->name.c_str(), message->message.c_str());
+ for (const auto &message : *(*messages))
+ {
+ if (u->ShouldPrivmsg())
+ IRCD->SendContextPrivmsg(c->ci->WhoSends(), u, c, message->message);
+ else
+ IRCD->SendContextNotice(c->ci->WhoSends(), u, c, message->message);
+ }
}
}
};
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 9856aa446..920e0662b 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -411,6 +411,20 @@ Anope::string IRCDProto::NormalizeMask(const Anope::string &mask)
return Entry("", mask).GetNUHMask();
}
+void IRCDProto::SendContextNotice(BotInfo *bi, User *target, Channel *context, const Anope::string &msg)
+{
+ IRCD->SendNoticeInternal(bi, target->GetUID(), Anope::printf("[%s] %s", context->name.c_str(), msg.c_str()), {
+ { "+draft/channel-context", context->name },
+ });
+}
+
+void IRCDProto::SendContextPrivmsg(BotInfo *bi, User *target, Channel *context, const Anope::string &msg)
+{
+ IRCD->SendPrivmsgInternal(bi, target->GetUID(), Anope::printf("[%s] %s", context->name.c_str(), msg.c_str()), {
+ { "+draft/channel-context", context->name },
+ });
+}
+
size_t IRCDProto::GetMaxChannel()
{
// We can cache this as its not allowed to change on rehash.