Skip to content

Commit

Permalink
now keeping track of namechanges
Browse files Browse the repository at this point in the history
  • Loading branch information
daanbeverdam committed Sep 4, 2017
1 parent f990640 commit ca6fd1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pybot/core/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 6 additions & 1 deletion pybot/helpers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ca6fd1d

Please sign in to comment.