seems like your bot isnt flagging msg as processed, making it rehandle them again. try to adjust the handler so once a msg is dealt with it won’t rerun it in a loop. also check your db updates
The issue might be related to the fact that your script doesn’t mark messages as processed after they’ve been handled. In my experience, when a message is repeatedly fetched without an update to its status, it ends up being processed again, causing a loop. I encountered similar behavior and solved it by updating the database to flag the broadcast as completed immediately after processing. This also helped prevent any concurrent processing issues. Additionally, reviewing the control flow to ensure there is a proper exit after command execution is beneficial in avoiding recursive calls or unintended repeats.
I faced a similar problem where messages were processed multiple times because the state wasn’t being updated correctly. In my implementation, messages were being re-read from the database until they were manually cleared. I resolved this by introducing a flag that marked each message as processed immediately after handling it. Additionally, I incorporated error handling that ensured incomplete processes wouldn’t trigger multiple iterations. This approach helped in stopping the endless loop and provided a means of tracking the state of each message effectively.
i think your code isnt stopping after processing the command. you need to flag or exit immediatly, otherwise the broadcast keeps getting picked up. small details like that can cause a looping issue.