Esempio n. 1
0
    def disable(bot: Bot, update: Update, args: List[str]):
        chat = update.effective_chat  # type: Optional[Chat]
        if len(args) >= 1:
            disable_cmd = args[0]
            if disable_cmd.startswith(CMD_STARTERS):
                disable_cmd = disable_cmd[1:]

            if disable_cmd in set(DISABLE_CMDS + DISABLE_OTHER):
                sql.disable_command(chat.id, disable_cmd)
                update.effective_message.reply_text(
                    "Disabled the use of `{}`".format(disable_cmd),
                    parse_mode=ParseMode.MARKDOWN)
            else:
                update.effective_message.reply_text(
                    "That command can't be disabled")

        else:
            update.effective_message.reply_text("What should I disable?")
Esempio n. 2
0
    def disable_module(bot: Bot, update: Update, args: List[str]):

        chat = update.effective_chat
        if len(args) >= 1:

            disable_module = "tg_bot.modules." + args[0].rsplit(".", 1)[0]

            try:
                module = importlib.import_module(disable_module)
            except:
                update.effective_message.reply_text("Does that module even exist?")
                return

            try:
                command_list = module.__command_list__
            except:
                update.effective_message.reply_text("Module does not contain command list!")
                return

            disabled_cmds = []
            failed_disabled_cmds = []

            for disable_cmd in command_list:
                if disable_cmd.startswith(CMD_STARTERS):
                    disable_cmd = disable_cmd[1:]

                if disable_cmd in set(DISABLE_CMDS + DISABLE_OTHER):
                    sql.disable_command(chat.id, str(disable_cmd).lower())
                    disabled_cmds.append(disable_cmd)
                else:
                    failed_disabled_cmds.append(disable_cmd)
            
            if disabled_cmds:
                disabled_cmds_string = ", ".join(disabled_cmds)
                update.effective_message.reply_text("Disabled the uses of `{}`".format(disabled_cmds_string),
                                                        parse_mode=ParseMode.MARKDOWN)
            
            if failed_disabled_cmds:
                failed_disabled_cmds_string = ", ".join(failed_disabled_cmds)
                update.effective_message.reply_text("Commands `{}` can't be disabled".format(failed_disabled_cmds_string),
                                                    parse_mode=ParseMode.MARKDOWN)

        else:
            update.effective_message.reply_text("What should I disable?")
Esempio n. 3
0
    def disable(update, context):
        chat = update.effective_chat  # type: Optional[Chat]
        user = update.effective_user
        args = context.args

        conn = connected(context.bot, update, chat, user.id, need_admin=True)
        if conn:
            chat = dispatcher.bot.getChat(conn)
            chat_name = dispatcher.bot.getChat(conn).title
        else:
            if update.effective_message.chat.type == "private":
                send_message(
                    update.effective_message,
                    "This command meant to be used in group not in PM",
                )
                return ""
            chat = update.effective_chat
            chat_name = update.effective_message.chat.title

        if len(args) >= 1:
            disable_cmd = args[0]
            if disable_cmd.startswith(CMD_STARTERS):
                disable_cmd = disable_cmd[1:]

            if disable_cmd in set(DISABLE_CMDS + DISABLE_OTHER):
                sql.disable_command(chat.id, disable_cmd)
                if conn:
                    text = "Disabled the use of `{}` command in *{}*!".format(
                        disable_cmd, chat_name)
                else:
                    text = "Disabled the use of `{}` command!".format(
                        disable_cmd)
                send_message(
                    update.effective_message,
                    text,
                    parse_mode=ParseMode.MARKDOWN,
                )
            else:
                send_message(update.effective_message,
                             "This command can't be disabled")

        else:
            send_message(update.effective_message, "What should I disable?")
