Warning: session_start(): open(/var/lib/php/sessions/sess_lqnb3cisq4gff04416auba3aq2, 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
abstract sclass DynTalkBot > DynDiscordHopper {
switchable S myName = "Anonymous bot";
transient bool useAGIBlueForDropPunctuation = true;
L authorizedUsers = ll(463778175432785932, 545983823997960193);
start {
dm_vmBus_onMessage_q('discordGuildJoin, voidfunc(Map map) {
ret unless map.get('module) == module();
print("Got join");
onUserJoin(getLong userID(map), map);
});
}
// overridable
void onUserJoin(long userID, O... _) {}
@Override S answer(S input, Map map) {
ret mapEachLine_tlft_nempties(input, s -> {
ret processLine(s, map);
});
}
S processLine(S s, O... _) {
s = preprocess(s, _);
ret processSimplifiedLine(s, _);
}
S preprocess(S s, O... _) {
if (discordBotID != 0)
s = replace(s, discordAt(discordBotID), " " + myName + " ");
s = dropPunctuation3_withAGIBlue(useAGIBlueForDropPunctuation, s);
s = trim(simpleSpaces_noTok(s));
print("simplified >> " + quote(s));
ret s;
}
// extend me
S processSimplifiedLine(S s, O... _)
if (swic_trim(input, prefix + "add master ", m)) {
if (!contains(authorizedUsers, userID)) ret "You are not my master";
add(authorizedUsers, parseFirstLong(m.rest()));
change();
ret "Okidoki. Have " + n2(l(authorizedUsers), "master");
}
null;
}
}