diff options
author | Sadie Powell <sadie@witchery.services> | 2024-06-24 14:29:55 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-06-24 14:29:55 +0100 |
commit | 693eeed762eac490b1289f8f4428ff0b5bbf1672 (patch) | |
tree | 974cbad287da04fc9e137d7f51092efd2e474acd /src/messages.cpp | |
parent | 6e5713d64a379fc64c7ff6658362d02b3618c3ca (diff) |
Rework how CTCP messages are sent and received.
Diffstat (limited to 'src/messages.cpp')
-rw-r--r-- | src/messages.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/messages.cpp b/src/messages.cpp index 9a0a7a539..512da3e95 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -342,19 +342,17 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m if (bi) { - if (message[0] == '\1' && message[message.length() - 1] == '\1') + Anope::string ctcpname, ctcpbody; + if (Anope::ParseCTCP(message, ctcpname, ctcpbody)) { - if (message.substr(0, 6).equals_ci("\1PING ")) + if (ctcpname.equals_ci("PING")) { - Anope::string buf = message; - buf.erase(buf.begin()); - buf.erase(buf.end() - 1); - IRCD->SendCTCP(bi, u->nick, "%s", buf.c_str()); + IRCD->SendNotice(bi, u->nick, Anope::FormatCTCP("PING", ctcpbody)); } - else if (message.substr(0, 9).equals_ci("\1VERSION\1")) + else if (ctcpname.equals_ci("VERSION")) { Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); - IRCD->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str()); + IRCD->SendNotice(bi, u->nick, Anope::FormatCTCP("VERSION", Anope::printf("Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str()))); } return; } |