Telethon没有重新连接

时间:2018-01-07 14:54:07

标签: python telegram telethon

使用第一个代码运行会创建一个会话文件并运行它。使用此文件运行第二个代码,会话将无法正常工作。

第一个代码

import telethon
from telethon import tl
from telethon import TelegramClient
import logging

def update_handler(update_object):
    print(update_object)
phone_number='*'
client = telethon.TelegramClient('sweet',api_id = *,api_hash = '*')
client.connect()
print('connected')
if not client.is_user_authorized():
    client.send_code_request(phone_number)
    me = client.sign_in(phone_number, input('Enter code: '))
print(client.get_me())
print(me.stringify())

输出:

连接

输入验证码:85813

用户(is_self =真,接触=真,mutual_contact =假,缺失=假,BOT =假,bot_chat_history =假,bot_nochats =假,验证=假,限制=假,最小值=假,bot_inline_geo =假,ID = ,access_hash = - ,如first_name = ' - ',姓氏=无,用户名=无,电话= '*',照片=无,状态= UserStatusOnline(到期= datetime.utcfromtimestamp(1515302772)) ,bot_info_version =无,restriction_reason =无,bot_inline_placeholder =无,lang_code =无)

用户(is_self =真,接触=真,mutual_contact =假,缺失=假,BOT =假,bot_chat_history =假,bot_nochats =假,验证=假,限制=假,最小值=假,bot_inline_geo =假,ID = ,access_hash = - ,如first_name = ' - ',姓氏=无,用户名=无,电话= '*',照片=无,状态= UserStatusOnline(到期= datetime.utcfromtimestamp(1515302772)) ,bot_info_version =无,restriction_reason =无,bot_inline_placeholder =无,lang_code =无)

第二个代码

import telethon
from telethon import tl
from telethon import TelegramClient
import logging

def update_handler(update_object):
    print(update_object)
phone_number='**'
client = telethon.TelegramClient('sweet',api_id = *,api_hash = '*')
client.connect()
print('connected')
print(client.get_me())

输出:

None

0 个答案:

没有答案