Example #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?"))
Example #2
0
    def enable(bot: Bot, update: Update, args: List[str]):
        chat = update.effective_chat  # type: Optional[Chat]
        user = update.effective_user
        spam = spamfilters(update.effective_message.text,
                           update.effective_message.from_user.id,
                           update.effective_chat.id)
        if spam == True:
            return update.effective_message.reply_text(
                "Saya kecewa dengan anda, saya tidak akan mendengar kata-kata anda sekarang!"
            )

        conn = connected(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":
                update.effective_message.reply_text(
                    "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 = "Diaktifkan penggunaan `{}` pada *{}*".format(
                        enable_cmd, chat_name)
                else:
                    text = "Diaktifkan penggunaan `{}`".format(enable_cmd)
                update.effective_message.reply_text(
                    text, parse_mode=ParseMode.MARKDOWN)
            else:
                update.effective_message.reply_text(
                    "Apakah itu bahkan dinonaktifkan?")

        else:
            update.effective_message.reply_text(
                "Apa yang harus saya aktifkan?")