summaryrefslogtreecommitdiff
path: root/bot/src/handlers.cpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-12-07 17:24:25 +0500
committerilotterytea <iltsu@alright.party>2024-12-07 17:24:25 +0500
commit52fd4ea8bad5cd7d3940a41df4f8f54b4e72beae (patch)
tree28f13892e7da8ec023f4b4d1113bef88795724ca /bot/src/handlers.cpp
parente604d12282b8fa9f9023bb79161b36c9a8b0be55 (diff)
feat: a special class for command responses
Diffstat (limited to 'bot/src/handlers.cpp')
-rw-r--r--bot/src/handlers.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/bot/src/handlers.cpp b/bot/src/handlers.cpp
index c7820b4..e764652 100644
--- a/bot/src/handlers.cpp
+++ b/bot/src/handlers.cpp
@@ -36,18 +36,12 @@ namespace bot::handlers {
auto response = command_loader.run(bundle, request.value());
if (response.has_value()) {
- try {
- auto str = std::get<std::string>(*response);
- bundle.irc_client.say(message.source.login, str);
- } catch (const std::exception &e) {
- }
-
- try {
- auto strs = std::get<std::vector<std::string>>(*response);
- for (const std::string &str : strs) {
- bundle.irc_client.say(message.source.login, str);
+ if (response->is_single()) {
+ bundle.irc_client.say(message.source.login, response->get_single());
+ } else if (response->is_multiple()) {
+ for (const std::string &msg : response->get_multiple()) {
+ bundle.irc_client.say(message.source.login, msg);
}
- } catch (const std::exception &e) {
}
}
} catch (const std::exception &e) {