|
@@ -42,6 +42,8 @@ def curse_agg(db, msg, args):
|
|
|
|
|
|
def curse_clear(db, msg, args):
|
|
|
name, _ = pop_arg(args)
|
|
|
+ if name is None:
|
|
|
+ return RollbotResponse(msg, txt=f"Sorry! I need to know who's records you're trying to clear!")
|
|
|
person_id = name.strip().lower()
|
|
|
if not msg.from_admin:
|
|
|
return RollbotResponse(msg, failure=RollbotFailure.PERMISSIONS)
|
|
@@ -57,6 +59,8 @@ def curse_clear(db, msg, args):
|
|
|
|
|
|
def curse_clearall(db, msg, args):
|
|
|
name, _ = pop_arg(args)
|
|
|
+ if name is None:
|
|
|
+ return RollbotResponse(msg, txt=f"Sorry! I need to know who's records you're trying to clear!")
|
|
|
person_id = name.strip().lower()
|
|
|
if not msg.from_admin:
|
|
|
return RollbotResponse(msg, failure=RollbotFailure.PERMISSIONS)
|
|
@@ -74,10 +78,23 @@ def curse_clearall(db, msg, args):
|
|
|
return RollbotResponse(msg, txt=f"Done! I have cleared all records of {name} in all chats, who was previously cursed {fmt_times(oc)} and blessed {fmt_times(ob)} in total!")
|
|
|
|
|
|
|
|
|
+def curse_top(db, msg, args):
|
|
|
+ rankings = "\n".join(f"{i + 1}. {cbs.person_id.capitalize()} was cursed {fmt_times(cbs.curses)}"
|
|
|
+ for i, cbs in enumerate(db.query(CurseBlessScore
|
|
|
+ ).filter(CurseBlessScore.group_id == msg.group_id
|
|
|
+ ).filter(CurseBlessScore.curses != 0
|
|
|
+ ).order_by(CurseBlessScore.curses.desc()
|
|
|
+ ).limit(10)))
|
|
|
+ if len(rankings) == 0:
|
|
|
+ return RollbotResponse(msg, txt="Sorry! I don't have enough curse history in this chat to give statistics.")
|
|
|
+ return RollbotResponse(msg, txt=f"The worst offenders of this chat:\n{rankings}")
|
|
|
+
|
|
|
+
|
|
|
SUBC_MAP = {
|
|
|
"aggregate": curse_agg,
|
|
|
"clear": curse_clear,
|
|
|
"clearall": curse_clearall,
|
|
|
+ "top": curse_top,
|
|
|
}
|
|
|
|
|
|
|