diff --git a/django_telethon/admin.py b/django_telethon/admin.py index 209212a..f75f9f3 100644 --- a/django_telethon/admin.py +++ b/django_telethon/admin.py @@ -97,5 +97,3 @@ class SentFileAdmin(admin.ModelAdmin): ] raw_id_fields = ['client_session'] list_filter = ['client_session__name'] - - diff --git a/django_telethon/rabbitmq.py b/django_telethon/rabbitmq.py index 6f9f9d5..f255669 100644 --- a/django_telethon/rabbitmq.py +++ b/django_telethon/rabbitmq.py @@ -6,13 +6,16 @@ from django_telethon.default_settings import ( QUEUE_CALLBACK_FN, QUEUE_CHANNEL_NAME, - RABBITMQ_URL, RABBITMQ_ACTIVE, + RABBITMQ_ACTIVE, + RABBITMQ_URL, ) + __all__ = [ "send_to_telegra_thread", ] + async def process_message(message: aio_pika.IncomingMessage): try: async with message.process(): @@ -39,10 +42,9 @@ def send_to_telegra_thread(**payload): connection = pika.BlockingConnection(parameters) channel = connection.channel() - # Ensure the queue exists. You might want to move this outside the function if you know the queue already exists. channel.queue_declare(queue=QUEUE_CHANNEL_NAME, durable=True) byte_payload = str(payload).encode('utf-8') - # Send the message + channel.basic_publish( exchange='', routing_key=QUEUE_CHANNEL_NAME,