})
)
+ def get_amqp_routing_key(self, msg):
+ # simplify the key significantly
+ key = shlex.split(re.sub(r'[^a-zäöüß0-9 "\']', '', msg["body"].lower()))
+ if not key:
+ # simple dots, smilies, emoji shit, pass through
+ key = shlex.split(msg["body"].lower())
+
+ # cut the nick from the message
+ if self.nick.lower() in key[0].lower():
+ if msg["body"][0] == '>':
+ key.pop(0)
+ key.insert(0, "quoted_nick")
+ else:
+ key.pop(0)
+ key.insert(0, "nick")
+ routing_key = '.'.join(key)[:254]
+ return routing_key
+
def message(self, msg):
logger.debug("msg is " + str(msg))
logger.debug("from: " + str(msg['from']))
self.initialize_actionthreads()
self.echo("Worker One available for master.")
- # simplify the key significantly
- key = shlex.split(re.sub(r'[^a-zäöüß0-9 "\']', '', msg["body"].lower()))
- if not key:
- # simple dots, smilies, emoji shit, pass through
- key = shlex.split(msg["body"].lower())
-
- # cut the nick from the message
- offset = 0
- if self.nick.lower() in key[0].lower():
- if message[0] == '>':
- key.pop(0)
- key.insert(0, "quoted_nick")
- else:
- key.pop(0)
- key.insert(0, "nick")
- offset = message.find(self.nick) + len(self.nick) + 1
+ routing_key = self.get_amqp_routing_key(msg)
if msg["type"] == "groupchat":
recipient = msg["mucroom"]
else:
recipient = msg["from"].jid
+ offset = msg["body"].find(self.nick) + len(self.nick) + 1
process_message(
- routing_key='.'.join(key)[:255],
+ routing_key=routing_key,
body=json.dumps({
"from": msg["from"].jid,
"to": recipient,