diff options
-rw-r--r-- | bot.py | 6 | ||||
-rw-r--r-- | main.py | 4 |
2 files changed, 6 insertions, 4 deletions
@@ -16,7 +16,7 @@ class Bot: def __init__(self): self.token = os.getenv('BOT_TOKEN') self.chatId = os.getenv('BOT_CHAT_ID') - self.isProcessingPolling = False + self.isBusy = False self.hasNewMessages = False self.messages = list() @@ -61,7 +61,7 @@ class Bot: logger.error(e) def pollUpdate(self): - self.isProcessingPolling = True + self.isBusy = True try: url = f'https://api.telegram.org/bot{self.token}/getUpdates' @@ -74,7 +74,7 @@ class Bot: logger.error("Connection error during polling update") self._checkUnreadDb() - self.isProcessingPolling = False + self.isBusy = False def getNewMessages(self): result = list() @@ -46,6 +46,7 @@ def sendLog(msg): def handleCommand(messages): + bot.isBusy = True for msg in messages: msg = msg.lower() if msg == 'update': @@ -82,6 +83,7 @@ def handleCommand(messages): msgSend += f'\nDB = {res[0]} rows' bot.sendMessage(msgSend) connn.close() + bot.isBusy = False @repeat(every().day.at("09:00")) @@ -104,7 +106,7 @@ if __name__ == '__main__': logger.info("DB FILE NOT FOUND. CREATING...") initDb() while True: - if not bot.isProcessingPolling and bot.hasNewMessages: + if not bot.isBusy and bot.hasNewMessages: handleCommand(bot.getNewMessages()) else: bot.pollUpdate() |