Skip to content

NewMessageListener - fired multiple times #4462

@rush0815

Description

@rush0815

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

  • The error is in the library's code, and not in my own.
  • I have searched for this issue before posting it and there isn't an open duplicate.
  • I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip and triggered the bug in the latest version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions