-
Notifications
You must be signed in to change notification settings - Fork 0
/
[.py
210 lines (165 loc) · 8.19 KB
/
[.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
import discord
from discord import Member
from discord.ext import commands
from discord.utils import get
import pandas as pd
import numpy as np
from discord.ext import commands
from zipfile import BadZipFile
#Nickname K A D Diff k/d Maps Maps Won Games Games Won Rounds Rounds won Coef DRP
#SVR KPR Impact RPG Rating sand_rounds sand_rounds_won rust_rounds rust_rounds_won zone9_rounds zone9_rounds_won province_rounds province_rounds_won
bot = commands.Bot(command_prefix='-')
p = pd.read_excel('f1.xlsx')
nicks = []
for i in range(len(p)):
nicks.append(p['Nick'][i])
c = list(p.columns)
c = c[:-1]
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
maps = ["Sandstone", "Rust", "Zone9", "Province"]
@bot.command()
async def stats(ctx, member: Member):
p = pd.read_excel('f1.xlsx')
nicks = []
for i in range(len(p)):
nicks.append(p['Nick'][i])
c = list(p.columns)
c = c[:-1]
output = ''
nick = member.name
if nick in nicks:
npy = p.loc[p['Nick'] == nick].to_numpy()
npy = npy[:, :-1]
for i in range(len(c)):
if c[i] in ["Nick", "K", "D", "SVR", "k/d", "Rating", "Maps", "Maps win rate", "Win rate on Sandstone", "Win rate on Rust", "Win rate on Zone 9", "Win rate on Province"]:
output = output + str(c[i]) + ": " + str(npy[0][i]) + '\n'
embed = discord.Embed(title = 'Ваша персональная статистика', description = '**' +output+ '**', color = discord.Color.blue())
await ctx.send(embed = embed)
elif nick not in nicks:
await ctx.send('Такого нет в дата базе')
a = str(ctx.author.roles)
a = a.split(',')
idr = []
for i in range(len(a)):
k = a[i].split(' ')
if k[0]!='[<Role':
del k[0]
k1 = k[1].split('=')
idr.append(k1[1])
role = str()
if "@everyone" in ctx.author.roles:
print("oda")
@bot.command()
async def mystats(ctx):
p = pd.read_excel('f1.xlsx')
nicks = []
for i in range(len(p)):
nicks.append(p['Nick'][i])
c = list(p.columns)
c = c[:-1]
output = ''
nick = ctx.author.name
if nick in nicks:
npy = p.loc[p['Nick'] == nick].to_numpy()
npy = npy[:, :-1]
for i in range(len(c)):
if c[i] in ["Nick", "K", "D", "SVR", "k/d", "Rating", "Maps", "Maps win rate", "Win rate on Sandstone", "Win rate on Rust", "Win rate on Zone 9", "Win rate on Province"]:
output = output + str(c[i]) + ": " + str(npy[0][i]) + '\n'
embed = discord.Embed(title = 'Ваша персональная статистика', description = '**' +output+ '**', color = discord.Color.blue())
await ctx.send(embed = embed)
elif nick not in nicks:
await ctx.send('Такого нет в дата базе')
@bot.command()
async def add(ctx, member: Member, arg):
maps = ["Sandstone", "Rust", "Zone9", "Province"]
p = pd.read_excel('f1.xlsx')
nicks = []
for i in range(len(p)):
nicks.append(p['Nick'][i])
c = list(p.columns)
c = c[:-1]
j = -1
adds = arg.split('-')
for i in range(len(adds)):
if i!=3:
adds[i] = int(adds[i])
nick = member.name
if nick in nicks:
for i in range(len(c)):
if c[i] in ["K", "A", "D"]:
j= j +1
p.loc[p['Nick'] == nick, c[i]] = p.loc[p['Nick'] == nick, c[i]] + int(adds[j])
p.loc[p['Nick'] == nick, 'Maps'] = p.loc[p['Nick'] == nick, 'Maps'] +1
tr = adds[4] + adds[5]
p.loc[p['Nick'] == nick, 'Rounds'] = p.loc[p['Nick'] == nick, 'Rounds'] +int(tr)
p.loc[p['Nick'] == nick, 'Rounds won'] = p.loc[p['Nick'] == nick, 'Rounds won'] +adds[4]
else:
j = -1
zr = pd.DataFrame(np.zeros((1, len(c))), columns = c)
p = p.append(zr)
p.iloc[len(p)-1, 0] = nick
for i in range(len(c)):
if c[i] in ["K", "A", "D"]:
j= j +1
p.loc[p['Nick'] == nick, c[i]] = p.loc[p['Nick'] == nick, c[i]] + int(adds[j])
p.loc[p['Nick'] == nick, 'Maps'] = p.loc[p['Nick'] == nick, 'Maps'] +1
tr = adds[4] + adds[5]
p.loc[p['Nick'] == nick, 'Rounds'] = p.loc[p['Nick'] == nick, 'Rounds'] +int(tr)
p.loc[p['Nick'] == nick, 'Rounds won'] = p.loc[p['Nick'] == nick, 'Rounds won'] +adds[4]
if adds[4] > adds[5]:
p.loc[p['Nick'] == nick, 'Maps won'] = p.loc[p['Nick'] == nick, 'Maps won'] +1
if adds[3] == maps[0]:
p.loc[p['Nick'] == nick, 'sr'] = p.loc[p['Nick'] == nick, 'sr'] + int(tr)
p.loc[p['Nick'] == nick, 'srw'] = p.loc[p['Nick'] == nick, 'srw'] +int(adds[4])
p.loc[p['Nick'] == nick, 'sm'] = p.loc[p['Nick'] == nick, 'sm'] +1
if adds[4] > adds[5]:
p.loc[p['Nick'] == nick, 'smw']= p.loc[p['Nick'] == nick, 'smw'] +1
p.loc[p['Nick'] == nick, 'Win rate on Sandstone'] = round(p.loc[p['Nick'] == nick, 'smw']*100/p.loc[p['Nick'] == nick, 'sm'], 2)
elif adds[3] == maps[1]:
p.loc[p['Nick'] == nick, 'rr'] = p.loc[p['Nick'] == nick, 'rr'] +int(tr)
p.loc[p['Nick'] == nick, 'rrw'] = p.loc[p['Nick'] == nick, 'rrw'] + int(adds[4])
p.loc[p['Nick'] == nick, 'rm'] = p.loc[p['Nick'] == nick, 'rm'] +int(1)
if adds[4] > adds[5]:
p.loc[p['Nick'] == nick, 'rmw'] = p.loc[p['Nick'] == nick, 'rmw'] + 1
p.loc[p['Nick'] == nick, 'Win rate on Rust'] = round(p.loc[p['Nick'] == nick, 'rmw']*100/p.loc[p['Nick'] == nick, 'rm'], 2)
elif adds[3] == maps[2]:
p.loc[p['Nick'] == nick, 'zr'] = p.loc[p['Nick'] == nick, 'zr'] +int(tr)
p.loc[p['Nick'] == nick, 'zrw'] = p.loc[p['Nick'] == nick, 'zrw'] +int(adds[4])
p.loc[p['Nick'] == nick, 'zm'] = p.loc[p['Nick'] == nick, 'zm'] +1
if adds[4] > adds[5]:
p.loc[p['Nick'] == nick, 'zmw']= p.loc[p['Nick'] == nick, 'zmw'] +1
p.loc[p['Nick'] == nick, 'Win rate on Zone9'] = round(p.loc[p['Nick'] == nick, 'zmw']*100/p.loc[p['Nick'] == nick, 'zm'], 2)
elif adds[3] == maps[3]:
p.loc[p['Nick'] == nick, 'pr'] = p.loc[p['Nick'] == nick, 'pr'] +int(tr)
p.loc[p['Nick'] == nick, 'prw'] = p.loc[p['Nick'] == nick, 'prw'] +int(adds[4])
p.loc[p['Nick'] == nick, 'pm'] = p.loc[p['Nick'] == nick, 'pm'] +1
if adds[4] > adds[5]:
p.loc[p['Nick'] == nick, 'pmw']= p.loc[p['Nick'] == nick, 'pmw'] +1
p.loc[p['Nick'] == nick, 'Win rate on Province'] = round(p.loc[p['Nick'] == nick, 'pmw']*100/p.loc[p['Nick'] == nick, 'pm'], 2)
p.loc[p['Nick'] == nick, 'Maps win rate'] = round(100*p.loc[p['Nick'] == nick, 'Maps won']/p.loc[p['Nick'] == nick, 'Maps'], 2)
p.loc[p['Nick'] == nick, 'Rounds win rate'] = round(100*p.loc[p['Nick'] == nick, 'Rounds won']/p.loc[p['Nick'] == nick, 'Rounds'], 2)
p.loc[p['Nick'] == nick, 'Diff'] = 1
p.loc[p['Nick'] == nick, 'k/d'] = 1
p.loc[p['Nick'] == nick, 'DRP'] = 1
p.loc[p['Nick'] == nick, 'SVR'] = 1
p.loc[p['Nick'] == nick, 'KPR'] = 1
p.loc[p['Nick'] == nick, 'Impact'] = 1
drp = p.loc[p['Nick'] == nick, 'DRP'].astype(float)
Impact = p.loc[p['Nick'] == nick, 'Impact'].astype(float)
kpr = p.loc[p['Nick'] == nick, 'KPR'].astype(float)
rw = p.loc[p['Nick'] == nick, 'Rounds win rate'].astype(float)
p.loc[p['Nick'] == nick, 'RPG'] = 1
rpg = 1
maxround = p['Rounds'].max()
p.loc[p['Nick'] == nick, 'Coef'] = 1
coef = 1
p.loc[p['Nick'] == nick, 'Rating'] = 1
a = "Статистика " + str(nick) +" была обновленна!"
with pd.ExcelWriter('f1.xlsx') as writer:
p.to_excel(writer, index = False)
embed = discord.Embed(title = a, color = discord.Color.blue())
await ctx.send(embed = embed)
bot.run('NzM1NzExNDE0OTE1ODI1Njc1.XxkOpg.R0KkSl7DaJnN8XlytrQRUKTPbKk')
"""@commands.has_any_role(781542383904620574)"""