python - Telegram is having internal issues RpcCallFailError
问题描述
I'm trying to get the latest message from a telegram channel with telethon and the following code:
import t_api,time,asyncio
from telethon import TelegramClient
from telethon.tl.functions.messages import GetHistoryRequest
async def get_message():
license_b="allow"
flag=0
try:
async with TelegramClient(t_api.username,t_api.api_id,t_api.api_hash) as client:
my_channel=await client.get_entity("channel_name")
while license_b=="allow":
history=await client(GetHistoryRequest(peer=my_channel,offset_id=0,offset_date=None,add_offset=0,limit=1,max_id=0,min_id=0,hash=0))
t1=history.messages[0].message
if flag==0:
sub_t1=t1
flag+=1
if sub_t1!=t1:
flag=0
checking_b(t1)
time.sleep(2)
except:
return False
asyncio.run(get_message())
I have to use this method due to the delay of about 30 seconds in receiving messages via streaming channels with many members. And this code works well, but sometimes after a few hours, despite the try except function, program gets following error.
Telegram is having internal issues RpcCallFailError: Telegram is having internal issues, please try again later. (caused by GetHistoryRequest)
My question is how to prevent this error from occurring and how to handle it if it occurs, because try except dose not work. Someone can help me?
解决方案
推荐阅读
- postgresql - docker compose 与网络,连接 ECONNREFUSED
- javascript - 如何实现一个组件最初显示多个 div 元素,然后显示更多元素?
- ruby-on-rails - Rails:冲突错误覆盖/home/username/blog/.gitignore?
- ruby-on-rails - 在 React 中使用 multipart/form-data 时 Rails Controller 中缺少参数
- matlab - Matlab中查找工具箱功能的问题
- python - CSV's to Database with Pandas,编码错误
- javascript - 我对这个 JS 数组做错了什么?
- python - Python Flask - 请求对象即使已导入也不存在
- node.js - 将标头发送到客户端后无法设置标头-Sendgrid
- visual-studio-2019 - 使用 Razor 页面模板创建项目时收到错误