summaryrefslogtreecommitdiff
path: root/bot/src/irc/client.cpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-07-05 18:56:26 +0500
committerilotterytea <iltsu@alright.party>2025-07-05 18:56:26 +0500
commit0194f86ee840b9585fdc9a111b3d9521217b39bf (patch)
treec05fea406458c5315457eb174a0bbc7a4c022e7a /bot/src/irc/client.cpp
parente39d90442dfd6fb136cda23b0d013da98fb089e9 (diff)
feat: use new IRCMessage parser on WS messages
Diffstat (limited to 'bot/src/irc/client.cpp')
-rw-r--r--bot/src/irc/client.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/bot/src/irc/client.cpp b/bot/src/irc/client.cpp
index 4f8fe6c..108d5c6 100644
--- a/bot/src/irc/client.cpp
+++ b/bot/src/irc/client.cpp
@@ -63,7 +63,12 @@ void Client::run() {
}),
line.end());
- std::optional<MessageType> type = define_message_type(line);
+ std::optional<IRCMessage> m = IRCMessage::from_string(line);
+ if (!m.has_value()) {
+ break;
+ }
+
+ std::optional<MessageType> type = define_message_type(m->command);
if (!type.has_value()) {
break;
@@ -73,7 +78,7 @@ void Client::run() {
if (m_type == MessageType::Privmsg) {
std::optional<Message<MessageType::Privmsg>> message =
- parse_message<MessageType::Privmsg>(line);
+ parse_message<MessageType::Privmsg>(*m);
if (message.has_value()) {
this->onPrivmsg(message.value());
@@ -81,9 +86,11 @@ void Client::run() {
} else if (m_type == MessageType::Ping) {
// as the docs say, the message should be the same as the one
// from the ping
- std::string response_text = msg->str.substr(4, msg->str.size());
-
- this->raw("PONG" + response_text);
+ std::string text;
+ if (!m->params.empty()) {
+ text = " :" + m->params.at(0);
+ }
+ this->raw("PONG" + text);
}
}