-
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.
- Loading branch information
1 parent
886473b
commit e9afaf3
Showing
3 changed files
with
76 additions
and
0 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 | ||
|
||
KEYWORDS_MEOW = ( | ||
'meow', | ||
'喵' | ||
) | ||
|
||
MEOW = '喵' | ||
TRADITIONAL_CAT = '貓' | ||
|
||
POSSIBLE_MEOW_REACTS = [ | ||
'<a:catArrive:1161441364869918881>', | ||
'<:Capoo:1139357657698938991>' | ||
] | ||
POSSIBLE_MEOW_MESSAGES = [ | ||
MEOW, | ||
TRADITIONAL_CAT, | ||
'瞄', | ||
'貓子孩女' | ||
'錨' | ||
] + POSSIBLE_MEOW_REACTS | ||
|
||
|
||
MEOW_REGEX = compile( | ||
rf"\b(?:{'|'.join(KEYWORDS_MEOW)})", | ||
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,47 @@ | ||
from random import choice, randint, shuffle | ||
import discord | ||
|
||
from commands.modules.probability import mock_bernoulli | ||
from .consts import MEOW, MEOW_REGEX, POSSIBLE_MEOW_MESSAGES, POSSIBLE_MEOW_REACTS, TRADITIONAL_CAT | ||
|
||
|
||
def is_meow_message(message: discord.Message): | ||
return MEOW_REGEX.search(message.content) | ||
|
||
|
||
def is_traditional_cat(message: discord.Message): | ||
return TRADITIONAL_CAT in message.content | ||
|
||
|
||
def from_meow_channel(message: discord.Message): | ||
return MEOW in message.channel.name | ||
|
||
|
||
async def do_meow(message: discord.Message, mention_author=False, multiplier=1): | ||
await message.reply(MEOW * multiplier, mention_author=mention_author) | ||
if not mention_author and mock_bernoulli(0.25): | ||
await message.channel.send(choice(POSSIBLE_MEOW_MESSAGES)) | ||
|
||
|
||
async def react_meow(message: discord.Message): | ||
shuffle(POSSIBLE_MEOW_REACTS) | ||
for react in POSSIBLE_MEOW_REACTS: | ||
if mock_bernoulli(0.5): | ||
await message.add_reaction(react) | ||
|
||
|
||
async def meow_meow(message: discord.Message): | ||
if is_meow_message(message): | ||
await react_meow(message) | ||
|
||
if is_traditional_cat(message): | ||
await do_meow(message, multiplier=randint(2, 101)) | ||
elif is_meow_message(message) and mock_bernoulli(0.169): | ||
await do_meow(message) | ||
elif from_meow_channel(message): | ||
if not is_meow_message(message) and mock_bernoulli(0.5): | ||
await do_meow(message, True) | ||
elif mock_bernoulli(0.25): | ||
await do_meow(message, False) | ||
elif mock_bernoulli(0.001): | ||
await do_meow(message) |
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