]> git.aero2k.de Git - urlbot-v3.git/commitdiff
let tokenizer forward domains at least partially
authorThorsten <mail@aero2k.de>
Sat, 11 Apr 2020 15:36:43 +0000 (17:36 +0200)
committerThorsten <mail@aero2k.de>
Sat, 11 Apr 2020 15:36:43 +0000 (17:36 +0200)
distbot/bot/bot.py
distbot/plugins/youtube.py
tests/test_unit/test_amqp_routing_key.py

index f47e8c9256e915e0894d432df29d0376774603f9..768d0500c60c82b20b73dd758b3a13d40ca0dce1 100644 (file)
@@ -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())
index c0db98a5e58f0af1cb971110d0673927f0e0965d..0587a8fbf77cdd04f00deef3264295cd3cfc95c3 100644 (file)
@@ -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"
 
index 87d67f51fa8ae31ef1adca9cfdbed8f2cefc8f0c..a0e5f2acdfabf744b12d4e9067c8430f6b1efb59 100644 (file)
@@ -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):