summaryrefslogtreecommitdiff
path: root/bot/src/irc/message.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bot/src/irc/message.cpp')
-rw-r--r--bot/src/irc/message.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/bot/src/irc/message.cpp b/bot/src/irc/message.cpp
new file mode 100644
index 0000000..569e691
--- /dev/null
+++ b/bot/src/irc/message.cpp
@@ -0,0 +1,30 @@
+#include "message.hpp"
+
+#include <optional>
+#include <string>
+#include <vector>
+
+namespace bot {
+ namespace irc {
+ std::optional<MessageType> define_message_type(const std::string &msg) {
+ std::vector<std::string> parts = utils::string::split_text(msg, ' ');
+ int i;
+
+ if (msg[0] == '@') {
+ i = 2;
+ } else if (msg[0] == ':') {
+ i = 1;
+ } else {
+ return std::nullopt;
+ }
+
+ if (parts[i] == "NOTICE") {
+ return MessageType::Notice;
+ } else if (parts[i] == "PRIVMSG") {
+ return MessageType::Privmsg;
+ }
+
+ return std::nullopt;
+ }
+ }
+}