RuntimeError: There is no current event loop in thread 'WorkerThread1'.
вот мой код:
import telebot, sqlite3, requests, time
from telebot import types
from datetime import datetime
# -*- coding: utf-8 -*-
from telethon import TelegramClient, events, sync
from telethon.tl.types import InputPhoneContact
from telethon import functions, types
import random, string
client = TelegramClient()
client.connect()
if not client.is_user_authorized():
client.send_code_request('')
client.sign_in('+1214', input('Enter code: '))
TOKEN =
bot = telebot.TeleBot(TOKEN)
def sex(message):
num = message.text
randoma = random.choice(string.ascii_letters)
randomb = random.choice(string.ascii_letters)
contact = InputPhoneContact(client_id = 0, phone = num, first_name=randoma, last_name=randomb)
contacts = client(functions.contacts.ImportContactsRequest([contact]))
username = contacts.to_dict()['users'][0]['username']
bot.send_message(message.chat.id, f'@{username}')
@bot.message_handler(content_types=['text'])
def referer(message):
a = bot.send_message(message.chat.id, '''отправь мне номер: ''')
bot.register_next_step_handler(a, sex)
while True:
try:
bot.infinity_polling(interval=0)
except:
bot.infinity_polling(interval=0)