forked from djsyl/kichou
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkichou.py
More file actions
259 lines (205 loc) · 11.9 KB
/
kichou.py
File metadata and controls
259 lines (205 loc) · 11.9 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/usr/bin/env python3
# coding: utf-8
import discord
import time
######################################### PARAMETRES A PERSONALISER ################
bot = "kichou" # nom de votre bot
jouea = bot+" fait du Python" # activité du bot
guild = 693286944712556595 # id de votre serveur
from tokenkichou import token #token du bot il faut créer un fichier tokenkichou.py
# avec une ligne token ='le token de votre bot'
####################################################################################
from dickichou import dickichou,T1,T2 # dictionnaire des mots reconnus par le boot
class MyClient(discord.Client):
global dickichou # dictionnaire
global T1
global T2
timer1 = T1 #timing §
timer2 = T2 #timing œ
jeux='off'
cannaux =["général","test"] # utilisable en restrictions ex : if message.channel in self.cannaux:
utilisateurs = ["Olive","iPapy",bot,"margotte","jpty"] # utilisable en restrictions ex : if message.author.name in self.utilisateurs:
async def on_ready(self):
await client.change_presence(status=discord.Status.online, activity=discord.Game('{}'.format(jouea)))
print('BOT : {} actif joue à {} --- on ready ---> OK'.format(bot,jouea))
# a travailler <------------------------------------------------------------------
async def on_message_edit(self,before, after):
print('edit:')
print(before.content)
print(after.content)
# receptinn d'un message _________________________________________________________
async def on_message(self, message):
id = client.get_guild(guild) # <
print("id membercount {}".format(id.member_count)) #nombre d'utilisateur
print("id server name {}".format(id.name)) #nom du serveur
''' OK quel ques commandes en options
for toto in id.channels: # tous les channels
print(toto)
for toto in id.text_channels: # les channels text seulement
print('channels texte : {},'.format(toto),end='')
print()
print('channels categorie : ',end='' )
for toto in id.categories : # les categories
print('{},'.format(toto),end='')
'''
print('roles: ',end='' )
for toto in id.roles : # membres
print('{},'.format(toto),end='')
print('')
print('membres: ',end='' )
for toto in id.members : # membres
print('{},'.format(toto),end='')
print()
print('membres 2: ',end='' )
for toto in client.users : # membres
print('{},'.format(toto),end='')
print()
print('membres 3: ',end='' )
for toto in client.get_all_members() : # membres
print('{},'.format(toto),end='')
print()
if 1 == 1 :#tous les channels
#if (str(message.channel)=='général') or (str(message.channel)=='test'): #seulement ces channels
print('{} canal: {} de: {} message: {}'.format(bot,message.channel,message.author,message.content))
print('ID message: {}'.format(message.id))
print('')
if str(message.content).lower().find('+') >= 0 :
print('pas de réaction')
return
if str(message.content).lower().find('§') >= 0 :
print('debug: {}'.format('A'))
await message.delete(delay=self.timer1)
if str(message.content).lower().find('œ') >= 0 :
print('debug: {}'.format('B'))
await message.delete(delay=self.timer2)
#COMMANDES simple en début de ligne #######################################################
if message.content.startswith('>hello') or message.content.startswith('>Hello'):
await message.channel.send('H e l l o, comment vas-tu {} ?'.format(message.author.name))
#_________________ A revoir avec l'histoire du dictionnaire __________________________________
if message.content.startswith('>aide') or message.content.startswith('>aide'):
await message.channel.send('```md\n#Liste des commandes :\n>aide >hello, >miaou, jeux on, jeux off, jeux\
\n\n#mots déclancheur :\navion, mdr, pelle, miaou, mousse, bonjour, hello, apero, apéro,\
sieste, level, givre, café, ☕, 👍, 🤣, poubelle , temps, compliqué, moche, chut,\
columbo, combo, salut, bravo, 👏\n\n#caractères spéciaux :\n\
" anti mot déclancheur \n Œ efface aprés 120 secondes\n § efface aprés 15 secondes```')
# VARIABLES globales et commande d'activation du jeux
if message.content.startswith('jeux on'):
self.jeux = 'on'
await message.channel.send('Activation du jeux, état = {}'.format(self.jeux))
return
if message.content.startswith('jeux off'):
self.jeux = 'off'
await message.channel.send('Désactivation du jeux, état = {}'.format(self.jeux))
return
if message.content.startswith('jeux'): #donne l'etat du jeux
await message.channel.send('jeux = {}'.format(self.jeux))
# JEUX ni oui ni nom ###################################
if self.jeux == 'on':
if str(message.content).lower().find('oui') > -1:
await message.channel.send('Ta perdu {} Tu a dit OUI !'.format(message.author.name))
await message.channel.send('https://tenor.com/view/picturstef-oui-yes-si-bien-s%C3%BBr-gif-17961526 §')
if str(message.content).lower().find('non') > -1:
await message.channel.send('Ta perdu {} Tu a dit NON !'.format(message.author.name))
await message.channel.send('https://tenor.com/view/non-nan-the-cabbage-soup-gif-5034277 §')
#COMMANDES kichou sauvegarde le dictionnaire ###################################################
cmd= bot + ' sauvegarde le dictionnaire'
if message.content.startswith(cmd) and message.author.name in self.utilisateurs :
with open('dickichou.py', 'w') as f:
f.write('T1={}\n'.format(self.timer1))
f.write('T2={}\n'.format(self.timer2))
f.write('dickichou={}\n')
for k,v in dickichou.items():
f.write('dickichou["{}"]="{}"\n'.format(k,v.replace('"', '\\"')))
f.close
await message.channel.send('dictionnaire et timers sauvegardés')
return
#COMMANDES kichou ajoute clef:value ### et opérations sur dictionnaire dickichou
cmd= bot + ' ajoute '
if message.content.startswith(cmd) and message.author.name in self.utilisateurs :
rep = message.content[len(cmd):len(message.content)]
sep = rep.find(':')
clef = rep[0:sep]
value = rep[sep+1:]
dickichou[clef] = value
await message.channel.send('dictionnaire '+bot+', ajout de la Clef={} Valeur={}'.format(clef,value))
return
cmd= bot+' retire '
if message.content.startswith(cmd) and message.author.name in self.utilisateurs :
rep = message.content[len(cmd):len(message.content)]
if dickichou.get(rep) != None:
del dickichou[rep]
await message.channel.send('dictionnaire '+bot+', Clef={} Supprimée !'.format(rep))
return
else :
await message.channel.send("dictionnaire "+bot+", La Clef={} n'existe pas !".format(rep))
return
cmd= bot+' dictionnaire' ################ A REVOIR
if message.content.startswith(cmd) and message.author.name in self.utilisateurs :
for k,v in dickichou.items():
print('{} : {} +'.format(k,v))
return
#DETECTION MOT DIC KICHOU ###########################################################
if message.author.name != bot :
for k,v in dickichou.items() :
if k.lower() in str(message.content).lower() :
await message.channel.send('{}'.format(v))
#COMMANDES TIMER ####################################################################
cmd='timer1'
if message.content.startswith(cmd) and message.author.name in self.utilisateurs :
nb = int(message.content[len(cmd):len(cmd)+10])
mem = self.timer1
self.timer1 = nb
await message.channel.send('timer 1 timer1 = {} -> {}\ntimer2 = {}'.format(mem,nb,self.timer2))
return
cmd='timer2'
if message.content.startswith(cmd) and message.author.name in self.utilisateurs :
nb = int(message.content[len(cmd):len(cmd)+10])
mem = self.timer2
self.timer2 = nb
await message.channel.send('timer 1 timer1 = {} \ntimer2 = {}-> {}'.format(self.timer1,mem,self.timer2))
return
cmd='timers'
if message.content.startswith(cmd) and message.author.name in self.utilisateurs :
#await message.channel.send(message.author.name)
await message.channel.send('timer1 = {}\ntimer2 = {}'.format(self.timer1,self.timer2))
return
if message.content.startswith('timers'):
await message.channel.send('commande staff seulement {}'.format(message.author.name))
#COMMANDES CLEAR ####################################################################
cmd='clear'
if message.content.startswith(cmd) and message.author.name in self.utilisateurs :
nb = int(message.content[len(cmd):len(cmd)+10])+1
print('{} messages à supprimer'.format(nb -1))
await message.channel.purge(limit=nb)
await message.channel.send('{},{} messages supprimés !'.format(message.author.name,nb -1))
#COMMANDES nbm compte les message dans un channel ###################################
if message.content.startswith('nbm'):
await message.channel.send('ta demande est en cours {}, ça peut être long !'.format(message.author.name))
counter = 0
async for message in message.channel.history(limit=500000):
if 1 == 1:
counter += 1
await message.channel.send('{} Messages !'.format(counter))
#print(counter)
#COMMANDE AVEC EFFACE COMMANDE #######################################################
if message.content.startswith('>miaou'):
await message.channel.purge(limit=1)
#await message.delete(delay=5)
await message.channel.send('https://tenor.com/view/test-neko-test-neko-keyboard-test-neko-meow-meow-gif-14509709 §')
#DETECION MOT hors dictionnaire traitement particulier #######################################
if message.author.name != bot :
if str(message.content).lower().find('bonjour') >= 0 and str(message.content).find('@') == -1 :
await message.channel.send('Bonjour, comment vas-tu {} ?'.format(message.author.name))
if str(message.content).lower().find('hello') >= 0 and str(message.content).find('@') == -1 :
await message.channel.send('Hello, {} Comment ça va ?'.format(message.author.name))
print(str(message.content).find('@'))
#if str(message.content).lower().find('café') > -1:
# await message.channel.send('Moi aussi je veux bien un petit ☕ {} !'.format(message.author.name))
#if str(message.content).lower().find('☕') > -1:
# await message.channel.send('Moi aussi je veux bien un petit ☕ {} !'.format(message.author.name))
#if str(message.content).lower().find('poubelle') > -1:
# await message.channel.send('<:poubjaune:712187805643833424> §')
if str(message.content).lower().find('<@!773136088582717441>') > -1: #@kichou
await message.channel.send('Oui {} je suis la !'.format(message.author.name) )
client = MyClient()
client.run(token)