prost: harden code against unicode input problems
This commit is contained in:
parent
798b339b4b
commit
e7009406c6
1 changed files with 20 additions and 17 deletions
|
|
@ -8,8 +8,11 @@ def init(bot):
|
||||||
bot.on_message(handle)
|
bot.on_message(handle)
|
||||||
|
|
||||||
|
|
||||||
|
vs16 = "\ufe0f" # see https://en.wikipedia.org/wiki/Variation_Selectors_%28Unicode_block%29
|
||||||
emojis = {
|
emojis = {
|
||||||
"☕️",
|
e.rstrip(vs16)
|
||||||
|
for e in {
|
||||||
|
"☕",
|
||||||
"🍵",
|
"🍵",
|
||||||
"🍶",
|
"🍶",
|
||||||
"🍷",
|
"🍷",
|
||||||
|
|
@ -25,11 +28,11 @@ emojis = {
|
||||||
"🥤",
|
"🥤",
|
||||||
"🧃",
|
"🧃",
|
||||||
"🧉",
|
"🧉",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def handle(message: Message):
|
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
|
is_drinkmoji = message.text.rstrip(vs16) in emojis
|
||||||
if not (message.tokens.str(0).startswith("PR!") or is_drinkmoji):
|
if not (message.tokens.str(0).startswith("PR!") or is_drinkmoji):
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue