浏览代码

uncursing and unblessing

Kirk Trombley 6 年之前
父节点
当前提交
b38f93fb6c
共有 1 个文件被更改,包括 33 次插入1 次删除
  1. 33 1
      src/plugins/curse.py

+ 33 - 1
src/plugins/curse.py

@@ -137,7 +137,7 @@ class Bless(RollbotPlugin):
     def on_command(self, db, msg):
         name, _ = pop_arg(msg.raw_args)
         if name.startswith("!"):
-            return RollbotResponse(msg, txt=f"Sorry! Subcommands have to go on !curse for now - this will be fixed in the future!")
+            return "Sorry! Subcommands have to go on !curse for now - this will be fixed in the future!"
         person_id = name.strip().lower()
         if is_banned(msg, person_id):
             self.bot.manually_post_message("Hey! You aren't allowed to affect that person's score! And cheaters never propser!", msg.group_id)
@@ -154,3 +154,35 @@ class Blurse(Bless):
     def do_score_change(self, score):
         score.blessings = score.blessings + 1
         score.curses = score.curses + 1
+
+
+@as_plugin
+def unbless(db, msg):
+    name, _ = pop_arg(msg.raw_args)
+    if name.startswith("!"):
+        return "Sorry! Subcommands have to go on !curse for now - this will be fixed in the future!"
+    if not msg.from_admin:
+        return RollbotResponse(msg, failure=RollbotFailure.PERMISSIONS, debugging={ "explain": "For now, only admins can unbless or uncurse people!" })
+    person_id = name.strip().lower()
+    if is_banned(msg, person_id):
+        return "Hey! You aren't allowed to affect that person's score!"
+
+    score = get_score(db, msg.group_id, person_id)
+    score.blessings = score.blessings - 1
+    return get_response(msg, name, score)
+
+
+@as_plugin
+def uncurse(db, msg):
+    name, _ = pop_arg(msg.raw_args)
+    if name.startswith("!"):
+        return "Sorry! Subcommands have to go on !curse for now - this will be fixed in the future!"
+    if not msg.from_admin:
+        return RollbotResponse(msg, failure=RollbotFailure.PERMISSIONS, debugging={ "explain": "For now, only admins can unbless or uncurse people!" })
+    person_id = name.strip().lower()
+    if is_banned(msg, person_id):
+        return "Hey! You aren't allowed to affect that person's score!"
+
+    score = get_score(db, msg.group_id, person_id)
+    score.curses = score.curses - 1
+    return get_response(msg, name, score)