Example #1
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_id = conn
            chat_name = dispatcher.bot.getChat(conn).title
        else:
            if update.effective_message.chat.type == "private":
                send_message(
                    update.effective_message,
                    languages.tl(
                        update.effective_message,
                        "Anda bisa lakukan command ini pada grup, bukan pada PM"
                    ))
                return ""
            chat = update.effective_chat
            chat_id = update.effective_chat.id
            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 = languages.tl(
                        update.effective_message,
                        "Menonaktifkan penggunaan `{}` pada *{}*").format(
                            disable_cmd, chat_name)
                else:
                    text = languages.tl(
                        update.effective_message,
                        "Menonaktifkan penggunaan `{}`").format(disable_cmd)
                send_message(update.effective_message,
                             text,
                             parse_mode=ParseMode.MARKDOWN)
            else:
                send_message(
                    update.effective_message,
                    languages.tl(update.effective_message,
                                 "Perintah itu tidak bisa dinonaktifkan"))

        else:
            send_message(
                update.effective_message,
                languages.tl(update.effective_message,
                             "Apa yang harus saya nonaktifkan?"))
Example #2
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?")
Example #3
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, disable_cmd)
                update.effective_message.reply_text(
                    tld(chat.id, "disable_success").format(disable_cmd),
                    parse_mode=ParseMode.MARKDOWN)
            else:
                update.effective_message.reply_text(
                    tld(chat.id, "disable_err_undisableable"))

        else:
            update.effective_message.reply_text(
                tld(chat.id, "disable_err_no_cmd"))
Example #4
0
 def __import_data__(chat_id, data):
     disabled = data.get('disabled', {})
     for disable_cmd in disabled:
         sql.disable_command(chat_id, disable_cmd)