Example #1
0
def cmd_format(message):
    bot.reply_to(message, 'Formato inválido')
    # bot.reply_to(message, ('<a href="tg://user?id={}">{}</a>').format(message.from_user.id, message.from_user.first_name), parse_mode='HTML')
    send_clean_msg(bot, message.from_user.id,
                   msgs.invalid.format(message.from_user.id))
    log_text(message.chat.id, message.message_id, 'Formato inválido')
    print(message)
Example #2
0
def cmd_pacotes(message):
    bot.send_chat_action(message.chat.id, 'typing')
    if str(message.from_user.id) in BANNED:
        log_text(message.chat.id, message.message_id,
                 '--- BANIDO --- ' + message.text)
        bot.send_message(message.chat.id, msgs.banned)
        return 0
    chatid = message.chat.id
    message, qtd = list_packages(chatid, False, False)
    if qtd == 0:
        send_clean_msg(bot, chatid, msgs.not_found)
    elif qtd == -1:
        send_clean_msg(bot, chatid, msgs.error_bot)
    else:
        message = '<b>Clique para ver o histórico:</b>\n' + message
        msg_split = message.split('\n')
        for elem in range(0, len(msg_split), 10):
            s = '\n'
            bot.send_message(chatid,
                             s.join(msg_split[elem:elem + 10]),
                             parse_mode='HTML',
                             reply_markup=markup_clean,
                             disable_web_page_preview=True)
        if qtd > 7 and chatid > 0:
            bot.send_message(chatid,
                             str(u'\U0001F4B5') + '<b>Colabore!</b>' +
                             '\nPicPay: http://grf.xyz/picpay' +
                             '\nPayPal: http://grf.xyz/paypal' +
                             '\nPatreon: http://grf.xyz/patreon',
                             parse_mode='HTML',
                             reply_markup=markup_clean,
                             disable_web_page_preview=True)
Example #3
0
def cmd_pacotes(message):
    bot.send_chat_action(message.chat.id, 'typing')
    chatid = message.chat.id
    message, qtd = list_packages(chatid, False, False)
    if qtd == 0:
        send_clean_msg(bot, chatid, msgs.not_found)
    elif qtd == -1:
        send_clean_msg(bot, chatid, msgs.error_bot)
    else:
        message = '<b>Clique para ver o histórico:</b>\n' + message
        msg = message
        msg_split = message.split('\n')
        for elem in range(0, len(msg_split), 10):
             s = '\n'
             bot.send_message(chatid,
                 s.join(msg_split[elem:elem+10]), parse_mode='HTML',
                 reply_markup=markup_clean)
