Skip to content

Commit

Permalink
chg: [chat feeder] add matrix feeder
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Feb 21, 2025
1 parent efbbad4 commit d81c550
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
38 changes: 38 additions & 0 deletions bin/importer/feeders/Matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3
# -*-coding:UTF-8 -*
"""
The Telegram Feeder Importer Module
================
Process Telegram JSON
"""
import os
import sys
import datetime

sys.path.append(os.environ['AIL_BIN'])
##################################
# Import Project packages
##################################
from importer.feeders.abstract_chats_feeder import AbstractChatFeeder
from lib.ConfigLoader import ConfigLoader
from lib.objects import ail_objects
from lib.objects.Chats import Chat
from lib.objects import Messages
from lib.objects import UsersAccount
from lib.objects.Usernames import Username

import base64

class MatrixFeeder(AbstractChatFeeder):

def __init__(self, json_data):
super().__init__('matrix', json_data)

# def get_obj(self):.
# obj_id = Messages.create_obj_id('telegram', chat_id, message_id, timestamp)
# obj_id = f'message:telegram:{obj_id}'
# self.obj = ail_objects.get_obj_from_global_id(obj_id)
# return self.obj

4 changes: 2 additions & 2 deletions bin/importer/feeders/abstract_chats_feeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def get_chat_protocol(self): # TODO # # # # # # # # # # # # #
return self.name

def get_chat_network(self):
self.json_data['meta'].get('network', None)
return self.json_data['meta'].get('network', None)

def get_chat_address(self):
self.json_data['meta'].get('address', None)
return self.json_data['meta'].get('address', None)

def get_chat_instance_uuid(self):
chat_instance_uuid = chats_viewer.create_chat_service_instance(self.get_chat_protocol(),
Expand Down
1 change: 0 additions & 1 deletion bin/lib/objects/DomHashs.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def get_misp_object(self):
for tag in self.get_tags():
obj_attr.add_tag(tag)
return obj
return None

def get_nb_seen(self):
return self.get_nb_correlation('domain')
Expand Down
2 changes: 1 addition & 1 deletion bin/lib/objects/Messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_user_account(self, meta=False):
if user_account.get('user-account'):
user_account = f'user-account:{user_account["user-account"].pop()}'
if meta:
_, user_account_subtype, user_account_id = user_account.split(':', 3)
_, user_account_subtype, user_account_id = user_account.split(':', 2)
user_account = UsersAccount.UserAccount(user_account_id, user_account_subtype).get_meta(options={'icon', 'username', 'username_meta'})
return user_account

Expand Down
2 changes: 1 addition & 1 deletion bin/lib/objects/UsersAccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def get_meta(self, options=set(), translation_target=None): # TODO Username time
if 'username' in options:
meta['username'] = self.get_username()
if meta['username']:
_, username_account_subtype, username_account_id = meta['username'].split(':', 3)
_, username_account_subtype, username_account_id = meta['username'].split(':', 2)
if 'username_meta' in options:
meta['username'] = Usernames.Username(username_account_id, username_account_subtype).get_meta(options={'icon'})
else:
Expand Down

0 comments on commit d81c550

Please sign in to comment.