channel is something entirely different than routing key... technically, at least
self.usage = "{}: {}".format(conf_get("bot_nickname"), "|".join(set(cmds)))
else:
self.usage = "(reaction only)"
- self.used_channel = None
+ self.used_routing_key = None
self.connection: Optional[pika.BlockingConnection] = None
self.channel = None
logger.debug("Reacting on %s in %s", str(method.routing_key), self.get_subclass_name())
body = json.loads(body.decode("utf-8"))
try:
- self.used_channel = method.routing_key.split(".")
+ self.used_routing_key = method.routing_key.split(".")
except TypeError as e:
logging.error("%s is of type %s", str(method.routing_key), type(method.routing_key))
logging.exception(e)
- self.used_channel = ["__error__"]
+ self.used_routing_key = ["__error__"]
if self.uses_history:
self.history = self.total_history[body["to"]]
def parse_body(self, msg):
words = get_words(msg)
sender = get_nick_from_message(msg)
- sudo = 'sudo' in self.used_channel
+ sudo = 'sudo' in self.used_routing_key
if sudo:
words.pop(0) # remove sudo from args
sudoers = conf_get('sudoers') or []
uses_history = True
def parse_body(self, msg):
- if self.history and 'repeat' in self.used_channel:
+ if self.history and 'repeat' in self.used_routing_key:
return Action(msg=self.history[-1]["body"])
description = "machines don't like the doctor."
def parse_body(self, msg):
- if "doctor" in self.used_channel:
+ if "doctor" in self.used_routing_key:
return Action(msg="EXTERMINATE! EXTERMINATE!")
else:
return Action(msg="ELIMINIEREN! ELIMINIEREN!")
def parse_body(self, msg):
sender = get_nick_from_message(msg)
words = get_words(msg)[1:]
- if not words or "decode" not in self.used_channel:
+ if not words or "decode" not in self.used_routing_key:
return
logger.debug('decode called for %s' % words[0])
out = []
def parse_body(self, msg):
# TODO not totally true regarding task and rate limiting
- if "info" in self.used_channel:
+ if "info" in self.used_routing_key:
return Action(msg=f""": I'm a bot named {conf_get('bot_nickname')}, my job is to extract <title> tags from posted URLs. In case I'm annoying or for further
questions, please talk to my master {conf_get('bot_owner')}. I'm rate limited.
To make me exit immediately, highlight me with 'hangup' in the message
words = get_words(msg)
sender = get_nick_from_message(msg)
- if not ("morse-decode" in self.used_channel or "morse-encode" in self.used_channel):
+ if not ("morse-decode" in self.used_routing_key or "morse-encode" in self.used_routing_key):
return
- if self.used_channel[2] == "that" and self.history:
+ if self.used_routing_key[2] == "that" and self.history:
message = self.history[-1]["body"]
else:
message = " ".join(words[1:])
- if self.used_channel[1] == "morse-decode":
+ if self.used_routing_key[1] == "morse-decode":
return Action(msg="{}: {}".format(sender, morse_decode(message)))
else:
return Action(msg="{}: {}".format(sender, morse_encode(message)))
def parse_body(self, msg):
words = get_words(msg)
- cmd = self.used_channel
+ cmd = self.used_routing_key
sender = get_nick_from_message(msg)
if cmd[0] == "userjoin":
return Action(msg=msg)
def parse_body(self, msg):
- bind = self.used_channel
+ bind = self.used_routing_key
if bind[1] == "help":
plugin_name = None
if len(bind) > 2:
from distbot.plugins.fun import Doctor
doc = Doctor("_")
- doc.used_channel = ["call", "the", "doctor"]
+ doc.used_routing_key = ["call", "the", "doctor"]
assert Action(msg="EXTERMINATE! EXTERMINATE!") == doc.parse_body({"msg": "call the doctor!"})
- doc.used_channel = ["der", "doktor", "hat", "gleich", "zeit"]
+ doc.used_routing_key = ["der", "doktor", "hat", "gleich", "zeit"]
assert Action(msg="ELIMINIEREN! ELIMINIEREN!") == doc.parse_body({"msg": "der Doktor hat gleich zeit."})