mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-22 22:27:17 +00:00
chg: [telegram fedeer] use meta of the new feeder
This commit is contained in:
parent
859591b53f
commit
2691000d0c
1 changed files with 19 additions and 15 deletions
|
@ -29,8 +29,8 @@ class TelegramFeeder(DefaultFeeder):
|
||||||
def get_item_id(self):
|
def get_item_id(self):
|
||||||
# TODO use telegram message date
|
# TODO use telegram message date
|
||||||
date = datetime.date.today().strftime("%Y/%m/%d")
|
date = datetime.date.today().strftime("%Y/%m/%d")
|
||||||
channel_id = str(self.json_data['meta']['channel_id'])
|
channel_id = str(self.json_data['meta']['chat']['id'])
|
||||||
message_id = str(self.json_data['meta']['message_id'])
|
message_id = str(self.json_data['meta']['id'])
|
||||||
item_id = f'{channel_id}_{message_id}'
|
item_id = f'{channel_id}_{message_id}'
|
||||||
item_id = os.path.join('telegram', date, item_id)
|
item_id = os.path.join('telegram', date, item_id)
|
||||||
self.item_id = f'{item_id}.gz'
|
self.item_id = f'{item_id}.gz'
|
||||||
|
@ -40,17 +40,21 @@ class TelegramFeeder(DefaultFeeder):
|
||||||
"""
|
"""
|
||||||
Process JSON meta field.
|
Process JSON meta field.
|
||||||
"""
|
"""
|
||||||
# channel_id = str(self.json_data['meta']['channel_id'])
|
# message chat
|
||||||
# message_id = str(self.json_data['meta']['message_id'])
|
meta = self.json_data['meta']
|
||||||
# telegram_id = f'{channel_id}_{message_id}'
|
if meta.get('chat'):
|
||||||
# item_basic.add_map_obj_id_item_id(telegram_id, item_id, 'telegram_id') #########################################
|
if meta['chat'].get('username'):
|
||||||
user = None
|
user = meta['chat']['username']
|
||||||
if self.json_data['meta'].get('user'):
|
if user:
|
||||||
user = str(self.json_data['meta']['user'])
|
date = item_basic.get_item_date(self.item_id)
|
||||||
elif self.json_data['meta'].get('channel'):
|
username = Username(user, 'telegram')
|
||||||
user = str(self.json_data['meta']['channel'].get('username'))
|
username.add(date, self.item_id)
|
||||||
if user:
|
# message sender
|
||||||
date = item_basic.get_item_date(self.item_id)
|
if meta.get('sender'):
|
||||||
username = Username(user, 'telegram')
|
if meta['sender'].get('username'):
|
||||||
username.add(date, self.item_id)
|
user = meta['sender']['username']
|
||||||
|
if user:
|
||||||
|
date = item_basic.get_item_date(self.item_id)
|
||||||
|
username = Username(user, 'telegram')
|
||||||
|
username.add(date, self.item_id)
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in a new issue