pyrogram icon indicating copy to clipboard operation
pyrogram copied to clipboard

bot.get_messages() Error

Open PythonNoob999 opened this issue 2 years ago • 0 comments

Checklist

  • [X] I am sure the error is coming from Pyrogram's code and not elsewhere
  • [X] I have searched in the issue tracker for similar bug reports, including closed ones
  • [X] I ran pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip and reproduced the issue using the latest development version

Description

First we have the bot code

`from pyrogram import Client, filters from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery import asyncio

bot = Client("mytestbot") admin_buttons = [[InlineKeyboardButton("send_a_message", callback_data="send_a_message")]] @bot.on_message(filters.private) async def main(bot, message): if message.from_user.id == 929863209: await bot.send_message(message.chat.id, "Hello Admin", reply_markup=InlineKeyboardMarkup(admin_buttons)) else: await bot.send_message(message.chat.id, "Hello User")

@bot.on_callback_query() async def main2(bot, CallBack): chat = CallBack.message.chat.id data = CallBack.data if data == "send_a_message": reply1 = await bot.send_message(chat, "Send me a message to print it!") while (await bot.get_messages(chat, reply1.id+1)).empty == True: pass else: response1 = await bot.get_messages(chat, reply1.id+1) print(response1.text)

asyncio.run(bot.run()) `

That if a user is admin he get a button so he can send a message and print it in the terminal

But there's a problem, when the bot awaits the Admin messgae, he doesn't only listen for the response from the admin chat but all the bot chat, even with the chat_id for the admin

Example Dialogue: ` Bot = >> Terminal = >>>

Admin - /start

Hello Admin [send_a_message]Button

User - /start

Hello User

Admin - ButtonClick(send_a_message)

Send a message to print

User - "Hello World!"

Message Printed Successfully ✅

"Hello World!"

`

Steps to reproduce

get_messges() Bug

Code example

No response

Logs

No response

PythonNoob999 avatar Aug 26 '23 20:08 PythonNoob999