启动客户端时,代码要求电话/机器人令牌 [英] When starting client the code is asking for phone/bot token

查看:154
本文介绍了启动客户端时,代码要求电话/机器人令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 Telethon 库运行我的第一个代码时,它需要一个机器人令牌.

While running my first code using Telethon library, it is asking for a bot token.

这是实际代码:

from telethon import TelegramClient, events, sync
api_id = 1234567
api_hash = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
client = TelegramClient('anon', api_id, api_hash)
client.start()

在命令提示符下:

pip3 install telethon

python3 C:/TG/First.py

结果:

请输入您的电话(或机器人令牌)

Please enter your phone (or bot token)

如果我提供我的 API ID,它最终会抛出错误:

If I give my API ID, it eventually throws the error:

telethon.errors.rpcerrorlist.PhoneNumberInvalidError: 电话号码无效(由 SendCodeRequest 引起)

telethon.errors.rpcerrorlist.PhoneNumberInvalidError: The phone number is invalid (caused by SendCodeRequest)

为什么?我希望客户端启动时不会出错.

Why? I expect the client to start without errors.

PS:我的 API ID 是 7 位数字.

PS: my API ID is 7 digits long.

推荐答案

如错误消息所示,您的电话号码无效.也许你没有输入国际格式?

As the error message suggests, your phone number is invalid. Maybe you didn't enter it in international format?

这篇关于启动客户端时,代码要求电话/机器人令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