-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathda.py
173 lines (139 loc) · 5.58 KB
/
da.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
#import donationalerts as daa
import logging
import asyncio
import numpy
import os
from io import BytesIO
from PIL import Image
#alert = daa.Alert("jCzYqIMrhfX1cn3GeK3B")
alerting_id = -1
if not os.path.isfile("data/donations.npy"):
donateList = [["ModErator5937", 2197, 1255297867, 2222],
["ReZoort", 501, 1017884431, 501],
["veel1en", 400.99, 1084649863, 400.99],
["rorik", 350, 1418299420, 350],
["Гамдав", 25, 995824148, 50],
["Vadalast", 30, 1070500942, 30],
["_WavyCat_", 25, 792035746, 25]]
numpy.save(arr=numpy.array(donateList), file="data/donations.npy")
else:
donateList_npy = numpy.load("data/donations.npy")
donateList = donateList_npy.tolist()
bot = None
def init(bot1, dp1):
global bot
global dp
bot = bot1
dp = dp1
da_event = -1
def sortir(donateList):
for x_s in range(len(donateList)):
for x in range(len(donateList) - 1):
if float(donateList[x][3]) < float(donateList[x + 1][3]):
topid = donateList[x][0]
topsc = donateList[x][1]
topidd = donateList[x][2]
topscm = donateList[x][3]
donateList[x][3] = donateList[x + 1][3]
donateList[x][2] = donateList[x + 1][2]
donateList[x][1] = donateList[x + 1][1]
donateList[x][0] = donateList[x + 1][0]
donateList[x + 1][3] = topscm
donateList[x + 1][2] = topidd
donateList[x + 1][1] = topsc
donateList[x + 1][0] = topid
return donateList
#@alert.event()
def new_donation(event):
global donateList
global alerting_id
finded = False
id = -1
idd = -1
username = event.username
if username == None: username = "Аноним"
last_balance = 0
balance_now = 0
if event.message != None:
try: id = int(event.message.split(" ")[0])
except:pass
if True: #if event.username != "AndcoolSystems":
for x in range(len(donateList)):
if username == donateList[x][0]:
last_balance = float(donateList[x][1])
id = int(donateList[x][2])
try:
if event.additional_data['is_commission_covered'] == 1:
add = (float(event.amount_main) / 100) * 11.12
else: add = 0
except: add = 0
donateList[x][1] = float(event.amount_main) + float(donateList[x][1]) + add
try:
if int(donateList[x][2]) == -1: donateList[x][2] = int(event.message.split(" ")[0])
except: pass
finded = True
idd = x
to_pop = []
if idd != -1 and donateList[idd][2] != -1:
for x in range(len(donateList)):
if int(donateList[x][2]) == int(donateList[idd][2]) and x != idd:
donateList[idd][1] = float(donateList[idd][1]) + float(donateList[x][1])
to_pop.append(x)
pop_c = 0
for x_pop in to_pop:
donateList.pop(x_pop - pop_c)
pop_c += 1
try:
if not finded: donateList.append([username, float(event.amount_main), int(event.message.split(" ")[0]), float(event.amount_main)])
except:
if not finded: donateList.append([username, float(event.amount_main), -1, float(event.amount_main)])
balance_now = float(donateList[idd][1])
for x_s in range(len(donateList)):
for x in range(len(donateList) - 1):
if float(donateList[x][3]) < float(donateList[x + 1][3]):
topid = donateList[x][0]
topsc = donateList[x][1]
topidd = donateList[x][2]
topscm = donateList[x][3]
donateList[x][3] = donateList[x + 1][3]
donateList[x][2] = donateList[x + 1][2]
donateList[x][1] = donateList[x + 1][1]
donateList[x][0] = donateList[x + 1][0]
donateList[x + 1][3] = topscm
donateList[x + 1][2] = topidd
donateList[x + 1][1] = topsc
donateList[x + 1][0] = topid
if finded: donateList[idd][3] = float(donateList[idd][3]) + float(event.amount_main)
numpy.save(arr=numpy.array(donateList), file="data/donations.npy")
global da_event
if id != -1:
if da_event == -1: da_event = [[float(event.amount_main), int(id), username, last_balance, balance_now]]
else:
da_event.append([float(event.amount_main), int(id), username, last_balance, balance_now])
def get_list():
global donateList
return donateList
def set_list(donateList1):
global donateList
donateList = donateList1
numpy.save(arr=numpy.array(donateList), file="data/donations.npy")
def get_event():
global da_event
return da_event
def reset_event():
global da_event
da_event = -1
def pay(id, cost):
global donateList
suc = False
if cost != 0:
for x in range(len(donateList)):
if int(donateList[x][2]) == id:
res = round(float(donateList[x][1]) - cost, 2)
if res >= 0:
donateList[x][1] = res
suc = True
numpy.save(arr=numpy.array(donateList), file="data/donations.npy")
break
elif cost == 0: suc = True
return suc