Warning: session_start(): open(/var/lib/php/sessions/sess_pa75u8n3hpvd1m5gc7afr3sshj, 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
//!include once #1025868 // DynTalkBot2 compact include - causes exceptions sometimes after reloads
concept PostedRuleMatch {
long guildID, msgID;
AGIBlue_MatchedRule matchedRule;
L reactions() {
ret conceptsWhere(concepts(), Reaction, +msgID);
}
toString { ret sfu(this); }
}
concept Reaction {
long msgID, userID;
S emoji;
}
standardBot1 agiBlueRulesBot {
init {
dbIndexing(PostedRuleMatch, 'msgID, Reaction, 'msgID);
analyze();
}
processSimplified {
if null (s = dropMyPrefixOrNull(s)) null;
long channelID = longPar channelID(_);
L rules = agiBlue_ruleObjects();
L matches = agiBlue_matchAllRulesOnInput(s);
if (empty(matches)) ret "No matches with " + nRules(rules);
L matches2 = takeFirst(5, matches);
for (AGIBlue_MatchedRule mm : matches2) {
S r = backtickQuote(mm.rewrittenRHS())
+ "\n " + mm.map;
postInChannel(channelID, r, msg -> {
temp enter();
cnew(PostedRuleMatch, guildID := guildID, msgID := msg.getIdLong(), matchedRule := mm);
queue(msg.addReaction(positiveEmoji));
queue(msg.addReaction(negativeEmoji));
});
}
postInChannel(channelID, plusNMoreWithNL(matches, matches2));
}
void onMessageReaction(Map map, bool added) {
long msgID = cast map.get('msgID);
long userID = cast map.get('userID);
S emoji = cast map.get('emoji);
if (added) {
Reaction r = uniq(Reaction, +msgID, +userID, +emoji);
print("Added reaction: " + sfu(r));
} else {
print("Removed reaction: " + sfu(removeConceptsWhere(Reaction, +msgID, +userID, +emoji)));
}
}
allServers {
transient S positiveEmoji = unicode_thumbsUp();
transient S negativeEmoji = unicode_thumbsDown();
void analyze {
for (PostedRuleMatch pr) {
int pos = 0, neg = 0;
for (Reaction r : pr.reactions()) {
if (eq(r.emoji, positiveEmoji)) ++pos;
else if (eq(r.emoji, negativeEmoji)) ++neg;
}
if (pos > 0 && neg > 0) continue with print("Unclear reactions to " + pr);
if (pos == 0 && neg == 0) continue;
SS map = pr.matchedRule.map;
if (empty(map))
if (neg > 0)
continue with print("Weird: Negative reaction to unchanged rule: " + pr);
else
continue with print("Unchanged rule confirmed: " + pr);
if (l(map) == 1)
continue with print(quote(firstKey(map)) + " and " + quote(firstValue(map)) + " are similar");
print("Feedback needs to be assigned to parts: " + pr);
}
}
}
}