From: Thorsten Date: Sat, 11 Apr 2020 15:36:43 +0000 (+0200) Subject: let tokenizer forward domains at least partially X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=2c3d1e5fa0fb655fe95cad13a5fe40eb3ce391ae;p=urlbot-v3.git let tokenizer forward domains at least partially --- diff --git a/distbot/bot/bot.py b/distbot/bot/bot.py index f47e8c9..768d050 100644 --- a/distbot/bot/bot.py +++ b/distbot/bot/bot.py @@ -111,7 +111,7 @@ class Bot(sleekxmpp.ClientXMPP): def get_amqp_routing_key(nick, msg): # simplify the key significantly offset = 0 - key = shlex.split(re.sub(r'[^a-zäöüß0-9 "\']', '', msg["body"].lower())) + 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()) diff --git a/distbot/plugins/youtube.py b/distbot/plugins/youtube.py index c0db98a..0587a8f 100644 --- a/distbot/plugins/youtube.py +++ b/distbot/plugins/youtube.py @@ -12,8 +12,8 @@ class Youtube(Worker): # approach 2 (without key): https://www.youtube.com/oembed?url=http://youtube.com/watch?v={YOUTUBE_VIDEO_ID}&format=json """ binding_keys = [ - "*.youtube.com.*", "*.youtu.be.*", - "*.youtube.com.*.nospoiler.*", "*.youtu.be.*.nospoiler.*", + "#.youtube.#", "#.youtu.#", + "#.youtube.#.nospoiler.#", "#.youtu.#.nospoiler.#", ] description = "resolves titles of posted youtube URLs" diff --git a/tests/test_unit/test_amqp_routing_key.py b/tests/test_unit/test_amqp_routing_key.py index 87d67f5..a0e5f2a 100644 --- a/tests/test_unit/test_amqp_routing_key.py +++ b/tests/test_unit/test_amqp_routing_key.py @@ -13,7 +13,7 @@ from distbot.bot.bot import Bot ("schrottbot", "> schrottbot: make me happy", b"quoted_nick.make.me.happy", 13), ("schrottbot", "> schrottbot, make me happy", b"quoted_nick.make.me.happy", 13), ("schrottbot", "> schrottbot make me happy", b"quoted_nick.make.me.happy", 13), - ("schrottbot", "https://docs.pytest.org/en/latest/warnings.html", b"httpsdocspytestorgenlatestwarningshtml", 0), + ("schrottbot", "https://docs.pytest.org/en/latest/warnings.html", b"httpsdocs.pytest.orgenlatestwarnings.html", 0), ] ) def test_get_amqp_routing_key(nick, message, expected_key, expected_offset):