Exemplo n.º 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...?')
Exemplo n.º 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...?')
Exemplo n.º 3
0
def echo_all(message):
    while True:
        try:
            try:
                user_id = msg.getUserID(message)
                message = message
                text = message.text
                msg_check = msg.msgCheck(message)
                ticket_status = mysql.user_tables(user_id)['open_ticket']
                banned_status = mysql.user_tables(user_id)['banned']

                if banned_status == 1:
                    # If User is banned - un-ban user and sent message
                    mysql.unban_user(user_id)
                    bot.reply_to(
                        message,
                        'ℹ️ *FYI: That user was banned.*\n_Un-banned and sent message!_',
                        parse_mode='Markdown')

                elif ticket_status == 1:
                    # Reset Open Tickets as well as the Spamfilter
                    mysql.reset_open_ticket(user_id)
                    continue

                else:
                    if message.reply_to_message and '(#id' in msg_check:
                        msg.snd_handler(user_id, bot, message, text)
                        return

            except telebot.apihelper.ApiException:
                bot.reply_to(
                    message,
                    '❌ I was unable to send that message...\nThe user might\'ve blocked me.'
                )
                return

        except Exception as e:
            bot.reply_to(message, '❌ Invalid command!')
            return