summaryrefslogtreecommitdiff
path: root/bot/src/utils
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-07-05 18:12:43 +0500
committerilotterytea <iltsu@alright.party>2025-07-05 18:12:43 +0500
commite39d90442dfd6fb136cda23b0d013da98fb089e9 (patch)
tree56d31185d7f64536b1ba5047ceeb6791667d97c2 /bot/src/utils
parent11ca4bf50b7b14b8be54756cb2a7f37ef31890a8 (diff)
feat: parse irc messages fully
Diffstat (limited to 'bot/src/utils')
-rw-r--r--bot/src/utils/string.cpp14
-rw-r--r--bot/src/utils/string.hpp4
2 files changed, 18 insertions, 0 deletions
diff --git a/bot/src/utils/string.cpp b/bot/src/utils/string.cpp
index 38087dc..0dd79dd 100644
--- a/bot/src/utils/string.cpp
+++ b/bot/src/utils/string.cpp
@@ -113,6 +113,20 @@ namespace bot {
return lines;
}
+
+ std::vector<std::string> split_text_n(std::string value,
+ const std::string &separator,
+ const int &n) {
+ std::vector<std::string> v;
+ int fi, i = 0;
+ while ((fi = value.find(separator)) != std::string::npos && i < n) {
+ v.push_back(value.substr(0, fi));
+ value = value.substr(fi + separator.size());
+ i++;
+ }
+ v.push_back(value);
+ return v;
+ }
}
}
}
diff --git a/bot/src/utils/string.hpp b/bot/src/utils/string.hpp
index 18d4f9a..f46b608 100644
--- a/bot/src/utils/string.hpp
+++ b/bot/src/utils/string.hpp
@@ -35,6 +35,10 @@ namespace bot {
const std::string &base, const std::vector<std::string> &values,
const std::string &prefix, const std::string &separator,
const long long &max_length);
+
+ std::vector<std::string> split_text_n(std::string value,
+ const std::string &separator,
+ const int &n);
}
}
}