Example #4
0
def cmd_magic(message):
    bot.send_chat_action(message.chat.id, 'typing')
    if str(message.from_user.id) in BANNED:
        log_text(message.chat.id, message.message_id,
                 '--- BANIDO --- ' + message.text)
        bot.send_message(message.chat.id, msgs.banned)
        return 0
    log_text(message.chat.id, message.message_id, message.text)
    user = str(message.chat.id)
    code = (str(message.text.strip().replace(
        '/start ', '').replace('\n', ' ').replace('/', '').upper().replace(
            '@RASTREIOBOT', '').replace('📮 ', '').replace('📮',
                                                          '').split(' ')[0]))
    try:
        desc = (str(
            message.text.replace('\n', ' ').split(
                ' ', 1)[1].split('Data:')[0].replace('  ', '')))
    except Exception:
        desc = code
    if check_type(code) is not None:
        sleep(random.randrange(500, 2000, 100) / 1000)
        exists = check_package(code)
        if exists:
            exists = check_user(code, user)
            if not exists:
                add_user(code, user)
            statts = status_package(code)
            message = ''
            system = check_system()
            for stat in statts:
                message = message + '\n\n' + stat
            if not system:
                message = (message + msgs.error_sys)
            if int(user) > 0:
                bot.send_message(user,
                                 message,
                                 parse_mode='HTML',
                                 reply_markup=markup_btn,
                                 disable_web_page_preview=True)
            else:
                send_clean_msg(bot, user, message)
            if desc != code:
                set_desc(str(code), str(user), desc)
        else:
            stat = add_package(str(code), str(user))
            if stat == status.OFFLINE:
                bot.reply_to(message, 'Correios fora do ar')
            elif stat == status.TYPO:
                bot.reply_to(message, msgs.typo)
            elif stat == status.NOT_FOUND:
                bot.reply_to(message, msgs.not_found)
            elif stat == status.OK:
                set_desc(str(code), str(user), desc)
                if int(message.chat.id) > 0:
                    bot.reply_to(message,
                                 'Pacote cadastrado.',
                                 reply_markup=markup_btn)
                    if desc == code:
                        send_clean_msg(bot, user, msgs.desc)
                else:
                    bot.reply_to(message,
                                 'Pacote cadastrado.',
                                 reply_markup=markup_clean)
                sttus = status_package(code)
                last = len(sttus) - 1
                if int(user) > 0:
                    bot.send_message(user,
                                     status_package(code)[last],
                                     parse_mode='HTML',
                                     reply_markup=markup_btn,
                                     disable_web_page_preview=True)
                else:
                    send_clean_msg(bot, user, status_package(code)[last])
    elif code == 'START':
        if int(message.chat.id) > 0:
            send_clean_msg(bot, message.chat.id, msgs.user)
            # bot.send_document(message.chat.id, 'CgADAQADhgAD45bBRvd9d-3ACM-cAg')
            # bot.send_document(message.chat.id, 'CgADAQADTAAD9-zRRl9s8doDwrMmAg')
            # bot.send_document(message.chat.id, 'CgADAQADPgADBm7QRkzGU7UpR3JzAg')
            bot.send_document(message.chat.id,
                              'CgADAQADWQADGu_QRlzGc4VIGIYaAg')
        else:
            send_clean_msg(bot, message.chat.id, msgs.group)
    else:
        if int(user) > 0:
            bot.reply_to(message, msgs.typo)
        if int(user) > 0 and len(message.text) > 25:
            send_clean_msg(bot, message.from_user.id,
                           msgs.invalid.format(message.from_user.id))
Example #5
0
def cmd_repetir(message):
    bot.send_chat_action(message.chat.id, 'typing')
    if int(message.chat.id) > 0:
        send_clean_msg(bot, message.chat.id, msgs.user)
    else:
        send_clean_msg(bot, message.chat.id, msgs.group)
Example #6
0
def cmd_magic(message):
    bot.send_chat_action(message.chat.id, 'typing')
    log_text(message.chat.id, message.message_id, message.text)
    user = str(message.chat.id)
    code = (
        str(message.text.replace('/start ', '').split(' ')[0])
        .replace('/', '').upper().replace('@RASTREIOBOT', '')
    )
    try:
        desc = str(message.text.split(' ', 1)[1])
    except Exception:
        desc = code
    if check_type(code) is not None:
        exists = check_package(code)
        if exists:
            exists = check_user(code, user)
            if not exists:
                add_user(code, user)
            statts = status_package(code)
            message = ''
            system = check_system()
            for stat in statts:
                message = message + '\n\n' + stat
            if not system:
                message = (message + msgs.error_sys)
            if int(user) > 0:
                bot.send_message(
                    user,
                    message,
                    parse_mode='HTML',
                    reply_markup=markup_btn
                )
            else:
                send_clean_msg(bot, user, message)
            if desc != code:
                set_desc(str(code), str(user), desc)
        else:
            stat = add_package(str(code), str(user))
            if stat == status.OFFLINE:
                bot.reply_to(message, 'Correios fora do ar')
            elif stat == status.TYPO:
                bot.reply_to(message, msgs.typo)
            elif stat == status.NOT_FOUND:
                bot.reply_to(message, msgs.not_found)
            elif stat == status.OK:
                set_desc(str(code), str(user), desc)
                if int(message.chat.id) > 0:
                    bot.reply_to(
                        message,
                        'Pacote cadastrado.',
                        reply_markup=markup_btn
                    )
                else:
                    bot.reply_to(
                        message,
                        'Pacote cadastrado.',
                        reply_markup=markup_clean
                    )
                sttus = status_package(code)
                last = len(sttus) - 1
                if int(user) > 0:
                    bot.send_message(
                        user,
                        status_package(code)[last],
                        parse_mode='HTML',
                        reply_markup=markup_btn
                    )
                else:
                    send_clean_msg(bot, user, status_package(code)[last])
    elif code == 'START':
        if int(message.chat.id) > 0:
            send_clean_msg(bot, message.chat.id, msgs.user)
        else:
            send_clean_msg(bot, message.chat.id, msgs.group)
    else:
        if int(user) > 0:
            bot.reply_to(message, msgs.typo)
