skunkybot-d/source/commands.d
2025-01-19 00:55:34 +03:00

40 lines
1.4 KiB
D

module commands;
import util;
// UDA
struct Command {
string description = "No description provided";
string name;
}
@Command("Отображает аватар пользователя")
auto avatar(Arguments argz, EventWithoutRoomID* evt) {
import std.net.curl: get;
string url = cast(string)get(homeserver~"/_matrix/client/v3/profile/" ~
((argz.parsed.length == 0) ? evt.sender : argz.parsed[0]) ~ "/avatar_url");
if (url == "{}") return MSG("User has no avatar");
return MSG(evt.sender, `<img src="`~url[15..$-2]~`">`);
}
@Command("", "пинг")
auto ping(Arguments, EventWithoutRoomID* evt) {
import std.datetime: Clock, SysTime, unixTimeToStdTime;
auto delay = (Clock.currTime() - SysTime(unixTimeToStdTime(0))).total!"msecs" - evt.origin_server_ts;
return MSG("PONG [" ~ intToStr(delay) ~ " ms]");
}
@Command("хз мне лень делать описание")
auto echo(Arguments argz, EventWithoutRoomID* evt) {
return MSG((argz.raw.length > 6) ? argz.raw[6..$] : "Too small MSG");
}
@Command()
string[2] huy = [":orehussmile:",
`<img data-mx-emoticon height="32" alt=":orehussmile:" title=":orehussmile:"
src="mxc://4d2.org/XvWYAuhASYRHtYvtspsrWvtU" >`];
@Command("Версия бота", "версия")
string ver = "SkunkyBot Pre-Alpha 0.1 :: https://git.bloat.cat/skunky/skunkybot-d";
@Command("test")
static string compver = "Compiler version: "~intToStr(__VERSION__);