pylakey/aiotdlib

Got false events API.Types.UPDATE_DELETE_MESSAGES

alega19 opened this issue · 0 comments

UPD: it's not a bug.
python 3.10
aiotdlib==0.19.2 (installed via pip install)
I created channel, subscribed the account on it via official desktop client.
After that I sent some messages to the channel via desktop client and saw coresponding logs (see logs below except last two lines).

However, in some minutes (~1-3) I got logs that some messages were deleted (see last two lines in logs below). But I did not delete them (yes, I am the only subscriber of my channel). Moreover I see these messages via desktop client - the ones are still there in the channel.
That happens also with other channels. I subscribed on two foreign ones and watch the same bug: false events about removed message.
What is going on? Bug? How to fix it?

Code:

#skip import section

async def run(account):
    proxy_settings = aiotdlib.ClientProxySettings(
        host=account.proxy.host,
        port=account.proxy.port,
        type=aiotdlib.ClientProxyType.SOCKS5,
        username=account.proxy.username,
        password=account.proxy.password,
    )
    client = aiotdlib.Client(
        account.api_id,
        account.api_hash,
        phone_number=account.phone
        application_version=account.app_version,
        device_model=account.device_model,
        system_version=account.system_version,
        proxy_settings=proxy_settings,
    )
    client.add_event_handler(message_published, update_type=aiotdlib.api.API.Types.UPDATE_NEW_MESSAGE)
    client.add_event_handler(message_edited, update_type=aiotdlib.api.API.Types.UPDATE_MESSAGE_EDITED)
    client.add_event_handler(messages_deleted, update_type=aiotdlib.api.API.Types.UPDATE_DELETE_MESSAGES)  # <--

    try:
        async with client:
            logger.info("I am online")
            while True:
                await asyncio.sleep(0.1)  # is copy of client.idle()
    finally:
        logger.info("I am offline")


async def message_published(client: aiotdlib.Client, update: aiotdlib.api.UpdateNewMessage):
    logger.info("message published, chat-id=%s id=%s", update.message.chat_id, update.message.id)


async def message_edited(client: aiotdlib.Client, update: aiotdlib.api.UpdateMessageEdited):
    logger.info("message edited, chat-id=%s id=%s", update.chat_id, update.message_id)


async def messages_deleted(client: aiotdlib.Client, update: aiotdlib.api.UpdateDeleteMessages):
    logger.info("messages deleted, chat-id=%s ids=%s", update.chat_id, update.message_ids)  # <---!!!


if __name__ == '__main__':
    account = create_account()
    asyncio.run(run(account))

Logs:

INFO:Client:Starting client
INFO:Client:Session workdir: /opt/app/.aiotdlib/ee552dc7070b5f06a8e82920d5c2cd55
INFO:Client:Authorization process has been started with phone
INFO:Client:Sending encryption key
INFO:Client:Setting up option disable_persistent_network_statistics = True
INFO:Client:Setting up option disable_sent_scheduled_message_notifications = True
INFO:Client:Setting up option disable_time_adjustment_protection = True
INFO:Client:Setting up option ignore_inline_thumbnails = True
INFO:Client:Setting up option ignore_platform_restrictions = True
INFO:Client:Setting up option is_location_visible = False
INFO:Client:Setting up option use_storage_optimizer = True
INFO:Client:Retrieving all proxies list
INFO:Client:Authorization is completed
INFO:tg: I am online
INFO:tg: message published, chat-id=-1001535328871 id=52428800
INFO:tg: message published, chat-id=-1001535328871 id=53477376
INFO:tg: message published, chat-id=-1001535328871 id=54525952
INFO:tg: message published, chat-id=-1001535328871 id=55574528
INFO:tg: message published, chat-id=-1001535328871 id=56623104
INFO:tg: message published, chat-id=-1001535328871 id=57671680
INFO:tg: message published, chat-id=-1001535328871 id=58720256
INFO:tg: message published, chat-id=-1001535328871 id=59768832
INFO:tg: message published, chat-id=-1001535328871 id=60817408
INFO:tg: message published, chat-id=-1001535328871 id=61865984
INFO:tg: message published, chat-id=-1001535328871 id=62914560
INFO:tg: message published, chat-id=-1001535328871 id=63963136
INFO:tg: messages deleted, chat-id=-1001535328871 ids=[51380224]
INFO:tg: messages deleted, chat-id=-1001535328871 ids=[52428800, 53477376, 54525952, 55574528, 56623104, 57671680, 58720256, 59768832, 60817408, 61865984, 62914560]```