blob: 038df834dbfb023190963c6bb292af3e5c9d9754 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#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;
} else if (parts[i] == "PING") {
return MessageType::Ping;
}
return std::nullopt;
}
}
}
|