Groups contact book
This commit is contained in:
parent
987ee029dc
commit
93728f6778
18
scel-buc.py
18
scel-buc.py
|
@ -52,13 +52,14 @@ def append_message(message):
|
|||
# Extract the data
|
||||
message_id = message['message_id']
|
||||
sender = str(message['from']['id'])
|
||||
chat_id = message['chat']['id']
|
||||
chat_id = str(message['chat']['id'])
|
||||
date = message['date']
|
||||
text = message['text']
|
||||
|
||||
# Process the data
|
||||
chat_file = CHAT_PATH+f'/{chat_id}.html'
|
||||
sender = resolve_user(sender)
|
||||
chat_id = resolve_chat(chat_id)
|
||||
chat_file = CHAT_PATH+f'/{chat_id}.html'
|
||||
date = dt.strftime(dt.utcfromtimestamp(date), '%Y-%m-%d %H:%M:%S') + ' UTC'
|
||||
text = text.replace('\n','</p>\n<p>')
|
||||
text = '<p>'+text+'</p>'
|
||||
|
@ -89,7 +90,8 @@ def generate_pages():
|
|||
# Generate chat files
|
||||
chat_files = set()
|
||||
for i in messages:
|
||||
chat_id = i['chat']['id']
|
||||
chat_id = str(i['chat']['id'])
|
||||
chat_id = resolve_chat(chat_id)
|
||||
chat_file = CHAT_PATH+f'/{chat_id}.html'
|
||||
chat_files.add(chat_file)
|
||||
for i in chat_files:
|
||||
|
@ -121,5 +123,15 @@ def resolve_user(user_id):
|
|||
return user_string
|
||||
|
||||
|
||||
def resolve_chat(chat_id):
|
||||
if chat_id in GROUP_NAMES:
|
||||
chat_string = GROUP_NAMES[chat_id]
|
||||
elif chat_id in USER_NAMES:
|
||||
chat_string = USER_NAMES[chat_id]
|
||||
else:
|
||||
chat_string = f'chat_{chat_id}'
|
||||
return chat_string
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
generate_pages()
|
||||
|
|
Reference in New Issue