From f677c661f0841e03b29920fb0b619ceefa462501 Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 10 Jan 2022 17:27:25 +0100 Subject: [PATCH] modules/CommandDrink.py --- modules/CommandDrink.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/CommandDrink.py b/modules/CommandDrink.py index 70a0fcd..9f88c7c 100644 --- a/modules/CommandDrink.py +++ b/modules/CommandDrink.py @@ -16,7 +16,7 @@ class CommandDrink(AbstractCommand): CONFIG = {"display_name": "somebot-command", "auto_complete": True, "auto_complete_hint": "['help'|<[count]shortcut>]", } - USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Buy a drink." + USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = AbstractCommand.ICON_PRIVATE+"Buy a drink." def __init__(self, team_id, drink_terminal_user, drink_terminal_pass): @@ -38,7 +38,7 @@ class CommandDrink(AbstractCommand): msg = ":arrow_right: Available credits:``"+str(account_data["account_info"]["balance"])+"``" except MCAPI.APIException as e: if e.message == "CERR_AUTH_FAIL_INVALID_token": - request.cmd_respond_text_temp(cleandoc(""" + request.respond_cmd_temp(cleandoc(""" :stop_sign: Mattermost account seems to not be bound to any drink-terminal account. :( Use ``/drink-bind-account `` to bind this Mattermost account to your drink-terminal account. """)) @@ -52,7 +52,7 @@ class CommandDrink(AbstractCommand): for s in account_data["shortcuts"]: if int(s["vislevel"]) >= 2: msg += "\n|"+s["short"]+"|"+s["amount"]+"|"+s["description"]+"|" - request.cmd_respond_text_temp(msg) + request.respond_cmd_temp(msg) return count = None @@ -60,7 +60,7 @@ class CommandDrink(AbstractCommand): mat = re.match(r"(\d*)\s*(\w+)", cmd) if mat is None: - request.cmd_respond_text_temp(msg+"\n:stop_sign: Invalid input: Nothing useful matched.") + request.respond_cmd_temp(msg+"\n:stop_sign: Invalid input: Nothing useful matched.") return (count, sc) = mat.groups() @@ -70,7 +70,7 @@ class CommandDrink(AbstractCommand): count = int(count) if count < 1: - request.cmd_respond_text_temp(msg+"\n:stop_sign: Invalid input: count < 1") + request.respond_cmd_temp(msg+"\n:stop_sign: Invalid input: count < 1") return for s in account_data["shortcuts"]: @@ -79,7 +79,7 @@ class CommandDrink(AbstractCommand): break if shortcut is None: - request.cmd_respond_text_temp(msg+"\n:stop_sign: Invalid input: no such shortcut :(\nUse ``/drink-shortcuts`` for a list of shortcuts.") + request.respond_cmd_temp(msg+"\n:stop_sign: Invalid input: no such shortcut :(\nUse ``/drink-shortcuts`` for a list of shortcuts.") return else: handle.do_transaction(shortcut["target"], str(int(shortcut["amount"])*count), shortcut["reason"]) @@ -88,9 +88,10 @@ class CommandDrink(AbstractCommand): # Infcoin-IPC self.bot.modules[self.TEAM_ID]["inf-coin"].award_infcoins(data["user_id"], 100, "drink-use, ts="+str(datetime.datetime.now().replace(microsecond=0).isoformat())) - msg = (":arrow_right:Available credits:``"+str(account_data["account_info"]["balance"])+"``"+ - "\n:white_check_mark: Sucessfully paid **``"+str(int(shortcut["amount"])*count)+"``** TO **``"+str(shortcut["target"])+"``** FOR **``"+str(shortcut["reason"])+"``** :beers:") self.bot.debug_chan("``/drink success: @"+data["user_name"]+' --'+str(int(shortcut["amount"])*count)+'--> '+str(shortcut["target"])+'``') + request.respond_cmd_temp("## :white_check_mark: Success! :)\n:arrow_right:Available credits:``"+str(account_data["account_info"]["balance"])+"``"+ + "\n:white_check_mark: Sucessfully paid **``"+str(int(shortcut["amount"])*count)+"``** TO **``"+str(shortcut["target"])+"``** FOR **``"+str(shortcut["reason"])+"``** :beers:" + ) except MCAPI.APIException as e: if e.message == "CERR_AUTH_FAIL_ACCTOK": @@ -99,4 +100,4 @@ class CommandDrink(AbstractCommand): elif e.message == "CERR_FAILED_TO_SEND": msg += "\n:stop_sign: Failed to send drink-credits. Balance exceeded? Sending too much? :(\nTried to send **``"+str(int(shortcut["amount"])*count)+"``** TO **``"+str(shortcut["target"])+"``** FOR **``"+str(shortcut["reason"])+"``**" - request.cmd_respond_text_temp(msg) + request.respond_cmd_err(msg) -- 2.43.0