You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
518 B
18 lines
518 B
from pyrogram.errors import RPCError
|
|
|
|
from .client import get_client
|
|
from .models import Chat, AggregationSource
|
|
|
|
|
|
def aggregation_source_deleted(sender, instance: AggregationSource, **kwargs):
|
|
if not AggregationSource.objects.filter(chat_id=instance.chat_id):
|
|
Chat.objects.filter(chat_id=instance.chat_id).delete()
|
|
|
|
|
|
def chat_deleted(sender, instance: Chat, **kwargs):
|
|
with get_client() as client:
|
|
try:
|
|
client.leave_chat(instance.chat_id)
|
|
except RPCError:
|
|
pass
|