telethon

how i can restore sessions old in telethon telegram and connect this again(without send again code))

a 夏天 提交于 2019-12-04 02:09:40
问题 i use this script for connect and create sessions in telethon from telethon import TelegramClient from telethon.tl.functions.messages import GetHistoryRequest from telethon.utils import get_input_peer api_id = 7**** api_hash = 'ef584d*****************' client = TelegramClient('+15159947451', api_id, api_hash) client.connect() if not client.is_user_authorized(): client.send_code_request('+15159947451') client.sign_in('+15159947451', cod) with this cod i can login good in this number telegram

RuntimeError: Task got Future <Future pending> attached to a different loop

一世执手 提交于 2019-12-02 13:11:05
How to call async method which get event loop in main thread inside another async method in Quart? t.py from telethon import TelegramClient, functions, types client2 = TelegramClient(sn, api_id, api_hash).start() async def create_contact(): return await client2(functions.contacts.ImportContactsRequest([ types.InputPhoneContact(0, '8', 'first_name', 'last_name') ])) app.py from quart import Quart, websocket,render_template,request import t2 app = Quart(__name__) @app.route('/wa2tg') def wa2tg(): return render_template('wa2tg.html',nm=request.args.get('nm','')) @app.websocket('/wa2tg2') async

Add new contact in api telegram python telethon

若如初见. 提交于 2019-12-01 17:50:48
How do I save a number in my contacts in telethon python? from telethon import TelegramClient from telethon.tl.functions.contacts import GetContactsRequest from telethon.tl.types import InputPeerUser client = TelegramClient('arta0', api_id, api_hash) client.connect() #number=+19133704541 #name='ali karimi' What module do I need to add contact? You can create a contact like this: contact = InputPhoneContact(client_id = 0, phone = "+12345678", first_name="ABC", last_name="abc") result = client.invoke(ImportContactsRequest([contact], replace=True)) To create a new contact you need to pass 0 for

how i can restore sessions old in telethon telegram and connect this again(without send again code))

一曲冷凌霜 提交于 2019-12-01 12:11:11
i use this script for connect and create sessions in telethon from telethon import TelegramClient from telethon.tl.functions.messages import GetHistoryRequest from telethon.utils import get_input_peer api_id = 7**** api_hash = 'ef584d*****************' client = TelegramClient('+15159947451', api_id, api_hash) client.connect() if not client.is_user_authorized(): client.send_code_request('+15159947451') client.sign_in('+15159947451', cod) with this cod i can login good in this number telegram and create file:+15159947451.session. now i close and disconnect, how i can again login this number with