From 8e2f7d36858f1ee021d78fe64627dbed782b4212 Mon Sep 17 00:00:00 2001 From: anebz Date: Thu, 4 Jun 2020 18:50:57 +0200 Subject: [PATCH] 7.7: chat server telegram example --- .../7.7. Chat server.md | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/07. Object-Oriented design/7.7. Chat server.md b/07. Object-Oriented design/7.7. Chat server.md index 4bfed06..160a03a 100644 --- a/07. Object-Oriented design/7.7. Chat server.md +++ b/07. Object-Oriented design/7.7. Chat server.md @@ -48,3 +48,114 @@ The key objects of the system are users, conversations and status messages. * How do we make the server scale? * Split the data across many servers, incresing the concern about out-of-sync data * How do we prevent DoS attacks? + +## Telegram export chat json file + +Example `json` of how Telegram saves message data in a `personal chat`. + +```json +{ + "name": "name", + "type": "personal_chat", + "id": 123456, + "messages": [ + { // text message + "id": 234, + "type": "message", + "date": "2020-01-29T11:41:46", + "edited": "1970-01-01T01:00:00", + "from": "Username", + "from_id": 123456, + "text": "..." + }, + { // sticker + "id": 432, + "type": "message", + "date": "2020-01-29T12:14:22", + "edited": "1970-01-01T01:00:00", + "from": "Username", + "from_id": 123456, + "file": "stickers/AnimatedSticker.tgs", + "thumbnail": "stickers/AnimatedSticker.tgs_thumb.jpg", + "media_type": "sticker", + "sticker_emoji": "😄", + "text": "" + }, + { // link in text message + "id": 436093, + "type": "message", + "date": "2020-01-30T17:03:34", + "edited": "1970-01-01T01:00:00", + "from": "ane", + "from_id": 222, + "text": [ + { + "type": "link", + "text": "https://www.link.com" + } + ] + }, + { // photo message + "id": 436396, + "type": "message", + "date": "2020-02-02T15:56:06", + "edited": "1970-01-01T01:00:00", + "from": "Username", + "from_id": 123456, + "photo": "photos/photo.jpg", + "width": 648, + "height": 259, + "text": "" + }, + { // audio message + "id": 36057, + "type": "message", + "date": "2016-04-05T13:26:02", + "edited": "1970-01-01T01:00:00", + "from": "Username", + "from_id": 123456, + "file": "voice_messages/audio_1@05-04-2016_13-26-02.ogg", + "media_type": "voice_message", + "mime_type": "audio/ogg", + "duration_seconds": 36, + "text": "" + } + ] +} +``` + +`json` data in a `group chat`. + +```json +{ + "name": "group_name", + "type": "private_group", + "id": 111111, + "messages": [ + { + "id": 35966, + "type": "service", + "date": "2016-04-04T22:35:06", + "edited": "1970-01-01T01:00:00", + "actor": "ane", + "actor_id": 222, + "action": "create_group", + "title": "group_name", + "members": [ + "ane", + "Username" + ], + "text": "" + }, + { + "id": 35968, + "type": "message", + "date": "2016-04-04T22:39:08", + "edited": "1970-01-01T01:00:00", + "from": "Username", + "from_id": 123456, + "text": "..." + } + ] +} +```