Esempio n. 4
0
    def disable(bot: Bot, update: Update, args: List[str]):
        chat = update.effective_chat  # type: Optional[Chat]
        if len(args) >= 1:
            disable_cmd = args[0]
            if disable_cmd.startswith(CMD_STARTERS):
                disable_cmd = disable_cmd[1:]

            if disable_cmd in set(DISABLE_CMDS + DISABLE_OTHER):
                sql.disable_command(chat.id, disable_cmd)
                update.effective_message.reply_text(
                    "استفاده از دستور `{}` غیرفعال شد!".format(disable_cmd),
                    parse_mode=ParseMode.MARKDOWN)
            else:
                update.effective_message.reply_text(
                    "اومم این دستور غیر فعال نمیشه")

        else:
            update.effective_message.reply_text(
                "کدوم دستورو میخوای غیر فعال کنم؟")
Esempio n. 5
0
    def disable(bot: Bot, update: Update, args: List[str]):
        chat = update.effective_chat  # type: Optional[Chat]
        if len(args) >= 1:
            disable_cmd = args[0]
            if disable_cmd.startswith(CMD_STARTERS):
                disable_cmd = disable_cmd[1:]

            if disable_cmd in set(DISABLE_CMDS + DISABLE_OTHER):
                sql.disable_command(chat.id, disable_cmd)
                update.effective_message.reply_text(
                    "Kullanımını devre dışı bıraktı `{}`".format(disable_cmd),
                    parse_mode=ParseMode.MARKDOWN)
            else:
                update.effective_message.reply_text(
                    "Bu komut devre dışı bırakılamaz")

        else:
            update.effective_message.reply_text(
                "Neyi devre dışı bırakmalıyım??")
Esempio n. 6
0
    def disable(bot: Bot, update: Update, args: List[str]):
        chat = update.effective_chat  # type: Optional[Chat]
        if len(args) >= 1:
            disable_cmd = args[0]
            if disable_cmd.startswith(CMD_STARTERS):
                disable_cmd = disable_cmd[1:]

            if disable_cmd in set(DISABLE_CMDS + DISABLE_OTHER):
                sql.disable_command(chat.id, disable_cmd)
                update.effective_message.reply_text(
                    "Disabilito il comando `{}`".format(disable_cmd),
                    parse_mode=ParseMode.MARKDOWN,
                )
            else:
                update.effective_message.reply_text(
                    "Questo comando non può essere disabilitato")

        else:
            update.effective_message.reply_text("Cosa dovrei disabilitare?")
Esempio n. 7
0
    def disable(update, context):
        chat = update.effective_chat  # type: Optional[Chat]
        args = context.args
        if len(args) >= 1:
            disable_cmd = args[0]
            if disable_cmd.startswith(CMD_STARTERS):
                disable_cmd = disable_cmd[1:]

            if disable_cmd in set(DISABLE_CMDS + DISABLE_OTHER):
                sql.disable_command(chat.id, disable_cmd)
                update.effective_message.reply_text(tld(
                    chat.id, "Disabled the use of `{}`").format(disable_cmd),
                                                    parse_mode='markdown')
            else:
                update.effective_message.reply_text(
                    tld(chat.id, "That command can't be disabled"))

        else:
            update.effective_message.reply_text(
                tld(chat.id, "What should I disable?"))
Esempio n. 8
0
    def disable(bot: Bot, update: Update, args: List[str]):
        chat = update.effective_chat
        if len(args) >= 1:
            disable_cmd = args[0]
            if disable_cmd.startswith(CMD_STARTERS):
                disable_cmd = disable_cmd[1:]

            if disable_cmd in set(DISABLE_CMDS + DISABLE_OTHER):
                sql.disable_command(chat.id, str(disable_cmd).lower())
                update.effective_message.reply_text(
                    f"Disabled the use of `{disable_cmd}`",
                    parse_mode=ParseMode.MARKDOWN,
                )
            else:
                update.effective_message.reply_text(
                    "Perintah itu tidak dapat dinonaktifkan")

        else:
            update.effective_message.reply_text(
                "Apa yang harus saya nonaktifkan?")
Esempio n. 9
0
 def __import_data__(chat_id, data):
     disabled = data.get("disabled", {})
     for disable_cmd in disabled:
         sql.disable_command(chat_id, disable_cmd)