-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPayments.py
71 lines (54 loc) · 2.04 KB
/
Payments.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
import time
from asyncio import run
from multiprocessing import Process
from yookassa import Payment
import functions
import texts
from Enum_classes import Flags
from config import users, bot
class Checking:
def __init__(self) -> None:
self.p0 = Process()
def start_process(self, func, arg=None):
if arg is not None:
self.p0 = Process(target=func, args=(arg,))
else:
self.p0 = Process(target=func)
self.p0.start()
def stop_process(self):
self.p0.terminate()
def check_pay(self, key: str):
try:
res = Payment.find_one(key)
if res.paid and res.status == "succeeded":
return True
except:
return False
async def work(self):
list_user_id: list = users.get_keys()
for user_id in list_user_id:
try:
user = users.get(user_id)
if not user.payment and user.flag == Flags.Payment:
if self.check_pay(user.key_payment):
await bot.send_message(chat_id=user_id,
text=texts.text_after_pay,
reply_markup=functions.create_keyboard(
name_buttons=["Начать историю"]
),
parse_mode="Markdown",
disable_web_page_preview=True,
)
user.payment = True
user.flag = Flags.NONE
users.update_info(user)
except:
pass
def start_schedule(self):
while True:
run(self.work())
time.sleep(30)
if __name__ == "__main__":
checking = Checking()
checking.check_pay("2b75d1d5-000f-5000-9000-15168f1fb17c")
# checking.start_process(func=checking.start_schedule)