LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
10.01k stars 1.41k forks source link

NewMessageListener - fired multiple times #4462

Open rush0815 opened 2 months ago

rush0815 commented 2 months ago

Code that causes the issue

´´'from telethon import TelegramClient, events, sync

api_id = "yyyyy" api_hash = "xxxxxxx" client = TelegramClient('me', api_id, api_hash) clientCommander = TelegramClient('commander', api_id, api_hash)

@client.on(events.NewMessage(chats = inputCmdChannel)) async def NewMessageListener(event): msg = event.message.message

´´´

Expected behavior

I expected, that this function will only be fired once per received new message. So, if the inputCmdChannel has already messages in it and I start the python program, nothing should happen until I send a new message.

Actual behavior

Currently NewMessageListener sometime is fired multiple times and process one or two older messages that are allready in the inputCmdChannel.

Traceback

No response

Telethon version

36.0

Python version

3.10.12

Operating system (including distribution name and version)

Debian 12.2

Other details

No response

Checklist

takabinance commented 1 month ago

Have a similar issue where same new message is being sent a number of times and then today I just got a flood of messages that were months old. Will add a max id check by channel to try to deal with it.