-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzad2.py
43 lines (38 loc) · 1.84 KB
/
zad2.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
# DANE WEJŚCIOWE:
LEVELS = [int(math.pow(x, 1.5)*20) for x in range(100)] # [0, 20, 56, 103, 160, 223, 293, 370, 452,...]
DATA = {'people': [{'userID': 0, 'xp': 0, 'level': 1}, {'userID': 325291113323692033, 'xp': 23, 'level': 2}, {'userID': 376863468122537985, 'xp': 92, 'level': 3}]} # Przykładowe po inicjalizacji
@bot.event
async def on_message(message):
if message.author == bot.user:
return
else:
if not containsBannedWords(message): #tę funkcję olejcie
for user in DATA['people']:
if user['userID'] == message.author.id:
unique = False
user['xp'] += len(message.content.split(" "))
level_before = user['level']
## WSTAW TUTAJ PĘTLĘ CZY USER
## POWINIEN JUŻ LVL'UPOWAĆ
## POWINNA ONA ZMIENIAĆ ZAWARTOŚĆ POLA user['level']
if user['xp'] > LEVELS [ user['level']]:
user['level'] ++; ## +=1;
if level_before != user['level']:
await message.channel.send(
f"Congratulations {message.author.mention}, you have just hit level {user['level']}!"
)
write_json(DATA)
break
else:
unique = True
if unique:
DATA['people'].append({
'userID': message.author.id,
'xp': len(message.content),
'level' : 1
})
write_json(DATA)
else:
await message.delete()
await message.channel.send(random.choice(cursingPhrases))
await bot.process_commands(message)