mirror of
https://gitlab.com/niansa/asbots.git
synced 2025-03-06 20:48:25 +01:00
Some more test code
This commit is contained in:
parent
cb0fcd6d8f
commit
3bb85ee277
1 changed files with 20 additions and 12 deletions
|
@ -42,7 +42,7 @@ async::result<void> TestService::intitialize() {
|
||||||
};
|
};
|
||||||
co_await mark_ready(user);
|
co_await mark_ready(user);
|
||||||
co_await i->send_event(serviceChannel.get_sjoin(user.uid));
|
co_await i->send_event(serviceChannel.get_sjoin(user.uid));
|
||||||
co_await i->send_event(serviceChannel.get_topic("IRC Service channel", user.uid));
|
//co_await i->send_event(serviceChannel.get_topic("IRC Service channel", user.uid));
|
||||||
co_await i->send_event(user.get_notice("Test... Hello world!", serviceChannel.name));
|
co_await i->send_event(user.get_notice("Test... Hello world!", serviceChannel.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,22 +52,30 @@ async::result<void> TestService::on_event(const Event& event) {
|
||||||
|
|
||||||
async::result<void> TestService::on_direct_privmsg(std::string_view msg, u_User &author) {
|
async::result<void> TestService::on_direct_privmsg(std::string_view msg, u_User &author) {
|
||||||
auto cmd = Utility::strSplit(msg, ' ', 1);
|
auto cmd = Utility::strSplit(msg, ' ', 1);
|
||||||
|
|
||||||
auto command = Utility::lowers(cmd[0]);
|
auto command = Utility::lowers(cmd[0]);
|
||||||
|
|
||||||
Event response = user.get_notice("You need to log in first", author->uid);
|
Event response = user.get_notice("You need to log in as NetOP first", author->uid);
|
||||||
if (command == "send") {
|
if (cmd.size() == 2 && !cmd[1].empty()) {
|
||||||
if (author->loginName.value_or("") == "NetOP") {
|
if (command == "login") {
|
||||||
Event event;
|
co_await i->send_event(author->get_encap_su(cmd[1]));
|
||||||
try {
|
response = user.get_notice("Logged in!", author->uid);
|
||||||
event.parse(cmd[1]);
|
} else if (command == "send") {
|
||||||
co_await i->send_event(event);
|
if (author->loginName.value_or("") == "NetOP") {
|
||||||
response = user.get_notice("Sent.", author->uid);
|
Event event;
|
||||||
} catch (std::exception&e) {
|
try {
|
||||||
response = user.get_notice(e.what(), author->uid);
|
event.parse(cmd[1]);
|
||||||
|
co_await i->send_event(event);
|
||||||
|
response = user.get_notice("Sent.", author->uid);
|
||||||
|
} catch (std::exception&e) {
|
||||||
|
response = user.get_notice(e.what(), author->uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
response = user.get_notice("Unknown command", author->uid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
response = user.get_notice("Unknown command", author->uid);
|
response = user.get_notice("Insufficient arguments?", author->uid);
|
||||||
}
|
}
|
||||||
co_await i->send_event(response);
|
co_await i->send_event(response);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue