|
@@ -1,9 +1,9 @@
|
|
|
+import logging
|
|
|
|
|
|
from sqlalchemy import Column, Integer, String
|
|
|
|
|
|
-from command_system import RollbotResponse, RollbotFailure, as_plugin, ModelBase, pop_arg
|
|
|
-from config import get_secret, BOTS_LOOKUP
|
|
|
-from util import post_message
|
|
|
+from command_system import RollbotResponse, RollbotFailure, RollbotPlugin, as_plugin, ModelBase, pop_arg
|
|
|
+from config import get_secret
|
|
|
|
|
|
|
|
|
class CurseBlessScore(ModelBase):
|
|
@@ -127,15 +127,18 @@ def curse(db, msg):
|
|
|
return SUBC_MAP.get(subc, lambda *a: RollbotResponse(msg, failure=RollbotFailure.INVALID_SUBCOMMAND))(db, msg, args)
|
|
|
|
|
|
|
|
|
-@as_plugin
|
|
|
-def bless(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!")
|
|
|
- person_id = name.strip().lower()
|
|
|
- if is_banned(msg, person_id):
|
|
|
- post_message("Hey! You aren't allowed to affect that person's score! And cheaters never propser!", BOTS_LOOKUP[msg.group_id])
|
|
|
- return RollbotResponse(msg, txt=f"!curse {BAN_LIST[msg.sender_id][0]} for trying to bless someone they can't!")
|
|
|
- score = get_score(db, msg.group_id, person_id)
|
|
|
- score.blessings = score.blessings + 1
|
|
|
- return get_response(msg, name, score)
|
|
|
+class bless(RollbotPlugin):
|
|
|
+ def __init__(self, bot, logger=logging.getLogger(__name__)):
|
|
|
+ RollbotPlugin.__init__(self, "bless", bot, logger=logger)
|
|
|
+
|
|
|
+ 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!")
|
|
|
+ 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)
|
|
|
+ return RollbotResponse(msg, txt=f"!curse {BAN_LIST[msg.sender_id][0]} for trying to bless someone they can't!")
|
|
|
+ score = get_score(db, msg.group_id, person_id)
|
|
|
+ score.blessings = score.blessings + 1
|
|
|
+ return get_response(msg, name, score)
|