1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 17:04:47 +02:00

Add an IRCv3 time tag to entry messages.

This commit is contained in:
Sadie Powell
2025-10-18 00:38:25 +01:00
parent 84dc0f3cc8
commit b9554f8539
5 changed files with 42 additions and 21 deletions
+13 -1
View File
@@ -990,8 +990,20 @@ module
{
name = "cs_entrymsg"
/* The maximum number of entrymsgs allowed per channel. If not set, defaults to 5. */
/*
* The maximum number of entry messages allowed per channel.
*
* Defaults to 5
*/
maxentries = 5
/*
* Whether to include an IRCv3 time tag for the original add time on entry
* messages.
*
* Defaults to yes.
*/
#timestamp = no
}
command { service = "ChanServ"; name = "ENTRYMSG"; command = "chanserv/entrymsg"; group = "chanserv/management"; }
+2 -2
View File
@@ -215,8 +215,8 @@ 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 SendContextNotice(BotInfo *bi, User *target, Channel *context, const Anope::string &msg, const Anope::map<Anope::string> &tags = {});
virtual void SendContextPrivmsg(BotInfo *bi, User *target, Channel *context, const Anope::string &msg, const Anope::map<Anope::string> &tags = {});
virtual void SendQuit(User *u, const Anope::string &msg = "", const Anope::string &opermsg = "");
virtual void SendPing(const Anope::string &servname, const Anope::string &who);
+11 -2
View File
@@ -296,12 +296,21 @@ public:
if (!messages)
return;
const auto timestamp = Config->GetModule(this).Get<bool>("timestamp", "yes");
for (const auto &message : *(*messages))
{
Anope::map<Anope::string> tags;
if (timestamp)
{
char timebuf[32];
strftime(timebuf, sizeof(timebuf), "%Y-%m-%dT%H:%M:%S.000Z", gmtime(&message->when));
tags["time"] = timebuf;
}
if (u->ShouldPrivmsg())
IRCD->SendContextPrivmsg(c->ci->WhoSends(), u, c, message->message);
IRCD->SendContextPrivmsg(c->ci->WhoSends(), u, c, message->message, tags);
else
IRCD->SendContextNotice(c->ci->WhoSends(), u, c, message->message);
IRCD->SendContextNotice(c->ci->WhoSends(), u, c, message->message, tags);
}
}
}
+8 -8
View File
@@ -249,25 +249,25 @@ public:
Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg);
}
void SendContextNotice(BotInfo *bi, User *target, Channel *context, const Anope::string &msg) override
void SendContextNotice(BotInfo *bi, User *target, Channel *context, const Anope::string &msg, const Anope::map<Anope::string> &tags) override
{
if (spanningtree_proto_ver >= 1206)
{
IRCD->SendNotice(bi, target->GetUID(), msg, {
{ "~context", context->name },
});
auto newtags = tags;
newtags["~context"] = context->name;
IRCD->SendNotice(bi, target->GetUID(), msg, newtags);
return;
}
IRCDProto::SendContextNotice(bi, target, context, msg);
}
void SendContextPrivmsg(BotInfo *bi, User *target, Channel *context, const Anope::string &msg) override
void SendContextPrivmsg(BotInfo *bi, User *target, Channel *context, const Anope::string &msg, const Anope::map<Anope::string> &tags) override
{
if (spanningtree_proto_ver >= 1206)
{
IRCD->SendPrivmsg(bi, target->GetUID(), msg, {
{ "~context", context->name },
});
auto newtags = tags;
newtags["~context"] = context->name;
IRCD->SendPrivmsg(bi, target->GetUID(), msg, newtags);
return;
}
IRCDProto::SendContextPrivmsg(bi, target, context, msg);
+8 -8
View File
@@ -388,18 +388,18 @@ 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)
void IRCDProto::SendContextNotice(BotInfo *bi, User *target, Channel *context, const Anope::string &msg, const Anope::map<Anope::string> &tags)
{
IRCD->SendNotice(bi, target->GetUID(), Anope::Format("[%s] %s", context->name.c_str(), msg.c_str()), {
{ "+draft/channel-context", context->name },
});
auto newtags = tags;
newtags["+draft/channel-context"] = context->name;
IRCD->SendNotice(bi, target->GetUID(), Anope::Format("[%s] %s", context->name.c_str(), msg.c_str()), newtags);
}
void IRCDProto::SendContextPrivmsg(BotInfo *bi, User *target, Channel *context, const Anope::string &msg)
void IRCDProto::SendContextPrivmsg(BotInfo *bi, User *target, Channel *context, const Anope::string &msg, const Anope::map<Anope::string> &tags)
{
IRCD->SendPrivmsg(bi, target->GetUID(), Anope::Format("[%s] %s", context->name.c_str(), msg.c_str()), {
{ "+draft/channel-context", context->name },
});
auto newtags = tags;
newtags["+draft/channel-context"] = context->name;
IRCD->SendPrivmsg(bi, target->GetUID(), Anope::Format("[%s] %s", context->name.c_str(), msg.c_str()), newtags);
}
MessageSource::MessageSource(const Anope::string &src) : source(src)