summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-05-01 00:46:34 +0500
committerilotterytea <iltsu@alright.party>2024-05-01 00:46:34 +0500
commita6444310762fff7c58c0026720634cc295b4ed12 (patch)
tree69d3b7de22e15fa18c0f4c13d6019edcf7cfa2c8 /src
parent93f29bc557d178650928a2027370ae0823940110 (diff)
feat: parse badges from irc message
Diffstat (limited to 'src')
-rw-r--r--src/irc/message.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/irc/message.hpp b/src/irc/message.hpp
index 94541a6..5f090b7 100644
--- a/src/irc/message.hpp
+++ b/src/irc/message.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <functional>
+#include <map>
#include <optional>
#include <sstream>
#include <string>
@@ -18,6 +19,8 @@ namespace bot {
std::string display_name;
int id;
+ std::map<std::string, int> badges;
+
// More fields will be here
};
@@ -85,6 +88,24 @@ namespace bot {
source.id = std::stoi(value);
} else if (key == "user-id") {
sender.id = std::stoi(value);
+ } else if (key == "badges") {
+ std::vector<std::string> badges =
+ utils::string::split_text(value, ',');
+
+ std::map<std::string, int> map;
+
+ for (const auto &badge : badges) {
+ std::istringstream iss2(badge);
+ std::string name;
+ std::string value;
+
+ std::getline(iss2, name, '/');
+ std::getline(iss2, value);
+
+ map.insert(name, value);
+ }
+
+ sender.badges = map;
}
}