key.insert(0, "nick")
offset = msg["body"].find(nick) + len(nick) + 1
routing_key = '.'.join(key).encode("UTF-8")[:255]
-
+ logging.debug(f"Routing key for message {msg['body']} -> {routing_key}")
return offset, routing_key
def message(self, msg):
})
)
- def echo(self, body, recipient=None):
+ def echo(self, body: str, recipient: str = None):
logger.debug("echo: %s", body)
if not recipient:
rooms = self.rooms
"""
import logging
+import re
import traceback
import unicodedata
from distbot.bot.worker import Worker
from distbot.common.action import Action
-from distbot.common.config import conf_get
from distbot.common.message import get_nick_from_message, get_words
return Action(msg='{}: something failed: {}'.format(sender, e))
if short:
- return Action(msg=sender + ': %s (<%s>)' % (
- short if short.strip() else '(nix)', link
- ))
+ text = re.sub(r"(\\n|\s)+", " ", short) if short.strip() else '(nix)'
+ return Action(msg=sender + ': %s (<%s>)' % (text, link))
elif 'missing' in page:
return Action(msg='Article "%s" not found' % page.get('title', query))
else: