Example #1
0
def ot_handler(message):
    try:
        if message.chat.id == config.support_chat:
            if message.reply_to_message and '(#id' in msg.msgCheck(message):
                user_id = msg.getUserID(message)
                banned_status = mysql.user_tables(user_id)['banned']

                if banned_status == 0:
                    bot.reply_to(message,
                                 '❌ That user is already un-banned...')
                else:
                    mysql.unban_user(user_id)
                    bot.reply_to(message, '✅ Ok, un-banned that user!')

            elif msg.getReferrer(message.text):
                user_id = int(msg.getReferrer(message.text))
                banned_status = mysql.user_tables(user_id)['banned']

                if banned_status == 0:
                    bot.reply_to(message,
                                 '❌ That user is already un-banned...')
                else:
                    mysql.unban_user(user_id)
                    bot.reply_to(message, '✅ Ok, un-banned that user!')
            else:
                bot.reply_to(
                    message,
                    'ℹ️ You\'d have to either reply to a message or mention an `Users ID`.',
                    parse_mode='Markdown')
    except TypeError:
        bot.reply_to(message,
                     '❌ Are you sure I interacted with that user before...?')
Example #2
0
def ot_handler(message):
    try:
        if message.chat.id == config.support_chat:
            if message.reply_to_message and '(#id' in msg.msgCheck(message):
                user_id = msg.getUserID(message)
                banned_status = mysql.user_tables(user_id)['banned']

                if banned_status == 1:
                    bot.reply_to(message, '❌ That user is already banned...')
                else:
                    mysql.ban_user(user_id)
                    try:
                        # Reset Open Tickets as well as the Spamfilter
                        mysql.reset_open_ticket(user_id)
                    except Exception as e:
                        pass
                    bot.reply_to(message, '✅ Ok, banned that user!')

            elif msg.getReferrer(message.text):
                user_id = int(msg.getReferrer(message.text))
                banned_status = mysql.user_tables(user_id)['banned']

                if banned_status == 1:
                    bot.reply_to(message, '❌ That user is already banned...')
                else:
                    mysql.ban_user(user_id)
                    try:
                        # Reset Open Tickets as well as the Spamfilter
                        mysql.reset_open_ticket(user_id)
                    except Exception as e:
                        pass
                    bot.reply_to(message, '✅ Ok, banned that user!')
        else:
            bot.reply_to(
                message,
                'ℹ️ You\'d have to either reply to a message or mention an `Users ID`.',
                parse_mode='Markdown')
    except TypeError:
        bot.reply_to(message,
                     '❌ Are you sure I interacted with that user before...?')