diff options
Diffstat (limited to 'bot/src/irc')
| -rw-r--r-- | bot/src/irc/client.cpp | 7 | ||||
| -rw-r--r-- | bot/src/irc/message.cpp | 2 | ||||
| -rw-r--r-- | bot/src/irc/message.hpp | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/bot/src/irc/client.cpp b/bot/src/irc/client.cpp index 018736e..06b7a03 100644 --- a/bot/src/irc/client.cpp +++ b/bot/src/irc/client.cpp @@ -4,6 +4,7 @@ #include <ixwebsocket/IXWebSocketMessageType.h> #include <algorithm> +#include <iostream> #include <optional> #include <string> #include <vector> @@ -77,6 +78,12 @@ void Client::run() { if (message.has_value()) { this->onPrivmsg(message.value()); } + } 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); } } diff --git a/bot/src/irc/message.cpp b/bot/src/irc/message.cpp index 569e691..038df83 100644 --- a/bot/src/irc/message.cpp +++ b/bot/src/irc/message.cpp @@ -22,6 +22,8 @@ namespace bot { return MessageType::Notice; } else if (parts[i] == "PRIVMSG") { return MessageType::Privmsg; + } else if (parts[i] == "PING") { + return MessageType::Ping; } return std::nullopt; diff --git a/bot/src/irc/message.hpp b/bot/src/irc/message.hpp index 164d7ca..54b911b 100644 --- a/bot/src/irc/message.hpp +++ b/bot/src/irc/message.hpp @@ -11,7 +11,7 @@ namespace bot { namespace irc { - enum MessageType { Privmsg, Notice }; + enum MessageType { Privmsg, Ping, Notice }; std::optional<MessageType> define_message_type(const std::string &msg); struct MessageSender { |
