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 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));
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
auto cmd = Utility::strSplit(msg, ' ', 1);
|
||||
|
||||
auto command = Utility::lowers(cmd[0]);
|
||||
|
||||
Event response = user.get_notice("You need to log in first", author->uid);
|
||||
if (command == "send") {
|
||||
if (author->loginName.value_or("") == "NetOP") {
|
||||
Event event;
|
||||
try {
|
||||
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);
|
||||
Event response = user.get_notice("You need to log in as NetOP first", author->uid);
|
||||
if (cmd.size() == 2 && !cmd[1].empty()) {
|
||||
if (command == "login") {
|
||||
co_await i->send_event(author->get_encap_su(cmd[1]));
|
||||
response = user.get_notice("Logged in!", author->uid);
|
||||
} else if (command == "send") {
|
||||
if (author->loginName.value_or("") == "NetOP") {
|
||||
Event event;
|
||||
try {
|
||||
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 {
|
||||
response = user.get_notice("Unknown command", author->uid);
|
||||
response = user.get_notice("Insufficient arguments?", author->uid);
|
||||
}
|
||||
co_await i->send_event(response);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue