telethon - telethon如何使用登录代码请求呼叫
问题描述
由于我正在编写一个客户端,我的美国朋友注意到代码不通过短信,而只是通过电话。但我不明白该怎么做,如何请求电话(
await client.connect()
code_settings = types.CodeSettings(
current_number=True,
allow_flashcall=False,
allow_app_hash=False
)
result = await client(functions.auth.SendCodeRequest(
phone_number=phone,
api_id=api_id,
api_hash=api_hash,
settings=code_settings
))
# time.sleep(10)
result = await client(functions.auth.ResendCodeRequest(
phone_number=phone,
phone_code_hash=result.phone_code_hash
))
# time.sleep(20)
result = await client(functions.auth.ResendCodeRequest(
phone_number=phone,
phone_code_hash=result.phone_code_hash
))
# result = await client(SentCodeTypeCall(5))
# result = await client(functions.auth.)
while not isinstance(result.type, SentCodeTypeCall):
# time.sleep(10)
result = await client(functions.auth.ResendCodeRequest(
phone_number=phone,
phone_code_hash=result.phone_code_hash
))
# time.sleep(20)
# await client(functions.auth.SendCodeRequest(
# phone_number=phone,
# api_id=api_id,
# api_hash=api_hash,
# settings=code_settings
# ))
def code_callback():
code = input('Please enter the code you received: ')
return code
time.sleep(5)
await client.start(phone=phone, code_callback=code_callback)
我认为这不是正确的代码。
我可以告诉 SendCode Request 方法立即调用而不发送 SMS 吗?
解决方案
推荐阅读
- php - 如何在 WooCommerce 产品页面中添加用户输入字段
- mysql - 在 macOS 上通过 brew 安装时如何卸载 MySQL 5.6?
- unit-testing - 在辅助函数中包装 httptest 方法
- java - 按日期分组 - jpa2 - postgres
- jquery - 在文本 select2 中添加新文本
- kubernetes - 如何删除 kube-proxy 添加的 iptables 规则?
- java - 如何在 Jmeter 中的两个线程组之间共享 JSessionID
- julia - 如何检查我当前的系统映像中可以使用哪些 cpu 功能?
- java - 我有一个多线程 JAVA 应用程序在具有 N 个内核的 CPU 上运行(在 Linux 上)但是它只使用第 0 个内核,其余内核处于空闲状态
- java - 执行 grep 和简单 rhdfs 命令时出现 R 致命错误