-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
2497 lines (2403 loc) · 86.8 KB
/
main.py
File metadata and controls
2497 lines (2403 loc) · 86.8 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
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
from prettytable import PrettyTable
import discord
from discord.ext import commands
from discord.ext import tasks
from PIL import Image, ImageFont, ImageDraw
from io import BytesIO
import re
import datetime
import os
import xlsxwriter
from myfunc import *
from vggc import *
from keep_alive import keep_alive
keep_alive()
intents = discord.Intents.all()
TOKEN = os.environ['TOKEN']
prefix = "="
bot = commands.Bot(command_prefix=commands.when_mentioned_or(prefix),
strip_after_prefix=True,
intents=intents)
#Global variables:-
red = int("ff0000", 16)
ftl=[]
@tasks.loop(seconds=1)
async def pot():
poi= datetime.datetime.now() + datetime.timedelta(hours=5,minutes=30)
a=poi.strftime("%X")
print(a)
if a in ftl:
await m()
async def m():
a=bot.get_user(747201484701040758)
await a.send("chal gya me betuichod")
@bot.command()
async def d2m(ctx,*,b):
a=re.compile("\d{18}")
list=a.findall(b)
c=len(list)
i=0
list1=[]
a1="<@"
a2=">"
while i < c:
a=a1 + list[i] + a2
list1.append(a)
i+=1
list2= "\n".join(list1)
await ctx.send("`{}`".format(list2))
@bot.event
async def on_message(message):
if message.guild==None and message.author!=bot.user:
a=message.content
b=message.author
ctx=bot.get_channel(897997299031109665)
await cembed(ctx,red,f"**ID:- {message.author.id}\nContent :-\n{a}**",message.author)
await bot.process_commands(message)
@bot.event
async def on_ready():
game = discord.Game("in the Clover Kingdom()".format(prefix))
await bot.change_presence(status=discord.Status.idle, activity=game)
print("Bot is ready")
pot.start()
@bot.command()
async def utbc(ctx,*,a):
b=re.compile("Team .*(name -|Name -).*")
c=b.findall(a)
i=0
while i < len(c):
a1=c[i]
if "Team Name -" in a1:
a2=a1.replace("Team Name -","")
c[i]=a2
i+=1
if "Team name -" in a1:
a2=a1.replace("Team name -","")
c[i]=a2
i+=1
a1 = len(c)
c1=[]
i=0
while i <len(c):
a=f"SLOT {i+3} ➠ {c[i]}"
c1.append(a)
i+=1
c2="\n".join(c1)
await ctx.send(f"""`**╔───────── ¤ ◎ ◎ ¤ ─────────╗
FAN CUP BGMI
╚───────── ¤ ◎ ◎ ¤ ─────────╝
GROUP SLOT LIST \n\n{c2}\n**`""")
@bot.command()
async def qui(ctx,*,b):
if b.lower()=="file":
if ctx.message.attachments!=[]:
await ctx.send("file nhi hai ")
await ctx.message.attachments[0].save("rcf.txt")
f1=open("rcf.txt","r")
b=f1.read()
else:
await ctx.send("Guru file to dfalo. Firse try karo pura.")
return
a=re.compile("\d{18}")
l1=a.findall(b)
c=len(l1)
await ctx.send("**Choose any one for futher operation:-\nFor new quiz enter `'1'`\nTo continue the old one enter `'2'`\nIf none then enter cancel.**")
msg=await time(ctx,bot,300,"**No response recieved ,process has been reverted try again.**")
d= msg.content
if d=="1":
f1=open("quiz.txt","w")
i=0
while i<c:
f1.write(f"{l1[i]}|{1}"+"\n")
i+=1
await ctx.send("File has been created")
return
elif d=="2":
f1=open("quiz.txt","r")
a1=f1.readlines()
a2=len(a1)
dic={}
for item in a1:
l2=item.split("|")
dic[l2[0]]=int(l2[1])
await ctx.send("**Choose any one for futher operation:-\nFor final result enter `'1'`\nTo continue enterting scores enter `'2'`\nIf none then enter cancel.**")
msg=await time(ctx,bot,300,"**No response recieved ,process has been reverted try again.**")
a1=msg.content
if a1=="1":
l3=[]
st=sorted(dic.items(),key=lambda x:x[1],reverse=True)
await ctx.send("**Final Score**")
o=0
for i in st:
if o<50:
f=f"<@{i[0]}> - {i[1]}"
l3.append(f)
o+=1
else:
l4="\n".join(l3)
await ctx.send(f"`{l4}`")
l3=[]
o=0
if 0<o<50:
l4="\n".join(l3)
await ctx.send(f"`{l4}`")
elif a1=="2":
for i in l1:
if i in dic.keys():
dic[i]+=1
else:
dic[i]=1
l3=[]
st=sorted(dic.items(),key=lambda x:x[1],reverse=True)
for i in st:
f=f"<@{i[0]}> - {i[1]}"
l3.append(f)
l4="\n".join(l3)
f1.close()
f1=open("quiz.txt","w")
o=0
l3=[]
await ctx.send(f"Final Score")
for i in st:
f1.write(f"{i[0]}|{i[1]}"+"\n")
if o<50:
f=f"<@{i[0]}> - {i[1]}"
l3.append(f)
o+=1
else:
l4="\n".join(l3)
await ctx.send(f"`{l4}`")
l3=[]
o=0
if 0<o<50:
l4="\n".join(l3)
await ctx.send(f"`{l4}`")
await ctx.send("Scores has been updated")
elif a1.lower()=="cancel":
await ctx.send("wokay")
return
else:
await ctx.send("Wrong selection , try again from start")
elif d.lower()=="cancel":
await ctx.send("wokay")
return
else:
await ctx.send("Wrong selection , try again from start")
@bot.command()
async def slot(ctx):
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
await ctx.send("2mins will be given for each entry.\nEnter group no.:")
a = True
while a == True:
try:
msg = await bot.wait_for("message", timeout=120, check=check)
except asyncio.TimeoutError:
await ctx.send("`Time's up. Process has been cancelled, try again`"
)
return
a1 = int(msg.content)
a4 = str(msg.content)
a2 = len(msg.content)
if type(a1) == int:
if 1 < a2 < 3:
await ctx.send(
"Now Enter the team names.\nEnter 'Stop' when the group is to be filled with lesser members.\nEnter 'Cancel' to stop the process. \n(Per group limit is 20 only)"
)
a = False
else:
await ctx.send("Group no. should be 2 digits long")
a = True
else:
await ctx.send("Group no, should be an integer number")
a = True
i = 0
b = []
while i < 20:
await ctx.send("Team no {}".format(i + 1))
try:
msg = await bot.wait_for("message", timeout=120, check=check)
except asyncio.Timeouterror:
await ctx.send("`Time's up, process has been cancelled try again.`"
)
return
b1 = msg.content
if b1.lower() == "cancel":
await ctx.send("The process has been cancelled.")
return
elif b1.lower() == 'stop':
i = 20
await ctx.send("Stopped entering process.")
else:
b.append(b1)
i += 1
im=Image.open("vgg.png")
mio = await ctx.send("**Started entering Team records**")
font2 = ImageFont.truetype("fonts/Roboto-mono.ttf",40)
font1 = ImageFont.truetype("fonts/Collegehm.ttf",0)
font = ImageFont.truetype("fonts/Landm.otf",50)
a = [30,600]
ko=[400, 465, 530, 595, 660, 725, 790, 855, 920, 985,400, 465, 530, 595, 660, 725, 790, 855, 920, 985]
col=(255,255,255)
d = ImageDraw.Draw(im)
mn=len(b)
i=0
while i<10:
draw = d.text((a[0], ko[i]), f"{i+1}.{b[i]}", col, font=font2)
await mio.edit(content="**Data of team {} has been successfully entered <a:emoji_55:856633188485955584> **".format(b[i]))
i+=1
while 9<i<mn:
draw = d.text((a[1], ko[i]), f"{i+1}.{b[i]}", col, font=font2)
await mio.edit(content="**Data of team {} has been successfully entered <a:emoji_55:856633188485955584> **".format(b[i]))
i+=1
im.save("res.png")
await mio.edit(content="**Successfully entered all the records <a:emoji_55:856633188485955584>,uploading the file**")
await ctx.send(file=discord.File("res.png"))
l2 = "\n".join(b)
await ctx.send("**__Group no. {}__\n{}**".format(a4, l2))
@bot.command()
@commands.has_permissions(administrator=True)
async def setup(ctx):
a = ctx.guild.roles
b = ["Result Manager", "Result creator"]
z = []
d = len(a)
a1 = ctx.guild.channels
a2 = discord.utils.get(a1, name="points-table-data")
i = 0
while i < d:
if b[0] in str(a[i]):
z.append("m")
i += 1
elif b[1] in str(a[i]):
z.append("c")
i += 1
else:
i += 1
if str(a2) == "points-table-data":
z.append("ch")
a4 = discord.utils.get(a, name=b[0])
a5 = discord.utils.get(a, name=b[1])
if len(z) == 2 and str(a2) != "None":
lo = await ctx.send("Chill dude. It has been already done.")
await asyncio.sleep(5)
await lo.delete
if len(z) == 0:
role1 = await ctx.guild.create_role(name=b[0],
color=discord.Color(0x2943DC))
role2 = await ctx.guild.create_role(name=b[1],
color=discord.Color(0x0A80DC))
a3 = await ctx.guild.create_text_channel("points table data")
await a3.set_permissions(a5,
read_messages=True,
send_messages=False,
view_channel=True)
await a3.set_permissions(a4,
read_messages=True,
send_messages=True,
view_channel=True)
await a3.set_permissions(ctx.guild.default_role,
read_messages=False,
send_messages=False,
view_channel=False)
embed = discord.Embed(
description="I will be creating 2 roles namely{} and {}\n".format(
role1.mention, role2.mention),
color=discord.Color(red))
l = "{}\nThis role gives permission to use result creation command\n\n{}\nThis roles gives permission to manage and to delete saved result data\n\n{} channel has been created where the backup will be uploaded of each record.It's still under development so it might have some issues while running.Don't delete or rename this channel as it will affect the working of the bot.".format(
role2.mention, role1.mention, a3.mention)
embed.add_field(name="ROLE INFORMATION", value=l)
await ctx.send(embed=embed)
i = 0
z = []
while i < d:
if b[0] in str(a[i]):
z.append("m")
i += 1
elif b[1] in str(a[i]):
z.append("c")
i += 1
else:
i += 1
if str(a2) == "points-table-data":
z.append("ch")
if "c" not in z:
role2 = await ctx.guild.create_role(name=b[1],
color=discord.Color(0x0A80DC))
embed = discord.Embed(
description=
"Seems like {} role is missong so it has been created.\n\nThis role gives permission to use result creation command.\n Assign this role to the members and get started"
.format(role2.mention),
color=discord.Color(red))
await ctx.send(embed=embed)
if "m" not in z:
role1 = await ctx.guild.create_role(name=b[0],
color=discord.Color(0x2943DC))
embed = discord.Embed(
description=
"Seems like {} role eas missong so it has been created.\n\nThis roles gives permission to manage and to delete saved result data\n Assign this role to the members and get started"
.format(role1.mention),
color=discord.Color(red))
await ctx.send(embed=embed)
if "ch" not in z:
overwrites = {
ctx.guild.default_role:
discord.PermissionOverwrite(read_messages=False,
send_messages=False,
view_channel=False),
a4:
discord.PermissionOverwrite(read_messages=True,
send_messages=True,
view_channel=True),
a5:
discord.PermissionOverwrite(read_messages=True,
send_messages=False,
view_channel=True)
}
a3 = await ctx.guild.create_text_channel("points table data",
overwrites=overwrites)
embed = discord.Embed(
description=
"{} channel has been created where the backup will be uploaded of each record.It's still under development so it might have some issues while running.Don't delete or rename this channel as it will affect the working of the bot."
.format(a3.mention),
color=discord.Color(red))
await ctx.send(embed=embed)
@setup.error
async def setup_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
embed = discord.Embed(
description="You must have admin perms to use this command",
color=discord.Color(red))
await ctx.send(embed=embed)
async def fcreate(ctx):
a1=os.listdir()
n1=str(ctx.author.id)
if n1 in a1:
return
else:
a2= str(f"{ctx.author.id}")
os.makedirs(a2)
a3=str(f"{ctx.author.id}/rec.txt")
f1=open(a3,"w")
f1.close()
a1=True
return a1
@bot.command()
async def new(ctx):
await vgret(ctx)
@bot.command()
@commands.has_any_role("Result creator", "Result Manager")
async def rest(ctx,*,a):
a1=await fcreate(ctx)
if a1==True:
await cembed(ctx,red,"Your private folders have been created,you can use the saved data in all the servers where the bot exists",None)
await res(ctx,bot,a)
@rest.error
async def res_error(ctx, error):
red = int("ff0000", 16)
if isinstance(error, discord.ext.commands.errors.MissingRequiredArgument):
file = discord.File('asta.gif', filename="image.gif")
embed = discord.Embed(
title="ERROR!",
description=
"`{}rest [slotlist]`\n Run the command in the following format".
format(prefix),
color=discord.Color(red))
embed.set_image(url="attachment://image.gif")
await ctx.send(embed=embed, file=file)
if isinstance(error, commands.MissingAnyRole):
embed = discord.Embed(
description=
"You must have one of the following roles to use this command:-\n\n1) Result Manager\n2) Result creator",
color=discord.Color(red))
await ctx.send(embed=embed)
@bot.command()
@commands.has_any_role("Result creator", "Result Manager")
async def rt(ctx):
a1=await fcreate(ctx)
if a1==True:
await cembed(ctx,red,"Your private folders have been created,you can use the saved data in all the servers where the bot exists",None)
await restt(ctx,bot)
@rt.error
async def rt_error(ctx, error):
if isinstance(error, commands.MissingAnyRole):
embed = discord.Embed(
description=
"You must have one of the following roles to use this command:-\n\n1) Result Manager\n2) Result creator",
color=discord.Color(red))
await ctx.send(embed=embed)
@bot.command()
@commands.has_any_role("Result creator", "Result Manager")
async def res23(ctx, *, a):
a1 = ctx.guild.channels
red = int("ff0000", 16)
a2 = discord.utils.get(a1, name="points-table-data")
if str(a2) == "None":
embed = discord.Embed(
description=
"Unable to fetch the backup channel created by the bot. use `{}setup` command to remove this issue."
.format(prefix),
color=discord.Color(red))
await ctx.send(embed=embed)
return
p = re.compile('Team.*')
rawlist = p.findall(a)
testvalue = len(rawlist)
await ctx.message.delete()
idlist = []
teamlist = []
killpoint1 = []
killpoint2 = []
matchplay = []
pospoint1 = []
pospoint2 = []
chicken = []
i = 0
while i < testvalue:
chicken.append(0)
i += 1
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
ton = open("weekdata(2-3)/rec.txt", "a+")
kl = open("weekdata(2-3)/Days(2-3).txt", "r+")
days = int(kl.read(1))
if days == 6:
embed = discord.Embed(
title="Weekly data collected",
description=
" Data of past 7 matches has already been collected, further match data cannot be sotred until weekly results have been created. Use the command ` {}weekly` to get the weekly result"
.format(prefix),
color=discord.Color(red))
await ctx.send(embed=embed)
return
else:
poi = datetime.datetime.now()
i = "weekdata(2-3)/Day{}.txt".format(days + 1)
tor = open(i, "w")
for item in rawlist:
rie = item.replace("Team", "")
teamlist.append(rie)
if len(teamlist) < 3:
await ctx.send(
"Improper data entered, process has been cancelled try again")
return
i = 0
a = """**Now enter the details of the teams being asked in the Following format.**
**__Format__:-**
`[Matches played],[Rank in match 1,enter 0 if not played],[Kills in match 1,enter 0 if no kills or not played],[Rank in match 2 , enter 0 if not played],[Kills in match enter 0 if no kills or match not played]`
5 minutes will be given for each entry.
**Enter cancel to quit the process at any stage.**"""
embed = discord.Embed(title="DAY {} match data entry".format(days + 1),
description=a,
color=discord.Color(red))
embed.set_footer(text="MONKEY D. LUFFY")
await ctx.send(embed=embed)
while i < testvalue:
q = await ctx.send("""**Slot no.{} team {}**""".format(
i + 1, teamlist[i]))
try:
msg = await bot.wait_for('message', timeout=300, check=check)
except asyncio.TimeoutError:
await ctx.send(
'You didn\'t answer in time, please be quicker next time!')
return
g = msg.content
h = g.split(",")
if len(h) == 5:
matchplay.append(int(h[0]))
if int(h[1]) == 1:
chicken[i] = chicken[i] + 1
await ctx.send("1 up")
pospoint1.append(int(h[1]))
if int(h[3]) == 1:
chicken[i] = chicken[i] + 1
await ctx.send("2 up")
pospoint2.append(int(h[3]))
killpoint1.append(int(h[2]))
killpoint2.append(int(h[4]))
i += 1
elif g.lower() == "cancel":
await ctx.send("`Result creation has been cancelled`")
return
else:
embed1 = discord.Embed(
description=
"**Values entered in inappropriate manner,try again from start**",
color=discord.Color(red))
await ctx.send(embed=embed1)
totalpoint = []
killf = []
posf = []
i = 0
pos = [
0, 15, 12, 10, 8, 6, 4, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0
]
while i < testvalue:
e = killpoint1[i] + killpoint2[i]
killf.append(e)
c = pos[pospoint1[i]] + pos[pospoint2[i]]
posf.append(c)
i += 1
i = 0
while i < testvalue:
a = killf[i] + posf[i]
totalpoint.append(a)
i += 1
async def sheet():
workbook = xlsxwriter.Workbook('Pointstable.xlsx')
worksheet = workbook.add_worksheet()
titles = [
"Place", "Team name", "M", "Chicken", "Pos pts", "Kill pts",
"Total pts"
]
i = 1
place = []
while i < (testvalue + 1):
place.append(i)
i += 1
worksheet.write_row(0, 0, titles)
worksheet.write_column(1, 0, place)
worksheet.write_column(1, 1, ntl)
worksheet.write_column(1, 2, nm)
worksheet.write_column(1, 3, nc)
worksheet.write_column(1, 4, np)
worksheet.write_column(1, 5, nk)
worksheet.write_column(1, 6, nt)
workbook.close()
await ctx.send(file=discord.File("Pointstable.xlsx"))
x = PrettyTable()
x.field_names = [
"Place", "Team name", "M", "Chicken", "Pos pts", "Kill pts",
"Total pts"
]
i = 0
e = 0
clone = totalpoint.copy()
clone.sort(reverse=True)
elist = []
ntl = []
nm = []
np = []
nk = []
nt = []
nc = []
while i < testvalue:
if e in elist:
e += 1
else:
if totalpoint[e] == clone[i]:
ntl.append(str(teamlist[e]))
nm.append(str(matchplay[e]))
np.append(str(posf[e]))
nk.append(str(killf[e]))
nt.append(str(totalpoint[e]))
nc.append(str(chicken[e]))
i += 1
elist.append(e)
e = 0
else:
e += 1
q = True
ji = len(ntl)
i = 0
while q == True:
if i == ji - 1:
q = False
elif clone[i] == clone[i + 1]:
if nk[i] < nk[i + 1]:
c1, c2, c3, c4, c5, c6 = ntl[i], nm[i], nc[i], np[i], nk[
i], nt[i]
c11, c12, c13, c14, c15, c16 = ntl[i + 1], nm[i + 1], nc[
i + 1], np[i + 1], nk[i + 1], nt[i + 1]
ntl[i], nm[i], nc[i], np[i], nk[i], nt[
i] = c11, c12, c13, c14, c15, c16
ntl[i + 1], nm[i + 1], nc[i + 1], np[i + 1], nk[i + 1], nt[
i + 1] = c1, c2, c3, c4, c5, c6
i = 0
else:
i += 1
else:
i += 1
e = 0
while e < ji:
x.add_row([(i + 1), ntl[e], nm[e], nc[e], np[e], nk[e], nt[e]])
e += 1
embed = discord.Embed(title="Points table",
description=x,
color=discord.Color(red))
await ctx.send(embed=embed)
q = True
while q:
await ctx.send(
"**Choose from the options given below\nTo make chnages to the points of a specific Team type `'1'`\nTo enter record of a new team type `'2'`\nTo save and make the result type `'3'`**"
)
try:
msg = await bot.wait_for("message", timeout=300, check=check)
except:
await ctx.send(
"You didn't answered so the process has been cancelled")
return
o = msg.content
x = """**From the previous points table preview enter the changed data with the unchanged data as entered before in the given format.
**__Format__:-**[Place of team according to the ponints table preview],[Matches played],[Rank in match 1,enter 0 if not played],[Kills in match 1,enter 0 if no kills or not played],[Rank in match 2 , enter 0 if not played],[Kills in match enter 0 if no kills or match not played]**"""
c = discord.Embed(title="CORRECTION FORMAT",
description=x,
color=discord.Color(red))
embed.set_footer(
text=
"if not answered in 5 mins the process will automatically be cancelled"
)
if o == "1":
await ctx.send(embed=c)
try:
msg = await bot.wait_for("message", timeout=300, check=check)
except asyncio.TimeoutError:
await ctx.send(
"Didn't got any response, process has been reverted")
return
e = msg.content
lis = e.split(",")
h = []
for item in lis:
h.append(int(item))
i = 0
c = 0
b = int(lis[0]) - 1
if len(lis) == 6:
io = True
while io:
if ntl[b] == teamlist[c]:
matchplay[c] = h[1]
chicken[c] = 0
if h[2] == 1:
chicken[c] = chicken[c] + 1
if h[4] == 1:
chicken[c] = chicken[c] + 1
posf[c] = pos[h[2]] + pos[h[4]]
killf[c] = h[3] + h[5]
totalpoint[c] = posf[c] + killf[c]
c = 0
x = PrettyTable()
x.field_names = [
"Place", "Team name", "M", "Chicken", "Pos pts",
"Kill pts", "Total pts"
]
i = 0
e = 0
clone = totalpoint.copy()
clone.sort(reverse=True)
elist = []
ntl = []
nm = []
np = []
nk = []
nt = []
nc = []
while i < testvalue:
if e in elist:
e += 1
else:
if totalpoint[e] == clone[i]:
ntl.append(str(teamlist[e]))
nm.append(str(matchplay[e]))
np.append(str(posf[e]))
nk.append(str(killf[e]))
nt.append(str(totalpoint[e]))
nc.append(str(chicken[e]))
i += 1
elist.append(e)
e = 0
else:
e += 1
q1 = True
await ctx.send("Details fetched")
ji = len(ntl)
i = 0
while q1 == True:
if i == ji - 1:
q1 = False
elif clone[i] == clone[i + 1]:
if nk[i] < nk[i + 1]:
c1, c2, c3, c4, c5, c6 = ntl[i], nm[i], nc[
i], np[i], nk[i], nt[i]
c11, c12, c13, c14, c15, c16 = ntl[
i +
1], nm[i +
1], nc[i +
1], np[i +
1], nk[i +
1], nt[i +
1]
ntl[i], nm[i], nc[i], np[i], nk[i], nt[
i] = c11, c12, c13, c14, c15, c16
ntl[i + 1], nm[i + 1], nc[i + 1], np[
i + 1], nk[i + 1], nt[
i + 1] = c1, c2, c3, c4, c5, c6
i = 0
else:
i += 1
else:
i += 1
i = 0
while i < ji:
x.add_row([(i + 1), ntl[i], nm[i], nc[i], np[i],
nk[i], nt[i]])
i += 1
embed = discord.Embed(title="Changed data",
description=x,
color=discord.Color(red))
await ctx.send(embed=embed)
io = False
else:
c += 1
else:
embed = discord.Embed(
description=
"**Values entered in inappropriate manner,try again**",
color=discord.Color(red))
await ctx.send(embed=embed)
elif o == "2":
testvalue += 1
ex = [
"Enter the team name:", "Enter no. of matches played",
"Enter rank in match 1,type 0 if not played:",
"Enter no. of kills in match 1:",
"Enter rank in match 2,enter 0 if not played",
"Enter no. of kills in match 2"
]
i = 0
lis = []
while i < 6:
await ctx.send("**{}**".format(ex[i]))
try:
msg = await bot.wait_for("message",
timeout=300,
check=check)
except asyncio.TimeoutError:
await ctx.send(
"Didn't got any response, process has been reverted")
return
lis.append(msg.content)
i += 1
teamlist.append(str(lis[0]))
ch = 0
del lis[0]
matchplay.append(int(lis[0]))
if lis[1] == 1:
ch += 1
if lis[3] == 1:
ch += 1
chicken.append(ch)
posf.append(pos[int(lis[1])] + pos[int(lis[3])])
killf.append(int(lis[2]) + int(lis[4]))
totalpoint.append(pos[int(lis[1])] + pos[int(lis[3])] +
int(lis[2]) + int(lis[4]))
x = PrettyTable()
x.field_names = [
"Place", "Team name", "M", "Chicken", "Pos pts", "Kill pts",
"Total pts"
]
i = 0
e = 0
clone = totalpoint.copy()
clone.sort(reverse=True)
elist = []
ntl = []
nm = []
np = []
nk = []
nt = []
nc = []
while i < testvalue:
if e in elist:
e += 1
else:
if totalpoint[e] == clone[i]:
ntl.append(str(teamlist[e]))
nm.append(str(matchplay[e]))
np.append(str(posf[e]))
nk.append(str(killf[e]))
nt.append(str(totalpoint[e]))
nc.append(str(chicken[e]))
i += 1
elist.append(e)
e = 0
else:
e += 1
q1 = True
ji = len(ntl)
i = 0
while q1 == True:
if i == ji - 1:
q1 = False
elif clone[i] == clone[i + 1]:
if nk[i] < nk[i + 1]:
c1, c2, c3, c4, c5, c6 = ntl[i], nm[i], nc[i], np[
i], nk[i], nt[i]
c11, c12, c13, c14, c15, c16 = ntl[i + 1], nm[
i + 1], nc[i + 1], np[i + 1], nk[i + 1], nt[i + 1]
ntl[i], nm[i], nc[i], np[i], nk[i], nt[
i] = c11, c12, c13, c14, c15, c16
ntl[i + 1], nm[i + 1], nc[i + 1], np[i + 1], nk[
i + 1], nt[i + 1] = c1, c2, c3, c4, c5, c6
i = 0
else:
i += 1
else:
i += 1
i = 0
while i < ji:
x.add_row([(i + 1), ntl[i], nm[i], nc[i], np[i], nk[i], nt[i]])
i += 1
embed = discord.Embed(title="Points table",
description=x,
color=discord.Color(red))
await ctx.send(embed=embed)
elif o == "3":
await sheet()
i = 0
place = []
while i < testvalue:
a = 1 + i
place.append(str(a))
i += 1
im1 = Image.open('img1.png')
im2 = Image.open('img2.png')
async def get_concat_v_cut(im1, im2):
i = 0
mio = await ctx.send("**Started entering Team records**")
dst = Image.new('RGB', (im2.width,
(im1.height + testvalue * im2.height)))
dst.paste(im1, (0, 0))
font1 = ImageFont.truetype("fonts/Lemonb.otf", 200)
font = ImageFont.truetype("fonts/Landm.otf", 300)
a = [240, 500, 2500, 2900, 3500, 4030, 4550]
im2.close()
ko = 100
mn = testvalue
while i < mn:
im2 = Image.open('img2.png')
d = ImageDraw.Draw(im2)
draw = d.text((a[0], ko), place[i], (0, 0, 0), font=font1)
draw = d.text((a[1], ko), ntl[i], (0, 0, 0), font=font)
draw = d.text((a[2], ko), nc[i], (0, 0, 0), font=font1)
draw = d.text((a[3], ko), nm[i], (0, 0, 0), font=font1)
draw = d.text((a[4], ko), nk[i], (0, 0, 0), font=font1)
draw = d.text((a[5], ko), np[i], (0, 0, 0), font=font1)
draw = d.text((a[6], ko), nt[i], (0, 0, 0), font=font1)
dst.paste(im2, (0, (im1.height + i * im2.height)))
await mio.edit(
content=
"**Data of team {} has been successfully entered <a:emoji_55:856633188485955584> **"
.format(ntl[i]))
i += 1
im2.close()
await mio.edit(
content=
"**Successfully entered all the records <a:emoji_55:856633188485955584>,uploading the file**"
)
dst.save("res.jpg")
await ctx.send(file=discord.File("res.jpg"))
await get_concat_v_cut(im1, im2)
nl = "\n"
wtl = ",".join(ntl)
tor.writelines(wtl + nl)
wm = ",".join(nm)
tor.writelines(wm + nl)
wc = ",".join(nc)
tor.writelines(wc + nl)
wp = ",".join(np)
tor.writelines(wp + nl)
wk = ",".join(nk)
tor.writelines(wk + nl)
wt = ",".join(nt)
tor.writelines(wt + nl)
tor.close()
kl.seek(0)
days += 1
j1 = "**2-3pm result**\nDay{}.txt\n{}\nMade by:- {}".format(
days, poi.strftime("%c"), ctx.author.mention)
j2 = "Day{}.txt\n{}\n".format(days, poi.strftime("%c"))
ton.write(j2)
ton.seek(0)
lm = "Day{}.txt".format(days)
cv = ton.read()
a4 = "weekdata(2-3)/" + lm
await a2.send(j1, file=discord.File(a4))
kl.write(str(days))
ton.close()
kl.close()
q = False
elif o.lower() == "cancel":
await ctx.send("`Result creation has been cancelled`")
return
else:
l = await ctx.send("**Inappropriate answer.**")
await asyncio.sleep(5)
await l.delete()
@res23.error
async def res23_error(ctx, error):
red = int("ff0000", 16)
if isinstance(error, discord.ext.commands.errors.MissingRequiredArgument):
file = discord.File('asta.gif', filename="image.gif")
embed = discord.Embed(
title="ERROR!",
description=
"`{}res23 [slotlist]`\n Run the command in the following format".
format(prefix),
color=discord.Color(red))
embed.set_image(url="attachment://image.gif")
await ctx.send(embed=embed, file=file)
if isinstance(error, commands.MissingAnyRole):
embed = discord.Embed(
description=
"You must have one of the following roles to use this command:-\n\n1) Result Manager\n2) Result creator",
color=discord.Color(red))
await ctx.send(embed=embed)
@bot.command()
async def weekly23(ctx):