From e39d90442dfd6fb136cda23b0d013da98fb089e9 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 5 Jul 2025 18:12:43 +0500 Subject: feat: parse irc messages fully --- bot/src/utils/string.cpp | 14 ++++++++++++++ bot/src/utils/string.hpp | 4 ++++ 2 files changed, 18 insertions(+) (limited to 'bot/src/utils') 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 split_text_n(std::string value, + const std::string &separator, + const int &n) { + std::vector 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 &values, const std::string &prefix, const std::string &separator, const long long &max_length); + + std::vector split_text_n(std::string value, + const std::string &separator, + const int &n); } } } -- cgit v1.2.3