Warning: session_start(): open(/var/lib/php/sessions/sess_rdcab9q8judbv328d53l8mles8, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
cmodule DiscordBot > DynPrintLogAndEnabled {
transient JDA bot;
start {
logModuleOutput();
// TODO: log JDA output
bot = discordBot(new ListenerAdapter {
public void onMessageReceived(MessageReceivedEvent e) {
ret if !enabled || !licensed();
ret if e.getAuthor().isBot();
print("Channel type: " + e.getChannelType());
bool isPrivate = e.getChannelType() == ChannelType.PRIVATE;
print("Msg from " + e.getAuthor().getName() + ": " + e.getMessage().getContentDisplay());
S content = e.getMessage().getContentRaw();
new Matches m;
S s = "";
if (isPrivate) s = content;
else if (swic(content, "gazelle", m)) s = m.rest();
if (empty(s)) ret;
s = "Bah! " + trim(s);
print("Sending: " + s);
fbool delete = ewic(content, "delete");
e.getChannel().sendMessage(s).queue(msg -> {
print("I sent msg: " + msg.getIdLong());
if (delete) doLater(5.0, r {
msg.delete().queue();
});
});
}
public void onMessageReactionAdd(MessageReactionAddEvent e) {
ret if !enabled || !licensed();
MessageReaction r = e.getReaction();
bool bot = e.getUser().isBot();
print("User " + e.getUser() + (bot ? " (bot)" : "") + " reacted to message " + r.getMessageIdLong() + " with " + r.getReactionEmote());
if (bot) ret;
e.getChannel().sendMessage("You just " + r.getReactionEmote().getName() + " ed");
}
});
print("Started bot");
}
void cleanMeUp {
if (bot != null) pcall {
bot.shutdown();
}
bot = null;
}
}