"Je suis" feature

This commit is contained in:
voXrey 2024-06-19 16:28:31 +02:00
parent b82d1bbf86
commit 94299e0336
1 changed files with 20 additions and 4 deletions

24
main.py
View File

@ -42,12 +42,28 @@ class MyClient(commands.Bot):
print(f"Admins : {', '.join([m.name for m in team.members])}")
print('------')
async def on_message(self, msg):
p = re.compile("[qQ]uoi[ \\.!?;\"»]*$")
print(f"{msg!r}")
if p.search(msg.content) is not None:
async def on_message(self, msg: discord.Message):
# quoicoubot
quoi = re.compile("[qQ]uoi[ \\.!?;\"»]*$")
if quoi.search(msg.content) is not None:
await msg.reply("Quoicoubeh !")
# je suis
je_suis = "je suis "
if msg.content.lower().startswith(je_suis): # détection
words = msg.content[len(je_suis):].split(' ')
new_pseudo = "" # pseudo creation (do not split a word)
for word in words:
if (len(new_pseudo) + len(word) + 1) > 32:
break
new_pseudo += " " + word
if new_pseudo != "":
member = msg.author
try:
await member.edit(nick=new_pseudo, reason="Il est " + new_pseudo)
except discord.Forbidden:
pass
if __name__ == "__main__":
client = MyClient()