作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我重新激活了“旧”机器人并收到此错误:
telethon\utils.py", line 138, in _raise_cast_fail
raise TypeError('Cannot cast {} to any kind of {}.'.format(
TypeError: Cannot cast coroutine to any kind of Peer.
经过一番尝试...我发现在功能中进行白名单聊天时会出现此错误:
@bot.on(events.NewMessage(chats=bot.get_entity(config_group),pattern='/hello'))
async def hello(event):
我的解决方法是:
@bot.on(events.NewMessage(pattern='/hello'))
async def hello(event):
if int(event.chat_id) == int(config_group):
它有效,但能持续多久?我想知道我是否做错了什么? (我的意思是在白名单参数中,该函数不会等待 - 如果这就是原因)但它在一周前起作用,所以......
谢谢您的帮助:)
最佳答案
ID和用户名可以传递给chats=参数,Telethon将自动获取实体。
@bot.on(events.NewMessage(chats=chat_id, pattern='/hello'))
async def hello(event):
# do your things
就您遇到的错误而言,get_entity
返回协程,因此必须等待它。
>> TypeError: Cannot cast coroutine to any kind of Peer.
关于Telethon 无法再获取聊天实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64929717/
我有本地更改和远程更改。 有人告诉我必须先推,再 pull 。这背后有什么原因吗? 最佳答案 那个人错了:正确的模型是pull-before-you-push,而不是相反。 当您pull时,git 将
我正在使用最新版本的 Flat UI Pro 1.3.2 ( http://designmodo.com/flat/ ),jQuery 插件 flatui-radiocheck v0.1.0 和 iO
我是一名优秀的程序员,十分优秀!