diff --git a/pybot/core/bot.py b/pybot/core/bot.py index ff9264c..52f2813 100644 --- a/pybot/core/bot.py +++ b/pybot/core/bot.py @@ -123,7 +123,9 @@ def log(self, entry, log_type='readable', file_name=None, log_dir=ROOT_DIR + '/l def track(self, message): """Keeps track of chats and users. Updates database.""" - if not self.helper.is_known(message.sender, message.chat): + if self.helper.is_known(message.sender, message.chat): + self.helper.update_user_chat(message.sender, message.chat) + else: self.helper.save_user_chat(user=message.sender, chat=message.chat) def reply(self, response): diff --git a/pybot/helpers/core.py b/pybot/helpers/core.py index 9875b15..a9e9a7f 100644 --- a/pybot/helpers/core.py +++ b/pybot/helpers/core.py @@ -198,9 +198,14 @@ def update_user_chat(self, user, chat): self.cursor.execute(""" UPDATE users SET first_name=?, last_name=?, username=? - WHERE user_id=? + WHERE id=? """, (user.first_name, user.last_name, user.username, user.id, )) + self.cursor.execute(""" + UPDATE chats + SET id=?, title=? + WHERE id=? + """, (chat.id, chat.title, chat.id)) self.save() def get_members(self, chat, include_self=True):