Beispiel #1
0
    def enable(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:
            enable_cmd = args[0]
            if enable_cmd.startswith(CMD_STARTERS):
                enable_cmd = enable_cmd[1:]

            if sql.enable_command(chat.id, enable_cmd):
                if conn:
                    text = languages.tl(
                        update.effective_message,
                        "Diaktifkan penggunaan `{}` pada *{}*").format(
                            enable_cmd, chat_name)
                else:
                    text = languages.tl(
                        update.effective_message,
                        "Diaktifkan penggunaan `{}`").format(enable_cmd)
                send_message(update.effective_message,
                             text,
                             parse_mode=ParseMode.MARKDOWN)
            else:
                send_message(
                    update.effective_message,
                    languages.tl(update.effective_message,
                                 "Apakah itu bahkan dinonaktifkan?"))

        else:
            send_message(
                update.effective_message,
                languages.tl(update.effective_message,
                             "Apa yang harus saya aktifkan?"))
Beispiel #2
0
    def enable(bot: Bot, update: Update, args: List[str]):
        chat = update.effective_chat  # type: Optional[Chat]
        if len(args) >= 1:
            enable_cmd = args[0]
            if enable_cmd.startswith(CMD_STARTERS):
                enable_cmd = enable_cmd[1:]

            if sql.enable_command(chat.id, enable_cmd):
                update.effective_message.reply_text(
                    "Enabled the use of `{}`".format(enable_cmd),
                    parse_mode=ParseMode.MARKDOWN)
            else:
                update.effective_message.reply_text("Is that even disabled?")

        else:
            update.effective_message.reply_text("What should I enable?")
Beispiel #3
0
    def enable(bot: Bot, update: Update, args: List[str]):
        chat = update.effective_chat
        if len(args) >= 1:
            enable_cmd = args[0]
            if enable_cmd.startswith(CMD_STARTERS):
                enable_cmd = enable_cmd[1:]

            if sql.enable_command(chat.id, enable_cmd):
                update.effective_message.reply_text(
                    tld(chat.id, "disable_enable_success").format(enable_cmd),
                    parse_mode=ParseMode.MARKDOWN)
            else:
                update.effective_message.reply_text(
                    tld(chat.id, "disable_already_enabled"))

        else:
            update.effective_message.reply_text(
                tld(chat.id, "disable_err_no_cmd"))