From e689e968dbd240b08ca88f8a487a33c25ce2e452 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Sat, 4 Jun 2022 21:33:05 +0500 Subject: [PATCH] Fix bug with unsaving data --- telebot/asyncio_storage/pickle_storage.py | 2 ++ telebot/storage/pickle_storage.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/telebot/asyncio_storage/pickle_storage.py b/telebot/asyncio_storage/pickle_storage.py index 4928d4a1b..49fe3bedd 100644 --- a/telebot/asyncio_storage/pickle_storage.py +++ b/telebot/asyncio_storage/pickle_storage.py @@ -51,9 +51,11 @@ async def set_state(self, chat_id, user_id, state): if chat_id in self.data: if user_id in self.data[chat_id]: self.data[chat_id][user_id]['state'] = state + self.update_data() return True else: self.data[chat_id][user_id] = {'state': state, 'data': {}} + self.update_data() return True self.data[chat_id] = {user_id: {'state': state, 'data': {}}} self.update_data() diff --git a/telebot/storage/pickle_storage.py b/telebot/storage/pickle_storage.py index 39b10a3aa..ff72ac3b6 100644 --- a/telebot/storage/pickle_storage.py +++ b/telebot/storage/pickle_storage.py @@ -57,9 +57,11 @@ def set_state(self, chat_id, user_id, state): if chat_id in self.data: if user_id in self.data[chat_id]: self.data[chat_id][user_id]['state'] = state + self.update_data() return True else: self.data[chat_id][user_id] = {'state': state, 'data': {}} + self.update_data() return True self.data[chat_id] = {user_id: {'state': state, 'data': {}}} self.update_data()