forked from NozyZy/Le-ptit-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
executable file
·1971 lines (1710 loc) · 72.4 KB
/
bot.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
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import asyncio
import time
from discord.ext.commands import UnexpectedQuoteError
import secret
import discord
import googletrans
import youtube_dl
from datetime import date
from discord.ext import commands
from googletrans import Translator
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
from fonctions import *
# ID : 653563141002756106
# https://discordapp.com/oauth2/authorize?&client_id=653563141002756106&scope=bot&permissions=8
intents = discord.Intents.default()
intents.members = True
client = discord.Client()
bot = commands.Bot(command_prefix="--",
description="Le p'tit bot !",
case_insensitive=True)
tgFile = open("txt/tg.txt", "r+")
nbtg: int = int(tgFile.readlines()[0])
nbprime: int = 0
tgFile.close()
# On ready message
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Game(name=f"insulter {nbtg} personnes"))
print("Logged in as")
print(bot.user.name)
print(bot.user.id)
print("------")
# Get every message sent, stocked in 'message'
@bot.event
async def on_message(message):
global nbtg
global nbprime
channel = message.channel
MESSAGE = message.content.lower()
rdnb = random.randint(1, 5)
today = date.today()
user = message.author
# open and stock the dico, with a lot of words
dicoFile = open("txt/dico.txt", "r+")
dicoLines = dicoFile.readlines()
dicoSize = len(dicoLines)
dicoFile.close()
bansFile = open("txt/bans.txt", "r+")
bansLines = bansFile.readlines()
bansFile.close()
if message.author == bot.user: # we don't want the bot to repeat itself
return
if (str(channel.id) +
"\n") in bansLines: # option to ban reactions from some channels
await bot.process_commands(message)
return
# expansion of the dico, with words of every messages (stock only words, never complete message)
# we don't want a specific bot (from a friend) to expand the dico
if message.author.id != 696099307706777610:
if "```" in MESSAGE:
return
mot = ""
for i in range(len(MESSAGE)):
mot += MESSAGE[i]
if MESSAGE[i] == " " or i == len(MESSAGE) - 1:
ponctuation = [
" ",
".",
",",
";",
"!",
"?",
"(",
")",
"[",
"]",
":",
"*",
]
for j in ponctuation:
mot = mot.replace(j, " ")
if verifAlphabet(mot) and 0 < len(mot) < 27:
mot += "\n"
if mot not in dicoLines:
print(f">>({user.name} {time.asctime()}) - nouveau mot : {mot}")
dicoLines.append(mot)
mot = ""
dicoLines.sort()
if len(dicoLines) > 0 and len(dicoLines) > dicoSize:
dicoFile = open("txt/dico.txt", "w+")
for i in dicoLines:
dicoFile.write(i)
dicoFile.close()
# stock file full of insults (yes I know...)
fichierInsulte = open("txt/insultes.txt", "r")
linesInsultes = fichierInsulte.readlines()
insultes = []
for line in linesInsultes:
line = line.replace("\n", "")
insultes.append(line)
fichierInsulte.close()
if message.content.startswith("--addInsult"):
print(f">>({user.name} {time.asctime()})", end=" - ")
mot = str(message.content)
mot = mot.replace(mot[0:12], "")
if len(mot) <= 2:
await channel.send("Sympa l'insulte...")
return
mot = "\n" + mot
fichierInsulte = open("txt/insultes.txt", "a")
fichierInsulte.write(mot)
fichierInsulte.close()
print("Nouvelle insulte :", mot)
await channel.send("Je retiens...")
# ping a people 10 time, once every 3 sec
if MESSAGE.startswith("--appel"):
print(f">>({user.name} {time.asctime()})", end=" - ")
if "<@!653563141002756106>" in MESSAGE:
await channel.send("T'es un marrant toi")
print("A tenté d'appeler le bot")
elif "<@" not in MESSAGE:
await channel.send("Tu veux appeler quelqu'un ? Bah tag le ! *Mondieu...*")
print("A tenté d'appeler sans taguer")
elif not message.author.guild_permissions.administrator:
await channel.send("Dommage, tu n'as pas le droit ¯\_(ツ)_/¯")
print("A tenté d'appeler sans les droits")
else:
nom = MESSAGE.replace("--appel ", "")
liste = [
"Allo ",
"T'es la ? ",
"Tu viens ",
"On t'attend...",
"Ca commence a faire long ",
"Tu viens un jour ??? ",
"J'en ai marre de toi... ",
"Allez grouille !! ",
"Toujours en rertard de toute facon... ",
"ALLOOOOOOOOOOOOOOOOOOOOOOOOOO ",
]
random.shuffle(liste)
for mot in liste:
text = mot + nom
await channel.send(text)
time.sleep(3)
print("A appelé", nom)
return
# if you tag this bot in any message
if "<@!653563141002756106>" in MESSAGE:
print(f">>({user.name} {time.asctime()}) - A ping le bot")
user = str(message.author.nick)
if user == "None":
user = message.author.name
rep = [
"ya quoi ?!",
"Qu'est ce que tu as " + user + " ?",
"Oui c'est moi",
"Présent !",
"*Oui ma bicheuh <3*",
user + " lance un duel.",
"Je t'aime.",
"T'as pas d'amis ? trouduc",
]
if user == "Le Grand bot":
rep.append("Oui bb ?")
rep.append("Yo <@!747066145550368789>")
elif message.author.id == 359743894042443776:
rep.append("Patron !")
rep.append("Eh mattez, ce mec est mon dev 👆")
rep.append("Je vais tous vous anéantir, en commençant par toi.")
rep.append("Tu es mort.")
await channel.send(random.choice(rep))
return
# send 5 randoms words from the dico
if MESSAGE == "--random":
print(f">>({user.name} {time.asctime()}) - A généré une phrase aléatoire")
text = ""
rd_dico = dicoLines
random.shuffle(rd_dico)
for i in range(5):
text += rd_dico[i]
if i != 4:
text += " "
text += "."
text = text.replace("\n", "")
text = text.replace(text[0], text[0].upper(), 1)
await channel.send(text)
# send the number of words stocked in the dico
if MESSAGE == "--dico":
print(f">>({user.name} {time.asctime()}) - A compter le nombe de mots du dico")
text = f"J'ai actuellement {str(len(dicoLines))} mots enregistrés, nickel"
await channel.send(text)
# begginning of reaction programs, get inspired
if not MESSAGE.startswith("--"):
if "enerv" in MESSAGE or "énerv" in MESSAGE and rdnb >= 2:
print(f">>({user.name} {time.asctime()}) - S'est enervé")
await channel.send("(╯°□°)╯︵ ┻━┻")
if "(╯°□°)╯︵ ┻━┻" in MESSAGE:
print(f">>({user.name} {time.asctime()}) - A balancé la table")
await channel.send("┬─┬ ノ( ゜-゜ノ)")
if (MESSAGE.startswith("tu sais") or MESSAGE.startswith("vous savez") or MESSAGE.startswith("savez vous")
or MESSAGE.startswith("savez-vous") or MESSAGE.startswith("savais-tu") or MESSAGE.startswith("savais tu")) \
and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - A demandé si on savait")
reponses = [
"J'en ai vraiment rien à faire tu sais ?",
"Waaa... Je bois tes paroles",
"Dis moi tout bg",
"Balec",
"M'en fous",
"Plait-il ?",
]
await channel.send(random.choice(reponses))
if MESSAGE == "pas mal" and rdnb > 2:
print(f">>({user.name} {time.asctime()}) - A trouvé ca pas mal")
reponses = [
"mouais",
"peut mieux faire",
"woaw",
":o"
]
await channel.send(random.choice(reponses))
if (MESSAGE == "ez" or MESSAGE == "easy") and rdnb >= 3:
print(f">>({user.name} {time.asctime()}) - A trouvé ça facile")
reponses = [
"https://tenor.com/view/walking-dead-easy-easy-peasy-lemon-squeazy-gif-7268918",
"https://tenor.com/view/pewds-pewdiepie-easy-ez-gif-9475407",
"https://tenor.com/view/easy-red-easy-button-red-button-gif-4642542",
"https://tenor.com/view/simple-easy-easy-game-easy-life-deal-with-it-gif-9276124"
]
await channel.send(random.choice(reponses))
if MESSAGE in [
"bite",
"zizi",
"teub",
"zboub",
"penis",
"chybre",
"chybrax",
"chibre",
]:
print(f">>({user.name} {time.asctime()}) - A parlé de bite")
text = "8" + "=" * random.randint(0, int(
today.strftime("%d"))) + "D"
await channel.send(text)
if MESSAGE.startswith("stop") or MESSAGE.startswith("arrête") or MESSAGE.startswith("arrete") and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - A demandé d'arrêter")
reponses = [
"https://tenor.com/view/daddys-home2-daddys-home2gifs-stop-it-stop-that-i-mean-it-gif-9694318",
"https://tenor.com/view/stop-sign-when-you-catch-feelings-note-to-self-stop-now-gif-4850841",
"https://tenor.com/view/stop-it-get-some-help-gif-7929301"
]
await channel.send(random.choice(reponses))
if MESSAGE.startswith("exact") and rdnb > 2:
print(f">>({user.name} {time.asctime()}) - A trouvé ça exacte")
reponses = [
"Je dirais même plus, exact.",
"Il est vrai",
"AH BON ??!",
"C'est cela",
"Plat-il ?",
"Jure ?",
]
await channel.send(random.choice(reponses))
if MESSAGE == "<3":
print(f">>({user.name} {time.asctime()}) - A envoyé de l'amour")
reponses = [
"Nique ta tante (pardon)",
"<3",
"luv luv",
"moi aussi je t'aime ❤",
]
await channel.send(random.choice(reponses))
if MESSAGE in ["toi-même", "toi-meme", "toi même", "toi meme"]:
print(f">>({user.name} {time.asctime()}) - A sorti sa meilleure répartie")
reponses = [
"Je ne vous permet pas",
"Miroir magique",
"C'est celui qui dit qui l'est",
]
await channel.send(random.choice(reponses))
if "<@!747066145550368789>" in message.content:
print(f">>({user.name} {time.asctime()}) - A parlé du grand bot")
reponses = [
"bae",
"Ah oui, cette sous-race de <@!747066145550368789>",
"il a moins de bits que moi",
"son pere est un con",
"ca se dit grand mais tout le monde sait que....",
]
await channel.send(random.choice(reponses))
if "❤" in MESSAGE:
print(f">>({user.name} {time.asctime()}) - A envoyé du love")
await message.add_reaction("❤")
if (MESSAGE.startswith("hein") or MESSAGE.startswith("1")) and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - A commencé par 1", end="")
reponses = [
"deux",
"2",
"deux ?",
"2 😏"
]
await channel.send(random.choice(reponses))
# waits for a message valiudating further instructions
def check(m):
return ("3" in m.content or "trois" in m.content) and m.channel == message.channel and not m.startswith(
"http")
try:
await bot.wait_for("message", timeout=60.0, check=check)
except asyncio.TimeoutError:
await message.add_reaction("☹")
print(f">>({user.name} {time.asctime()}) - A pas su compter")
else:
print(f">>({user.name} {time.asctime()}) - A su compter")
reponses = [
"BRAVO TU SAIS COMPTER !",
"SOLEIL !",
"4, 5, 6, 7.... oh et puis merde",
"HAHAHAHAH non.",
"stop.",
]
await channel.send(random.choice(reponses))
if MESSAGE == "a" and rdnb > 2:
print(f">>({user.name} {time.asctime()}) - A commencer par a", end="")
def check(m):
return m.content.lower() == "b" and m.channel == message.channel
try:
await bot.wait_for("message", timeout=60.0, check=check)
except asyncio.TimeoutError:
await message.add_reaction("☹")
print(f">>({user.name} {time.asctime()}) - A pas continué par b")
else:
print(f">>({user.name} {time.asctime()}) - A connait son alphabet")
await channel.send("A B C GNEU GNEU MARRANT TROU DU CUL !!!")
if MESSAGE == "ah" and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - ", end="")
if rdnb >= 4:
print("S'est fait Oh/Bh")
reponses = ["Oh", "Bh"]
await channel.send(random.choice(reponses))
else:
print("S'est fait répondre avec le dico (ah)")
await channel.send(finndAndReplace("a", dicoLines))
if MESSAGE == "oh" and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - ", end="")
if rdnb >= 4:
print("S'est fait répondre (oh)")
reponses = ["Quoi ?",
"p",
"ah",
":o",
"https://thumbs.gfycat.com/AptGrouchyAmericanquarterhorse-size_restricted.gif"
]
await channel.send(random.choice(reponses))
else:
print("S'est fait répondre par le dico (oh)")
await channel.send(finndAndReplace("o", dicoLines))
if MESSAGE == "eh" and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - ", end="")
if rdnb >= 4:
print("S'est fait répondre (eh)")
reponses = ["hehehehehe", "oh", "Du calme."]
await channel.send(random.choice(reponses))
else:
print("S'est fait répondre par le dico (eh)")
await channel.send(finndAndReplace("é", dicoLines))
if MESSAGE.startswith("merci"):
print(f">>({user.name} {time.asctime()}) - A dit merci")
if rdnb >= 3:
reponses = [
"De rien hehe",
"C'est normal t'inquiète",
"Je veux le cul d'la crémière avec.",
"non.",
"Excuse toi non ?",
"Au plaisir",
]
await channel.send(random.choice(reponses))
else:
await message.add_reaction("🥰")
if MESSAGE == "skusku" or MESSAGE == "sku sku":
print(f">>({user.name} {time.asctime()}) - A demandé qui jouait")
await channel.send("KICÉKIJOUE ????")
if ("😢" in MESSAGE or "😭" in MESSAGE) and rdnb >= 3:
print(f">>({user.name} {time.asctime()}) - A chialé")
reponses = [
"cheh",
"dur dur",
"dommage mon p'tit pote",
"balec",
"tant pis",
]
await channel.send(random.choice(reponses))
if MESSAGE.startswith("tu veux") and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - A demandé si on voulait")
reponses = [
"Ouais gros",
"Carrément ma poule",
"Mais jamais tes fou ptdr",
"Oui.",
]
await channel.send(random.choice(reponses))
if MESSAGE.startswith("quoi") and rdnb > 2:
print(f">>({user.name} {time.asctime()}) - A demandé quoi")
reponses = [
"feur",
"hein ?",
"nan laisse",
"oublie",
"rien",
"😯"
]
await channel.send(random.choice(reponses))
if MESSAGE.startswith("pourquoi") and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - A demandé pourquoi")
reponses = [
"PARCEQUEEEE",
"Aucune idée.",
"Demande au voisin",
"Pourquoi tu demandes ça ?",
]
await channel.send(random.choice(reponses))
if (MESSAGE in [
"facepalm",
"damn",
"fait chier",
"fais chier",
"ptn",
"putain"]
or MESSAGE.startswith("pff") or MESSAGE.startswith("no..")) \
and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - A gifé Conteville")
await channel.send(
"https://media.discordapp.net/attachments/636579760419504148/811916705663025192/image0.gif"
)
if (MESSAGE.startswith("t'es sur") or MESSAGE.startswith("t sur")) and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - A demandé si on était sur")
reponses = [
"Ouais gros",
"Nan pas du tout",
"Qui ne tente rien...",
"haha 👀",
]
await channel.send(random.choice(reponses))
if (MESSAGE.startswith("ah ouais") or MESSAGE.startswith("ah bon")) and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - S'est intérrogé de la véracité du dernier propos")
reponses = [
"Ouais gros", "Nan ptdr", "Je sais pas écoute...", "tg"
]
await channel.send(random.choice(reponses))
if MESSAGE.startswith("au pied") and message.author.id == 359743894042443776:
print(f">>({user.name} {time.asctime()}) - Le maitre m'a appelé")
reponses = [
"wouf wouf",
"Maître ?",
"*s'agenouille*\nComment puis-je vous être utile ?",
"*Nous vous devons une reconnaissance éternelllllllle*",
]
await channel.send(random.choice(reponses))
if "<@!761898936364695573>" in MESSAGE:
print(f">>({user.name} {time.asctime()}) - A parlé de mon pote")
await channel.send("Tu parles comment de mon pote là ?")
if "tg" in MESSAGE:
MESSAGE = " " + MESSAGE + " "
for i in range(len(MESSAGE) - 3):
if (MESSAGE[i] == " " and MESSAGE[i + 1] == "t"
and MESSAGE[i + 2] == "g" and MESSAGE[i + 3] == " "):
nbtg += 1
tgFile = open("txt/tg.txt", "w+")
tgFile.write(str(nbtg))
tgFile.close()
activity = f"insulter {nbtg} personnes"
await bot.change_presence(activity=discord.Game(
name=activity))
await channel.send(random.choice(insultes))
if rdnb >= 4:
await message.add_reaction('🇹')
await message.add_reaction('🇬')
print(f">>({user.name} {time.asctime()}) - A insulté")
return
if MESSAGE == "cheh" or MESSAGE == "sheh":
print(f">>({user.name} {time.asctime()}) - A dit cheh")
if rdnb >= 3:
reponses = [
"Oh tu t'excuses", "Cheh", "C'est pas gentil ça", "🙁"
]
await channel.send(random.choice(reponses))
else:
await message.add_reaction("😉")
if MESSAGE.startswith("non") and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - A dit non")
reponses = [
"si.",
"ah bah ca c'est sur",
"SÉRIEUX ??",
"logique aussi",
"jure ?",
]
await channel.send(random.choice(reponses))
if MESSAGE.startswith("lequel") and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - A demandé lequel")
reponses = [
"Le deuxième",
"Le prochain",
"Aucun"
]
await channel.send(random.choice(reponses))
if MESSAGE.startswith("laquelle") and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - A demandé laquelle")
reponses = [
"La deuxième",
"La prochaine",
"Aucune"
]
await channel.send(random.choice(reponses))
if MESSAGE.startswith("miroir magique"):
print(f">>({user.name} {time.asctime()}) - A sorti une répartie de maternelle")
await channel.send(MESSAGE)
if MESSAGE.startswith("jure") and rdnb > 4:
print(f">>({user.name} {time.asctime()}) - A demandé de jurer")
if "wola" in MESSAGE:
await channel.send("Wola")
elif "wallah" in MESSAGE:
await channel.send("Wallah")
else:
rep = await channel.send(
"Je jure de dire la vérité, uniquement la vérité et toute la vérité"
)
if rdnb >= 4:
await rep.add_reaction("🤞")
if "☹" in MESSAGE or "😞" in MESSAGE or "😦" in MESSAGE:
print(f">>({user.name} {time.asctime()}) - A chialé")
await message.add_reaction("🥰")
if MESSAGE == "f" or MESSAGE == "rip":
print(f">>({user.name} {time.asctime()}) - Payed respect")
await channel.send(
"#####\n#\n#\n####\n#\n#\n# to pay respect")
if ("quentin" in MESSAGE or "quent1" in MESSAGE) and rdnb >= 4:
print(f">>({user.name} {time.asctime()}) - A parlé de mon maitre")
await channel.send("Papa ! 🤗")
if MESSAGE.startswith("god"):
print(f">>({user.name} {time.asctime()}) - ", end="")
day = today.strftime("%d")
month = today.strftime("%m")
MESSAGE = MESSAGE.replace("god", "")
userID = ""
if "<@!" not in MESSAGE:
userID = int(user.id)
else:
i = 0
for i in range(len(MESSAGE)):
if (MESSAGE[i] == "<" and MESSAGE[i + 1] == "@"
and MESSAGE[i + 2] == "!"):
i += 3
userID = ""
break
while MESSAGE[i] != ">" and i < len(MESSAGE):
userID += MESSAGE[i]
i += 1
userID = int(userID)
if userID % 5 != (int(day) + int(month)) % 5:
await channel.send("Not today (☞゚ヮ゚)☞")
print("N'est pas dieu aujourd'hui")
return
user = await message.guild.fetch_member(userID)
pfp = user.avatar_url
gods = [
["https://tse4.mm.bing.net/th?id=OIP.IXAIL06o83HxXHGjKHqZMAHaKe&pid=Api", "Loki"],
["https://www.wallpaperflare.com/static/810/148/1018/painting-vikings-odin-gungnir-wallpaper.jpg",
"Odin"],
["https://tse3.mm.bing.net/th?id=OIP.3NR2eZEBm46mrcFM_p14RgHaJ3&pid=Api", "Osiris"],
["https://tse1.explicit.bing.net/th?id=OIP.KXfuA_jDa_cfDkrMInOMfQHaJq&pid=Api", "Shiva"],
["https://tse2.mm.bing.net/th?id=OIP.BYG-Xfgo4To4PJaY32Gj0gHaKD&pid=Api", "Poseidon"],
["https://tse1.mm.bing.net/th?id=OIP.M6A5OIYcaUO5UUrUjVRn5wHaNK&pid=Api", "Arceus"],
["https://tse3.mm.bing.net/th?id=OIP.M2w0Dn5HK19lF68UcicLUwHaMv&pid=Api", "Anubis"],
["https://tse2.mm.bing.net/th?id=OIP.pVKMpFtFLRjIpAEsPMafJgAAAA&pid=Api", "Tezcatlipoca"],
["https://tse2.mm.bing.net/th?id=OIP.8hT9rmQRFhGa11CTdXXPQAHaJ6&pid=Api", "Venus"],
["https://c.tenor.com/nMkmGwGH8s8AAAAd/elon-musk-smoke.gif","Elon Musk"]
]
embed = discord.Embed(
title="This is God",
description="<@%s> is that god." % userID,
color=0xECCE8B,
url=random.choice([
"https://media.giphy.com/media/USm8tJQzgDAAKJRKkk/giphy.gif",
"https://media.giphy.com/media/ZArMUnViJtKaBH0XLg/giphy.gif",
"https://tenor.com/view/bruce-almighty-morgan-freeman-i-am-god-hello-hey-gif-4743445"
])
)
god = gods[((userID // 365 + int(day) * 5) // int(month)) % len(gods)]
embed.set_thumbnail(url=pfp)
embed.set_author(name="Le p'tit god", url="https://github.com/NozyZy/Le-ptit-bot",
icon_url="https://cdn.discordapp.com/avatars/653563141002756106/5e2ef5faf8773b5216aca6b8923ea87a.png")
embed.set_image(url=god[0])
embed.set_footer(text=god[1])
print("Est un dieu aujourd'hui : ", god[1])
await channel.send("God looks like him.", embed=embed)
if MESSAGE.startswith("hello") and rdnb >= 3:
print(f">>({user.name} {time.asctime()}) - A dit hello")
await channel.send(file=discord.File("images/helo.jpg"))
if (MESSAGE == "enculé" or MESSAGE == "enculer") and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - A demander d'aller se faire enculer")
image = ["images/tellermeme.png", "images/bigard.jpeg"]
await channel.send(file=discord.File(random.choice(image)))
if MESSAGE == "stonks":
print(f">>({user.name} {time.asctime()}) - Stonked")
await channel.send(file=discord.File("images/stonks.png"))
if (MESSAGE == "parfait" or MESSAGE == "perfection") and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - Perfection")
await channel.send(file=discord.File("images/perfection.jpg"))
if MESSAGE.startswith("leeroy"):
print(f">>({user.name} {time.asctime()}) - LEEROOOOOOOOOOYY")
await channel.send(file=discord.File("sounds/Leeroy Jenkins.mp3"))
if "pute" in MESSAGE and rdnb > 4:
print(f">>({user.name} {time.asctime()}) - Le pute")
reponses = [
"https://tenor.com/view/mom-gif-10756105",
"https://tenor.com/view/wiener-sausages-hotdogs-gif-5295979",
"https://i.ytimg.com/vi/3HZ0lvpdw6A/maxresdefault.jpg",
]
await channel.send(random.choice(reponses))
if "guillotine" in MESSAGE:
print(f">>({user.name} {time.asctime()}) - Le guillotine")
reponses = [
"https://tenor.com/view/guillatene-behead-lego-gif-12352396",
"https://tenor.com/view/guillotine-gulp-worried-scared-slug-riot-gif-11539046",
"https://tenor.com/view/revolution-guillotine-marie-antoinette-off-with-their-heads-behead-gif-12604431",
]
await channel.send(random.choice(reponses))
if (MESSAGE == "ouh" or MESSAGE == "oh.") and rdnb > 3:
print(f">>({user.name} {time.asctime()}) - 'OUH.', by Velikson")
await channel.send("https://thumbs.gfycat.com/AptGrouchyAmericanquarterhorse-size_restricted.gif")
if "pd" in MESSAGE:
print(f">>({user.name} {time.asctime()}) - A parlé de pd")
MESSAGE = " " + MESSAGE + " "
for i in range(len(MESSAGE) - 3):
if (MESSAGE[i] == " " and MESSAGE[i + 1] == "p"
and MESSAGE[i + 2] == "d" and MESSAGE[i + 3] == " "):
await channel.send(file=discord.File("images/pd.jpg"))
if "oof" in MESSAGE and rdnb >= 3:
print(f">>({user.name} {time.asctime()}) - oof")
reponses = [
"https://media.discordapp.net/attachments/636579760419504148/811916705663025192/image0.gif",
"https://tenor.com/view/oh-snap-surprise-shocked-johncena-gif-5026702",
"https://tenor.com/view/oof-damn-wow-ow-size-gif-16490485",
"https://tenor.com/view/oof-simpsons-gif-14031953",
"https://tenor.com/view/yikes-michael-scott-the-office-my-bad-oof-gif-13450971",
]
await channel.send(random.choice(reponses))
if ("money" in MESSAGE or "argent" in MESSAGE) and rdnb >= 4:
print(f">>({user.name} {time.asctime()}) - Money bitch")
reponses = [
"https://tenor.com/view/6m-rain-wallstreet-makeitrain-gif-8203989",
"https://tenor.com/view/money-makeitrain-rain-guap-dollar-gif-7391084",
"https://tenor.com/view/taka-money-gif-10114852",
]
await channel.send(random.choice(reponses))
# teh help command, add commands call, but not reactions
if MESSAGE == "--help":
print(f">>({user.name} {time.asctime()}) - A demandé de l'aide")
await channel.send(
"Commandes : \n"
" **F** to pay respect\n"
" **--serverInfo** pour connaître les infos du server\n"
" **--clear** *nb* pour supprimer *nb* messages\n"
" **--addInsult** pour ajouter des insultes et **tg** pour te faire insulter\n"
" **--game** pour jouer au jeu du **clap**\n"
" **--presentation** et **--master** pour créer des memes\n"
" **--repeat** pour que je répète ce qui vient après l'espace\n"
" **--appel** puis le pseudo de ton pote pour l'appeler (admin only)\n"
" **--crypt** pour chiffrer/déchiffrer un message César (décalage)\n"
" **--random** pour écrire 5 mots aléatoires\n"
" **--randint** *nb1*, *nb2* pour avoir un nombre aléatoire entre ***nb1*** et ***nb2***\n"
" **--calcul** *nb1* (+, -, /, *, ^, !) *nb2* pour avoir un calcul adéquat \n"
" **--isPrime** *nb* pour tester si *nb* est premier\n"
" **--prime** *nb* pour avoir la liste de tous les nombres premiers jusqu'a *nb* au minimum\n"
" **--poll** ***question***, *prop1*, *prop2*,..., *prop10* pour avoir un sondage de max 10 propositions\n"
" **--invite** pour savoir comment m'inviter\n"
"Et je risque de réagir à tes messages, parfois de manière... **Inattendue** 😈"
)
else:
# allows command to process after the on_message() function call
await bot.process_commands(message)
# beginning of the commands
@bot.command() # delete 'nombre' messages
async def clear(ctx, nombre: int):
print(
f">>({ctx.author.name} {time.asctime()}) - A demandé de clear {nombre} messages dans le channel {ctx.channel.name} du serveur {ctx.guild.name}")
messages = await ctx.channel.history(limit=nombre + 1).flatten()
for message in messages:
await message.delete()
@bot.command() # repeat the 'text', and delete the original message
async def repeat(ctx, *text):
print(f">>({ctx.author.name} {time.asctime()}) - A demandé de répéter {' '.join(text)} messages")
messages = await ctx.channel.history(limit=1).flatten()
for message in messages:
await message.delete()
await ctx.send(" ".join(text))
@bot.command() # show the number of people in the server, and its name
async def serverinfo(ctx):
server = ctx.guild
nbUsers = server.member_count
text = f"Le serveur **{server.name}** contient **{nbUsers}** personnes !"
print(f">>({ctx.author.name} {time.asctime()}) - A demandé les infos du serveur {server.name}")
await ctx.send(text)
@bot.command() # send the 26 possibilites of a ceasar un/decryption
async def crypt(ctx, *text):
mot = " ".join(text)
messages = await ctx.channel.history(limit=1).flatten()
for message in messages:
await message.delete()
print(f">>({ctx.author.name} {time.asctime()}) - A demandé de crypter {mot} en {crypting(mot)}")
await ctx.send(f"||{mot}|| :\n" + crypting(mot))
@bot.command() # send a random integer between two numbers, or 1 and 0
async def randint(ctx, *text):
print(f">>({ctx.author.name} {time.asctime()}) - ", end="")
tab = []
MESSAGE = "".join(text)
nb2 = 0
i = 0
while i < len(MESSAGE) and MESSAGE[i] != ",":
if 48 <= ord(MESSAGE[i]) <= 57:
tab.append(MESSAGE[i])
i += 1
if len(tab) == 0:
await ctx.send("Rentre un nombre banane")
print("A demandé un nombre aléatoire sans donner d'encadrement")
return
nb1 = strToInt(tab)
if i != len(MESSAGE):
nb2 = strToInt(list=nbInStr(MESSAGE, i, len(MESSAGE)))
if nb1 == nb2:
text = f"Bah {str(nb1)} du coup... 🙄"
await ctx.send(text)
print(f"A demandé le nombre {nb1}")
return
if nb2 < nb1:
temp = nb2
nb2 = nb1
nb1 = temp
rd = random.randint(nb1, nb2)
print(f"A généré un nombre aléatoire [|{nb1}:{nb2}|] = {rd}")
await ctx.send(rd)
@bot.command() # send a random word from the dico, the first to write it wins
async def game(ctx):
print(f">>({ctx.author.name} {time.asctime()}) - ", end="")
dicoFile = open("txt/dico.txt", "r+")
dicoLines = dicoFile.readlines()
dicoFile.close()
mot = random.choice(dicoLines)
mot = mot.replace("\n", "")
text = f"Le premier à écrire **{mot}** a gagné"
print(f"A joué au jeu en devinant {mot}, ", end="")
reponse = await ctx.send(text)
if ctx.author == bot.user:
return
def check(m):
return m.content == mot and m.channel == ctx.channel
try:
msg = await bot.wait_for("message", timeout=60.0, check=check)
except asyncio.TimeoutError:
await reponse.add_reaction("☹")
else:
user = str(msg.author.nick)
text = f"**{user}** a gagné !"
print(f"{user} a gagné")
await ctx.send(text)
@bot.command(
) # do a simple calcul of 2 numbers and 1 operator (or a fractionnal)
async def calcul(ctx, *text):
print(f">>({ctx.author.name} {time.asctime()}) - ", end="")
tab = []
symbols = ["-", "+", "/", "*", "^", "!"]
Message = "".join(text)
Message = Message.lower()
nb2 = i = rd = 0
if "infinity" in Message:
text = ""
for i in range(1999):
text += "9"
await ctx.send(text)
print("A demandé de calculer l'infini")
return
while i < len(Message) and 48 <= ord(Message[i]) <= 57:
if 48 <= ord(Message[i]) <= 57:
tab.append(Message[i])
i += 1
if len(tab) == 0:
await ctx.send("Rentre un nombre banane")
print("A demandé de calculer sans rentrer de nombre")
return
if i == len(Message) or Message[i] not in symbols:
await ctx.send("Rentre un symbole (+, -, *, /, ^, !)")
print("A demandé de calculer sans rentrer de symbole")
return
symb = Message[i]
nb1 = strToInt(tab)
if symb == "!":
if nb1 > 806: # can't go above 806 recursion deepth
await ctx.send("806! maximum, désolé 🤷♂️")
print("A demandé de calculer plus de 806! (erreur récursive)")
return
rd = facto(nb1)
text = str(nb1) + "! =" + str(rd)
await ctx.send(text)
print(f"A demandé de calculer {text}")
return
if i != len(Message):
tab = nbInStr(Message, i, len(Message))
if len(tab) == 0:
await ctx.send("Rentre un deuxième nombre patate")
print("A demandé de calculer sans reentrer de deuxième nombre")
return
nb2 = strToInt(tab)
if symb == "+":
rd = nb1 + nb2
elif symb == "-":
rd = nb1 - nb2
elif symb == "*":
rd = nb1 * nb2
elif symb == "/":
if nb2 == 0:
await ctx.send("±∞")
print("A demandé de calculer une division par 0 (le con)")
return
rd = float(nb1 / nb2)
elif symb == "^":
rd = nb1 ** nb2
text = str(nb1) + str(symb) + str(nb2) + "=" + str(rd)
print(text)
print(f"A demandé de calculer {text}")
await ctx.send(text)
@bot.command(
) # create a reaction poll with a question, and max 10 propositions
async def poll(ctx, *text):
print(f">>({ctx.author.name} {time.asctime()}) - ", end="")
tab = []
Message = " ".join(text)
text = ""
for i in range(len(Message)):
if Message[i] == ",":
tab.append(text)
text = ""
elif i == len(Message) - 1:
text += Message[i]
tab.append(text)
else:
text += Message[i]
if len(tab) <= 1:
await ctx.send(
"Ecris plusieurs choix séparés par des virgules, c'est pas si compliqué que ça..."
)
print("A demandé un poll sans choix")
return
if len(tab) > 11:
await ctx.send("Ca commence à faire beaucoup non ?... 10 max ca suffit"
)
print("A demandé un poll e plus de 10 choix")
return
text = ""
print("A demandé un poll avec : ", end="")
for i in range(len(tab)):
print(tab[i], sep=" - ")
if i == 0:
text += "❓"
elif i == 1:
text += "\n1️⃣"
elif i == 2:
text += "\n2️⃣"
elif i == 3:
text += "\n3️⃣"
elif i == 4:
text += "\n4️⃣"
elif i == 5:
text += "\n5️⃣"
elif i == 6: