From f2465a5523e4c0f5d682318442f00d046a44bf61 Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 10 Jan 2022 17:27:25 +0100 Subject: [PATCH] modules/CommandJoinActive.py --- modules/CommandJoinActive.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/CommandJoinActive.py b/modules/CommandJoinActive.py index 9899c93..53a0e1f 100644 --- a/modules/CommandJoinActive.py +++ b/modules/CommandJoinActive.py @@ -6,6 +6,9 @@ import datetime import threading from inspect import cleandoc +import logging +logger = logging.getLogger(__name__) + # pylint: disable=wrong-import-position from AbstractCommand import AbstractCommand class CommandJoinActive(AbstractCommand): @@ -13,7 +16,7 @@ class CommandJoinActive(AbstractCommand): CONFIG = {"display_name": "somebot-command", "auto_complete": True, "auto_complete_hint": "[]" } - USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Join active public channels. active = '10 posts+ in the last x months'. There is no undo." + USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = AbstractCommand.ICON_PRIVATE+"Join active public channels. active = '10 posts+ in the last x months'. There is no undo." def __init__(self, team_id, skip_chann_ids): @@ -34,10 +37,10 @@ class CommandJoinActive(AbstractCommand): def _index_channels(self): if self.channel_index_th != threading.current_thread(): - print("_index_channels(): thread mismatch") + logger.warning("_index_channels(): thread mismatch") return - print("_index_channels(): started") + logger.info("_index_channels(): started") new_dict = dict() for c in self.bot.api.get_team_channels(self.TEAM_ID): if c["id"] in self.skip_chann_ids: @@ -58,12 +61,12 @@ class CommandJoinActive(AbstractCommand): self.channel_index_th.setName("CommandJoinActive::_index_channels()") self.channel_index_th.setDaemon(True) self.channel_index_th.start() - print("_index_channels(): done") + logger.info("_index_channels(): done") def on_POST(self, request, data): if self.channel_index is None: - request.cmd_respond_text_temp("### ``Failed`` :(\nThe channel indexer didnt finish yet. try again in a few minutes") + request.respond_cmd_err("``/"+self.TRIGGER+"`` The channel indexer didnt finish yet. try again in a few minutes") return try: @@ -80,8 +83,8 @@ class CommandJoinActive(AbstractCommand): self.bot.api.add_user_to_channel(c["id"], data["user_id"]) msg += "\n + ~"+c["name"] - request.cmd_respond_text_temp(cleandoc(""" - ### ``Done`` :) + request.respond_cmd_temp(cleandoc(""" + ## :white_check_mark: Success! :) By default it wont join you into channels that had less than 5 messages posted within the last 2 weeks. If you want to be joined into less active channels give the command an integer number of weeks to to consider. /join-active 8 will join you into channels that had less than 5 messages posted within the last 2 months. -- 2.43.0