summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-06-24 14:29:55 +0100
committerSadie Powell <sadie@witchery.services>2024-06-24 14:29:55 +0100
commit693eeed762eac490b1289f8f4428ff0b5bbf1672 (patch)
tree974cbad287da04fc9e137d7f51092efd2e474acd /modules
parent6e5713d64a379fc64c7ff6658362d02b3618c3ca (diff)
Rework how CTCP messages are sent and received.
Diffstat (limited to 'modules')
-rw-r--r--modules/botserv/bs_control.cpp6
-rw-r--r--modules/botserv/bs_kick.cpp8
-rw-r--r--modules/irc2sql/irc2sql.cpp41
3 files changed, 24 insertions, 31 deletions
diff --git a/modules/botserv/bs_control.cpp b/modules/botserv/bs_control.cpp
index 1784914b6..4847c8470 100644
--- a/modules/botserv/bs_control.cpp
+++ b/modules/botserv/bs_control.cpp
@@ -111,11 +111,7 @@ public:
return;
}
- message = message.replace_all_cs("\1", "");
- if (message.empty())
- return;
-
- IRCD->SendAction(*ci->bi, ci->name, "%s", message.c_str());
+ IRCD->SendPrivmsg(*ci->bi, ci->name, Anope::FormatCTCP("ACTION", message));
ci->bi->lastmsg = Anope::CurTime;
bool override = !source.AccessFor(ci).HasPriv("SAY");
diff --git a/modules/botserv/bs_kick.cpp b/modules/botserv/bs_kick.cpp
index 7d67a6577..f2a39dbf1 100644
--- a/modules/botserv/bs_kick.cpp
+++ b/modules/botserv/bs_kick.cpp
@@ -1215,11 +1215,9 @@ public:
/* If it's a /me, cut the CTCP part because the ACTION will cause
* problems with the caps or badwords kicker
*/
- if (realbuf.substr(0, 8).equals_ci("\1ACTION ") && realbuf[realbuf.length() - 1] == '\1')
- {
- realbuf.erase(0, 8);
- realbuf.erase(realbuf.length() - 1);
- }
+ Anope::string ctcpname, ctcpbody;
+ if (Anope::ParseCTCP(msg, ctcpname, ctcpbody) && ctcpname.equals_ci("ACTION"))
+ realbuf = ctcpbody;
if (realbuf.empty())
return;
diff --git a/modules/irc2sql/irc2sql.cpp b/modules/irc2sql/irc2sql.cpp
index fdd80cdf9..917e37fd3 100644
--- a/modules/irc2sql/irc2sql.cpp
+++ b/modules/irc2sql/irc2sql.cpp
@@ -117,7 +117,7 @@ void IRC2SQL::OnUserConnect(User *u, bool &exempt)
this->RunQuery(query);
if (ctcpuser && (Me->IsSynced() || ctcpeob) && u->server != Me)
- IRCD->SendPrivmsg(StatServ, u->GetUID(), "\1VERSION\1");
+ IRCD->SendPrivmsg(StatServ, u->GetUID(), Anope::FormatCTCP("VERSION"));
}
@@ -299,28 +299,27 @@ void IRC2SQL::OnTopicUpdated(User *source, Channel *c, const Anope::string &user
void IRC2SQL::OnBotNotice(User *u, BotInfo *bi, Anope::string &message, const Anope::map<Anope::string> &tags)
{
- Anope::string versionstr;
if (bi != StatServ)
return;
- if (message[0] == '\1' && message[message.length() - 1] == '\1')
- {
- if (message.substr(0, 9).equals_ci("\1VERSION "))
- {
- if (u->HasExt("CTCPVERSION"))
- return;
- u->Extend<bool>("CTCPVERSION");
-
- versionstr = Anope::NormalizeBuffer(message.substr(9, message.length() - 10));
- if (versionstr.empty())
- return;
- query = "UPDATE `" + prefix + "user` "
- "SET version=@version@ "
- "WHERE nick=@nick@";
- query.SetValue("version", versionstr);
- query.SetValue("nick", u->nick);
- this->RunQuery(query);
- }
- }
+
+ Anope::string ctcpname, ctcpbody;
+ if (!Anope::ParseCTCP(message, ctcpname, ctcpbody) || ctcpname != "VERSION")
+ return;
+
+ if (u->HasExt("CTCPVERSION"))
+ return;
+
+ u->Extend<bool>("CTCPVERSION");
+ auto versionstr = Anope::NormalizeBuffer(message.substr(9, message.length() - 10));
+ if (versionstr.empty())
+ return;
+
+ query = "UPDATE `" + prefix + "user` "
+ "SET version=@version@ "
+ "WHERE nick=@nick@";
+ query.SetValue("version", versionstr);
+ query.SetValue("nick", u->nick);
+ this->RunQuery(query);
}
MODULE_INIT(IRC2SQL)