-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer.py
113 lines (64 loc) · 2.16 KB
/
timer.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
from sys import path
from mysql.connector import connect
from time import sleep , localtime
from list import list_get as lget
from core import send_message as osend
print ('start')
sql = connect (
user = 'pyprog',
password = 'itpas',
database = 'bot'
)
print ('connected')
db = sql.cursor()
inl = []
def gen ():
while True :
sleep (3)
yield list(localtime() ) [3]
def read_to_send (id):
db.execute ('select modint from user where id="%s"' %id)
num = db.fetchall() [0] [0]
tdata = []
for q in range( num*5 , (num + 1)*5 ):
db.execute ('select * from words where num=%i' %q)
ert = db.fetchall()
tdata.append (ert [0])
slist = list()
for q in tdata :
slist.append ([q[0],q[1]])
return slist
for now in gen():
sql = connect (
user = 'pyprog',
password = 'itpas',
database = 'bot'
)
db = sql.cursor()
db.execute ('select * from user')
mdata = db.fetchall()
for data in mdata:
if data [9] == 'False' :
inl = ['6','7','8','9','10']
else:
inl = ['1','2','3','4','5']
ooo = 0
id = data [0]
if str(data [len(data)-1]) == '5.2' :
smsg = 'اینم از پنج تای امروزت'
ooo = read_to_send(id)
elif (now == 5 and lget (data ,3,'') == 'True' ) :
smsg = 'سلام چطوری ؟ اینم از پنج تای امروزت'
ooo = read_to_send(id)
if ooo != 0 :
print ('send start')
for rrr in range(0,5) :
q = ooo[rrr]
smsg += '\n%i_%s' %(rrr + 1 , q[0])
l = inl[rrr-1]
db.execute('update user set word%s="%s" , tday="False" where id="%s"' %(l,q[1],id) )
sql.commit()
osend ({'type':'TEXT','body':smsg,'to':id})
db.execute('update user set flo="1.1" , mode="wait" where id="%s"' %id )
sql.commit()
print ('sended')