-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
33 lines (32 loc) · 871 Bytes
/
server.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
from newBot import tBot
import stopstalk
import rating
import time
update_id = None
mine=None
bot=tBot(r"config.cfg")
def make_reply(msg):
reply=None
if msg is not None:
reply = stopstalk.text(msg)
print(reply)
return reply
while True:
print("...")
updates = bot.get_updates(offset=update_id)['result']
ratingChanges = rating.ratingChange()
if(ratingChanges):
if(mine):
bot.send_message(ratingChanges,mine)
if updates:
for item in updates:
update_id = item['update_id']
try:
message = item['message']['text']
except:
message = None
from_ = item['message']['from']['id']
mine = item['message']['from']['id']
reply = make_reply(message)
bot.send_message(reply,from_)
time.sleep(5)