diff --git a/bin/importer/feeders/Telegram.py b/bin/importer/feeders/Telegram.py index 52eb0a75..2900a46d 100755 --- a/bin/importer/feeders/Telegram.py +++ b/bin/importer/feeders/Telegram.py @@ -79,7 +79,7 @@ class TelegramFeeder(DefaultFeeder): if meta.get('chat'): chat = Chat(meta['chat']['id'], 'telegram') - if meta['chat'].get('username'): # TODO USE ID AND SAVE USERNAME + if meta['chat'].get('username'): # SAVE USERNAME chat_username = meta['chat']['username'] # Chat---Message @@ -99,7 +99,7 @@ class TelegramFeeder(DefaultFeeder): chat = None # message sender - if meta.get('sender'): # TODO handle message channel forward + if meta.get('sender'): # TODO handle message channel forward - check if is user user_id = meta['sender']['id'] user_account = UsersAccount.UserAccount(user_id, 'telegram') # UserAccount---Message @@ -117,10 +117,13 @@ class TelegramFeeder(DefaultFeeder): if meta['sender'].get('username'): username = Username(meta['sender']['username'], 'telegram') user_account.add_correlation(username.type, username.get_subtype(r_str=True), username.id) + # TODO Update user_account<--->username timeline # Username---Message username.add(date, self.item_id) # TODO #################################################################### + if chat: + # Chat---Username chat.add_correlation(username.type, username.get_subtype(r_str=True), username.id) # if meta.get('fwd_from'): diff --git a/bin/lib/objects/Chats.py b/bin/lib/objects/Chats.py index 438acf51..a3d1721c 100755 --- a/bin/lib/objects/Chats.py +++ b/bin/lib/objects/Chats.py @@ -117,9 +117,15 @@ class Chat(AbstractSubtypeObject): # TODO # ID == username ????? def get_name(self): # get username ???? pass - # return username correlation - def get_users(self): # get participants ??? -> passive users ??? - pass + # users that send at least a message else participants/spectator + # correlation created by messages + def get_users(self): + users = set() + accounts = self.get_correlation('user-account').get('user-account', []) + for account in accounts: + users.add(account[1:]) + return users + # def get_last_message_id(self): # diff --git a/bin/lib/objects/Messages.py b/bin/lib/objects/Messages.py index 98cc838f..302f0d0a 100755 --- a/bin/lib/objects/Messages.py +++ b/bin/lib/objects/Messages.py @@ -91,7 +91,7 @@ class Message(AbstractObject): # message_id = message_id[:-3] return message_id - def get_chat_id(self): # TODO optimize + def get_chat_id(self): # TODO optimize -> use me to tag Chat chat_id = self.get_basename().rsplit('_', 1)[0] # if chat_id.endswith('.gz'): # chat_id = chat_id[:-3] diff --git a/bin/lib/objects/UsersAccount.py b/bin/lib/objects/UsersAccount.py index 0355806e..f4f71d05 100755 --- a/bin/lib/objects/UsersAccount.py +++ b/bin/lib/objects/UsersAccount.py @@ -87,9 +87,7 @@ class UserAccount(AbstractSubtypeObject): def get_usernames(self): usernames = [] - correl = self.get_correlation('username') - for partial_id in correl.get('username', []): - usernames.append(f'username:{partial_id}') + # TODO TIMELINE return usernames def get_meta(self, options=set()):