Add test_server_dedup

This commit is contained in:
blank X 2021-11-11 21:15:52 +07:00
parent b4f3a06ee5
commit 3cd21e6065
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
from collections import defaultdict
from pyrogram import Client, filters
from .. import config, log_errors
if config['telegram'].get('use_test_servers'):
messages_seen = defaultdict(lambda: defaultdict(set))
@Client.on_message(~filters.scheduled & ~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me, group=-5)
@log_errors
async def test_server_deduper(client, message):
try:
messages_seen[client][message.chat.id].remove(message.message_id)
except KeyError:
messages_seen[client][message.chat.id].add(message.message_id)
else:
message.stop_propagation()