Example #7
0
def cmd_magic(message):
    bot.send_chat_action(message.chat.id, 'typing')
    if str(message.from_user.id) in BANNED:
        log_text(message.chat.id, message.message_id,
                 '--- BANIDO --- ' + message.text)
        bot.send_message(message.chat.id, msgs.banned)
        return 0
    log_text(message.chat.id, message.message_id, message.text)
    user = str(message.chat.id)
    message_text = (message.text.replace('/start ', '').replace(
        '/', '').replace('📮', '').strip().split())

    code = code_type = None
    for word in message_text:
        if word.lower() == '@rastreiobot':
            message_text.remove(word)

        code_type = check_type(word)
        if code_type:
            code = word.upper()
            message_text.remove(word)
            break

    message_text = ' '.join(message_text)

    try:
        desc = message_text.split('Data:')[0].replace('  ', '')
        if desc == '':
            desc = code
    except Exception:
        desc = code

    if code_type:
        if code_type != correios and user not in PATREON:
            bot.reply_to(message, msgs.premium, parse_mode='HTML')
            log_text(message.chat.id, message.message_id,
                     'Pacote chines. Usuario nao assinante.')
            return 0
        exists = check_package(code)
        if exists:
            if not db.package_has_user(code, user):
                db.add_user_to_package(code, user)
            stats = db.package_status(code)
            message = ''
            system = check_system_correios()
            for stat in stats:
                message = message + '\n\n' + stat
            if not system:
                message = (message + msgs.error_sys)
            if int(user) > 0:
                bot.send_message(user,
                                 message,
                                 parse_mode='HTML',
                                 reply_markup=markup_btn,
                                 disable_web_page_preview=True)
            else:
                send_clean_msg(bot, user, message)
            if desc != code:
                db.set_package_description(code, user, desc)
        else:
            stat = add_package(str(code), str(user))
            if stat == status.OFFLINE:
                bot.reply_to(message, 'Sistema fora do ar')
            elif stat == status.TYPO:
                bot.reply_to(message, msgs.typo)
            elif stat == status.NOT_FOUND:
                bot.reply_to(message, msgs.not_found)
            elif stat == status.NOT_FOUND_TM:
                bot.reply_to(message, msgs.not_found_tm)
            elif stat == status.OK:
                db.set_package_description(code, user, desc)
                if int(message.chat.id) > 0:
                    bot.reply_to(message,
                                 'Pacote cadastrado.',
                                 reply_markup=markup_btn)
                    if desc == code:
                        send_clean_msg(bot, user, msgs.desc)
                else:
                    bot.reply_to(message,
                                 'Pacote cadastrado.',
                                 reply_markup=markup_clean)
                sttus = db.package_status(code)
                last = len(sttus) - 1
                if int(user) > 0:
                    bot.send_message(user,
                                     db.package_status(code)[last],
                                     parse_mode='HTML',
                                     reply_markup=markup_btn,
                                     disable_web_page_preview=True)
                else:
                    send_clean_msg(bot, user, db.package_status(code)[last])
    elif message.text.upper() == '/START':
        if int(message.chat.id) > 0:
            send_clean_msg(bot, message.chat.id, msgs.user)
            # bot.send_document(message.chat.id, 'CgADAQADhgAD45bBRvd9d-3ACM-cAg')
            # bot.send_document(message.chat.id, 'CgADAQADTAAD9-zRRl9s8doDwrMmAg')
            # bot.send_document(message.chat.id, 'CgADAQADPgADBm7QRkzGU7UpR3JzAg')
            bot.send_document(message.chat.id,
                              'CgADAQADWQADGu_QRlzGc4VIGIYaAg')
        else:
            send_clean_msg(bot, message.chat.id, msgs.group)
    else:
        if int(user) > 0:
            bot.reply_to(message, msgs.typo)
        if int(user) > 0 and len(message.text) > 25:
            send_clean_msg(bot, message.from_user.id,
                           msgs.invalid.format(message.from_user.id))