prost: harden code against unicode input problems

This commit is contained in:
ducklet 2020-11-07 19:53:36 +01:00
parent 798b339b4b
commit e7009406c6

View file

@ -8,8 +8,11 @@ def init(bot):
bot.on_message(handle)
vs16 = "\ufe0f" # see https://en.wikipedia.org/wiki/Variation_Selectors_%28Unicode_block%29
emojis = {
"☕️",
e.rstrip(vs16)
for e in {
"",
"🍵",
"🍶",
"🍷",
@ -26,10 +29,10 @@ emojis = {
"🧃",
"🧉",
}
}
async def handle(message: Message):
vs16 = "\ufe0f" # see https://en.wikipedia.org/wiki/Variation_Selectors_%28Unicode_block%29
is_drinkmoji = message.text.rstrip(vs16) in emojis
if not (message.tokens.str(0).startswith("PR!") or is_drinkmoji):
return