pyrogram:对于等待app.get_history(chat,limit = 1)的味精:attributeError:' client'对象没有属性' get_history'
import time
import pyrogram
app = pyrogram.Client("my_account", api_id=********,
api_hash="***********ffe01e582ef")
@app.on_message(pyrogram.filters.command('start', prefixes='.') & pyrogram.filters.me)
async def sms(_, msg):
with app:
public = await app.get_chat('@public_name')
chat = public.id
while True:
for msg in await app.get_history(chat, limit=1):
if msg.text == 'Menu:':
await app.send_message(chat, '1')
else:
await app.send_message(chat, '2')
break
time.sleep(2)
app.run()
我在VScode和他的工作中运行此代码。但是,如果我尝试在Debian 10中运行这个,我有一个
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试更新pyrogram并尝试使用以下方式:get_chat_history()
文档:
Try to update pyrogram and try using this: get_chat_history()
Documentation:
https://docs.pyrogram.org/api/methods/get_chat_history?highlight=history#pyrogram.Client.get_chat_history
我面临着同样的问题。
PROMPROMPROMPON版本1.4.15已在本地安装,并且在其中使用了“ app.get_history(gat_id)”方法。
当我将Proragram更新为2.0.62版本时,我遇到了一个错误:“'客户端'对象没有属性'get_history'”。
错误,因为新版本需要“ get_chat_history”方法。
文档:
https://docs.pyrgram.orgags.org/api/methods/methods/get_chat_chat_history
usage USAGE USAGE示例:
https://docs.pyrgram.org/start/start/start/examples/get_chat_history
我希望这些建议将有用。
I'm facing the same problem.
Pyrogram version 1.4.15 was installed locally and the "app.get_history(chat_id)" method worked in it.
When I updated the Pyrogram to version 2.0.62 I got an error: "'Client' object has no attribute 'get_history'".
Error because the new version requires the "get_chat_history" method.
Documentation:
https://docs.pyrogram.org/api/methods/get_chat_history
Usage example:
https://docs.pyrogram.org/start/examples/get_chat_history
I hope the advice will be useful.