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())
# 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"
("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):