skip to Main Content
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

2

Answers


  1. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search