From 2c3d1e5fa0fb655fe95cad13a5fe40eb3ce391ae Mon Sep 17 00:00:00 2001 From: Thorsten Date: Sat, 11 Apr 2020 17:36:43 +0200 Subject: [PATCH] let tokenizer forward domains at least partially --- distbot/bot/bot.py | 2 +- distbot/plugins/youtube.py | 4 ++-- tests/test_unit/test_amqp_routing_key.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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): -- 2.39.2