]> git.aero2k.de Git - urlbot-v3.git/commitdiff
fixes for pika incompatible upgrade
authorThorsten <mail@aero2k.de>
Sat, 12 Nov 2022 14:34:03 +0000 (15:34 +0100)
committerThorsten <mail@aero2k.de>
Sat, 12 Nov 2022 14:34:03 +0000 (15:34 +0100)
distbot/bot/action_worker.py
distbot/bot/bot.py
distbot/bot/worker.py
distbot/plugins/plugin_help.py
setup.py

index a57d47c34ee6fdba55e6ea0cf1ed31773d7139a5..8ea11d197c9bef3a460fb39df8228962dc4b0944 100644 (file)
@@ -64,7 +64,8 @@ class ActionWorker(object):
         logger.info('Issuing consumer related RPC commands')
         # self.add_on_cancel_callback()
         self._consumer_tag = self._channel.basic_consume(
-            self.on_message, self._queue_name
+            queue=self._queue_name,
+            on_message_callback=self.on_message
         )
         logger.info("Setup consumer for actions on ch %s on con %s with tag %s", self._channel, self._connection,
                      self._consumer_tag)
index ab311914a7999f38c48a5b1696472198fc3f706b..bfc7401396df3c77f51a32b34468786fcd59aaed 100644 (file)
@@ -5,7 +5,7 @@ import re
 import shlex
 
 import pika
-from pika.adapters import AsyncioConnection
+from pika.adapters.asyncio_connection import AsyncioConnection
 
 import slixmpp
 from distbot.bot import action_worker
index 7aad677504420205d67296660914aa1bb4f9c619..ccd1f4106690357a4fecaab6f6adc2b86b0bb5d1 100644 (file)
@@ -101,7 +101,7 @@ class Worker(threading.Thread):
         self.channel.stop_consuming()
 
     def run(self):
-        result = self.channel.queue_declare(exclusive=True)
+        result = self.channel.queue_declare(exclusive=True, queue="")
         self.queue = result.method.queue
 
         for binding_key in self.binding_keys:
@@ -112,7 +112,7 @@ class Worker(threading.Thread):
                 routing_key=binding_key
             )
 
-        self.channel.basic_consume(self.callback, queue=self.queue)
+        self.channel.basic_consume(queue=self.queue, on_message_callback=self.callback)
         self.channel.start_consuming()
 
     def parse_body(self, msg):
@@ -126,7 +126,7 @@ class Worker(threading.Thread):
         channel.basic_publish(
             exchange='',
             routing_key='plugin_registry',
-            body=json.dumps(self.get_declaration())
+            body=json.dumps(self.get_declaration()).encode("utf-8")
         )
 
     def get_declaration(self):
index ff0e26a421088fb3984ef6d5bdea1dde6dced590..fd5aad1935e11ea344726dcb0a1a40414cf09e5a 100644 (file)
@@ -28,15 +28,15 @@ class Plugins(Worker):
     plugin_storage = {}
     reverse_lookup = {}
 
-    def __init__(self, actionqueue, queue="work"):
+    def __init__(self, actionqueue, queue=""):
         super(Plugins, self).__init__(actionqueue, queue)
         self.channel.exchange_declare(exchange='plugin_exc', exchange_type='fanout')
 
     def run(self):
-        result = self.channel.queue_declare(exclusive=True)
+        result = self.channel.queue_declare(exclusive=True, queue=self.queue)
         plugin_queue = result.method.queue
         self.channel.queue_bind(exchange='plugin_exc', queue=plugin_queue)
-        self.channel.basic_consume(self.callback_plugins, queue='plugin_registry')
+        self.channel.basic_consume(queue='plugin_registry', on_message_callback=self.callback_plugins)
         super(Plugins, self).run()
 
     def callback_plugins(self, ch, method, properties, body):
index ae96beb8102732603b475120d07c29bdfddd57f8..d0cea7ed331351c6b4e7b56fec38134103b07619 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -2,9 +2,9 @@ from setuptools import setup, find_packages
 
 setup(
     name="distbot",
-    version=0.1,
+    version="0.1",
     description="the distributed bot",
-    install_requires=["pika==0.12.0", 'configobj', 'requests'],
+    install_requires=["pika", 'configobj', 'requests'],
     test_requires=["pytest"],
     extras_require={
         'test': ["pytest"],