pyrogram:对于等待app.get_history(chat,limit = 1)的味精:attributeError:' client'对象没有属性' get_history'

发布于 2025-02-09 11:18:34 字数 772 浏览 1 评论 0 原文

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中运行这个,我有一个

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()

i run this code in vscode and his work. but if i try to run this in debian 10 i have this one

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白日梦 2025-02-16 11:18:34

尝试更新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

坦然微笑 2025-02-16 11:18:34

我面临着同样的问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文