blob: 2957e34837b1086edf70b29b5d017899cbd47e1b (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#pragma once
#include <string>
#include <variant>
#include <vector>
#include "../bundle.hpp"
#include "../commands/command.hpp"
namespace bot {
namespace mod {
class Massping : public command::Command {
std::string get_name() const override { return "massping"; }
schemas::PermissionLevel get_permission_level() const override {
return schemas::PermissionLevel::MODERATOR;
}
int get_delay_seconds() const override { return 1; }
std::variant<std::vector<std::string>, std::string> run(
const InstanceBundle &bundle,
const command::Request &request) const override {
auto chatters = bundle.helix_client.get_chatters(
request.channel.get_alias_id(), bundle.irc_client.get_bot_id());
std::string m;
if (request.message.has_value()) {
m = request.message.value() + " ·";
}
std::string base = "📣 " + m + " ";
std::vector<std::string> msgs = {""};
int index = 0;
for (const auto &chatter : chatters) {
const std::string ¤t_msg = msgs.at(index);
std::string x = "@" + chatter.login;
if (base.length() + current_msg.length() + 1 + x.length() >= 500) {
index += 1;
}
if (index > msgs.size() - 1) {
msgs.push_back(x);
} else {
msgs[index] = current_msg + " " + x;
}
}
std::vector<std::string> msgs2;
for (const auto &m : msgs) {
msgs2.push_back(base + m);
}
return msgs2;
}
};
}
}
|