From 2e2c38e149af0d67fb158e845cc507d33e6bcd14 Mon Sep 17 00:00:00 2001 From: PinLin Date: Sat, 26 Aug 2017 23:18:31 +0800 Subject: [PATCH] try to fix suicide bug --- bot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 5f9dfea..6865c66 100644 --- a/bot.py +++ b/bot.py @@ -6,12 +6,11 @@ from telepot.loop import MessageLoop from pprint import pprint # kCOJ API import access -from interface import kuser +from interface import kuser, bot # configurations import config users = {} -bot = telepot.Bot(config.TOKEN) def on_chat(msg): content_type, chat_type, chat_id = telepot.glance(msg) @@ -147,9 +146,13 @@ with open('users.json', 'r') as f: MessageLoop(bot, on_chat).run_as_thread() print("Started! Service is available.") +count = 0 while True: time.sleep(1) - bot.getMe() + count += 1 + if count == 5: + bot.getMe() + count = 0 # backup users_backup = {}