-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
43 lines (34 loc) · 1.19 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import discord
import random
import unidecode
client = discord.Client()
lastChannel = None
lastAuthor = None
def insulte_in_message(content):
insultes = open('./insultes.txt', encoding="utf-8").read().splitlines()
for word in content.split():
if unidecode.unidecode(word).lower() in insultes:
return True
return False
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
lastChannel = message.channel
lastAuthor = message.author
if message.author == client.user:
return
if client.user.mentioned_in(message):
quotes = open('./quotes.txt', encoding="utf-8").readlines();
quote = quotes[random.randint(0, len(quotes) - 1)]
await message.channel.send(f"{message.author.mention} {quote}")
return
if insulte_in_message(message.content):
warnings = open('./quotes.txt', encoding="utf-8").readlines();
warning = warnings[random.randint(0, len(warnings) - 1)]
await message.channel.send(f"{message.author.mention} {warning}")
return
tokenFile = open('./token')
token = tokenFile.readlines()[0]
client.run(token)