-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cb4b1fd915
committed
Dec 4, 2023
1 parent
f4f1d35
commit 078858e
Showing
2 changed files
with
51 additions
and
22 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 |
---|---|---|
@@ -1,21 +1,37 @@ | ||
import urllib.parse | ||
|
||
|
||
TRIGGERS = {'jest moze', 'jest może', 'czy jest', 'czy mamy', 'mamy może', 'mamy moze', 'może mamy', 'moze mamy'} | ||
TRIGGERS = { | ||
"jest moze", | ||
"jest może", | ||
"czy jest", | ||
"czy mamy", | ||
"mamy może", | ||
"mamy moze", | ||
"może mamy", | ||
"moze mamy", | ||
} | ||
|
||
|
||
def czymamy(message: str) -> str | None: | ||
url = None | ||
hsl_phrases = ('w spejse', 'w spejsie', 'w hackerspejsie', 'w hs-ie', 'w hs', 'w hsie', ) | ||
null_phrases = ('jakiś', 'jakis', 'może', 'moze', 'mamy') | ||
text = message.lower().split('?')[0].strip() | ||
if '?' in message and any(map(lambda x: x in text, hsl_phrases)): | ||
replacements = ('jakiś') | ||
hsl_phrases = ( | ||
"w spejse", | ||
"w spejsie", | ||
"w hackerspejsie", | ||
"w hs-ie", | ||
"w hs", | ||
"w hsie", | ||
) | ||
null_phrases = ("jakiś", "jakis", "może", "moze", "mamy") | ||
text = message.lower().split("?")[0].strip() | ||
if "?" in message and any(map(lambda x: x in text, hsl_phrases)): | ||
replacements = "jakiś" | ||
for item in TRIGGERS: | ||
text = text.replace(item, '') | ||
text = text.replace(item, "") | ||
for item in hsl_phrases: | ||
text = text.replace(item, '') | ||
text = text.replace(item, "") | ||
for item in null_phrases: | ||
text = text.replace(item, '') | ||
url = 'https://g.hs-ldz.pl/search?query=' + urllib.parse.quote(text.strip()) | ||
text = text.replace(item, "") | ||
url = "https://g.hs-ldz.pl/search?query=" + urllib.parse.quote(text.strip()) | ||
return url |
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