You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am sure the error is coming from Pyrogram's code and not elsewhere
I have searched in the issue tracker for similar bug reports, including closed ones
I ran pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip and reproduced the issue using the latest development version
Description
I have a bot that responds to user messages, I recently discovered a problem that I didn’t pay attention to, now it’s a critical error for my project
Steps to reproduce
the user sent a message to my bot, the bot responded to it, after which the handler accepted the same message again and responded to it a second time
Code example
importosfrompyrogramimportfilters, Clientfromdotenvimportload_dotenvfromclasses.TgmHandlersimportTgmHandlersfromclasses.UtilsimportUtilsload_dotenv()
os.environ["OPENAI_API_KEY"] =os.getenv("OPENAI_API_KEY")
db_dsn=os.getenv("DSN")
api_id=os.getenv("API_ID_TG")
api_hash=os.getenv("HASH_ID_TG")
app=Client(name="me_client2", api_id=api_id, api_hash=api_hash)
# text message from user@app.on_message(filters.text)asyncdefmessage(app, message):
tgm_handlers=TgmHandlers(app, message)
try:
awaittgm_handlers.on_text_message()
exceptExceptionase:
ifstr(e).startswith("Could not parse LLM output: `"):
response=str(e).removeprefix("Could not parse LLM output: `").removesuffix("`")
awaitapp.send_message(tgm_handlers.USERNAME, response)
else:
print(f"We got a error: {e}")
rand_phrase=Utils().get_rand_phrase_of_clarify()
awaitapp.send_message(tgm_handlers.USERNAME, rand_phrase)
# in tgm_handlers.on_text_message() work this code:awaitchat_manager.chat_bot(all_messages)
# and chat_manager.chot_bot(all_messages) code:asyncdefchat_with_neural_manager(self, user_message):
response=self.llm_chain(user_message).invoke(input=user_message)
awaitself.app.send_message(self.username, response["output"])
Logs
For example:
Client: Hello, how much products you have?
(waiting +-10sec)
Bot: Hello! I have 2 products: programming and design
(in here handler get message from client again: Hello, how much products you have? waiting +-10sec)
Bot: Hello! I have 2 products: programming and design
The text was updated successfully, but these errors were encountered:
Checklist
pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip
and reproduced the issue using the latest development versionDescription
I have a bot that responds to user messages, I recently discovered a problem that I didn’t pay attention to, now it’s a critical error for my project
Steps to reproduce
the user sent a message to my bot, the bot responded to it, after which the handler accepted the same message again and responded to it a second time
Code example
Logs
The text was updated successfully, but these errors were encountered: