-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved regex and added Lithuanian keywords for Baltic heart
- Loading branch information
1 parent
908c357
commit 7288fc1
Showing
5 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from re import compile, IGNORECASE, UNICODE | ||
|
||
POSSIBLE_REACTS = ( | ||
"<:tw_baltics_heart:1132524940587962388>", | ||
"<:bubblemilktea:1132632348651966596>", | ||
) | ||
|
||
KEYWORDS = ( | ||
# Lithuanian | ||
"Taivanas", | ||
"Taivane", | ||
"Taivano", | ||
"Taivanui", | ||
"Taivanietis", | ||
"Taivanietė", | ||
"Taivaniečiai", | ||
"Taivaniečių", | ||
"Taivaniečiui", | ||
"Taivaniečiams", | ||
"Taivanietiškas", | ||
"Taivana" | ||
# Latvian | ||
# Estonian | ||
) | ||
|
||
|
||
BALTIC_REGEX = compile(rf"({'|'.join(KEYWORDS)})", flags=IGNORECASE | UNICODE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import discord | ||
import random | ||
from .consts import POSSIBLE_REACTS, BALTIC_REGEX | ||
|
||
|
||
def is_baltic_message(message: discord.Message): | ||
return BALTIC_REGEX.search(message.content) | ||
|
||
|
||
def mock_bernoulli(p: float) -> bool: | ||
"""Returns True with probability p. | ||
Args: | ||
p (float): a float between 0 and 1. | ||
Returns: | ||
bool: True or False. | ||
""" | ||
return random.random() < p | ||
|
||
|
||
async def send_react_baltic(message: discord.Message): | ||
for react in POSSIBLE_REACTS: | ||
if mock_bernoulli(0.69): | ||
await message.add_reaction(react) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters