Skip to content

Instantly share code, notes, and snippets.

@wfjsw
Created June 10, 2018 15:44
Show Gist options
  • Save wfjsw/abb21d1a36f201e26c6f412a96484238 to your computer and use it in GitHub Desktop.
Save wfjsw/abb21d1a36f201e26c6f412a96484238 to your computer and use it in GitHub Desktop.
环境:(完全模拟 api.telegram.org 运行环境)
TDLib,运行参数:
use_message_database: false,
use_secret_chats: false,
use_chat_info_database: false,
use_file_database: false
同样的一条消息在 Full 全开 和 只开 Basic 之间的差距
两者得到的消息分别在两个 JSON 文件中
假设在单次请求内缓存全开(即去重并完全复用)并只获取必要信息的情况下
其中 全 Full 模式 共向服务器发送 10 条请求:
{"chat_id":*user1*,"@type":"getChat","@extra":"0ce1fdfd"}
{"user_id":*user1*,"@type":"getUser","@extra":"49ad8a42"}
{"user_id":*user1*,"@type":"getUserFullInfo","@extra":"b0f1ce9d"}
{"chat_id":*channel1*,"@type":"getChat","@extra":"bd3da753"}
{"supergroup_id":*channel1*,"@type":"getSupergroup","@extra":"8a6d0dc0"}
{"supergroup_id":*channel1*,"@type":"getSupergroupFullInfo","@extra":"34526687"}
{"chat_id":*channel1*,"message_id":*msg1*,"@type":"getMessage","@extra":"3e3f9c0b"}
{"chat_id":*channel2*,"@type":"getChat","@extra":"61b16d80"}
{"supergroup_id":*channel2*,"@type":"getSupergroup","@extra":"b90e9990"}
{"supergroup_id":*channel2*,"@type":"getSupergroupFullInfo","@extra":"e0b2db07"}
共涉及一个用户(我)两个频道(一个是我的频道,一个是置顶消息所在频道)一条消息(置顶消息)
Basic 模式 共向服务器发送 4 条请求:
{"chat_id":*user1*,"@type":"getChat","@extra":"aa9d68c6"}
{"user_id":*user1*,"@type":"getUser","@extra":"744e3edb"}
{"chat_id":*channel1*,"@type":"getChat","@extra":"71a63c74"}
{"supergroup_id":*channel1*,"@type":"getSupergroup","@extra":"957a6c36"}
同上
请求 Timing 由于网络环境不稳定带来过大误差而暂不提供。
本测试使用 https://github.com/tdlib/td 与 https://github.com/wfjsw/node-tdlib 完成。
{ message_id: 1210,
date: 1528644174,
edit_date: 0,
is_channel_post: false,
can_be_deleted_for_all_users: false,
chat:
{ id: ***,
title: '***',
photo:
{ small_file_id: '***',
big_file_id: '***' },
type: 'user',
first_name: '***',
last_name: '',
username: '',
language_code: 'zh-CN',
restriction_reason: '',
is_verified: false,
phone_number: '',
is_bot: false,
last_seen: -2 },
from:
{ id: ***,
first_name: '***',
last_name: '',
username: '',
language_code: 'zh-CN',
restriction_reason: '',
is_verified: false,
phone_number: '',
is_bot: false,
photo:
{ small_file_id: '***',
big_file_id: '***' },
last_seen: -2,
type: 'user' },
views: 165,
forward_from_chat:
{ id: -***,
title: '***',
photo:
{ small_file_id: '***',
big_file_id: '***' },
type: 'channel',
sign_messages: false,
username: '***',
date: 1492916569,
status: { status: 'left' },
member_count: 0,
is_verified: false,
restriction_reason: '' },
forward_from_message_id: 1342,
forward_date: 1528463208,
forward_signature: '',
text: 'Aligram Telepay' }
{ message_id: 1208,
date: 1528643807,
edit_date: 0,
is_channel_post: false,
can_be_deleted_for_all_users: false,
chat:
{ id: ***,
title: ***,
photo:
{ small_file_id: '***',
big_file_id: '***' },
type: 'user',
first_name: '***',
last_name: '',
username: '',
language_code: 'zh-CN',
restriction_reason: '',
is_verified: false,
phone_number: '',
is_bot: false,
last_seen: -2,
description: '***',
group_in_common_count: 0 },
from:
{ id: ***,
first_name: '***',
last_name: '',
username: '',
language_code: 'zh-CN',
restriction_reason: '',
is_verified: false,
phone_number: '',
is_bot: false,
photo:
{ small_file_id: '***',
big_file_id: '***' },
last_seen: -2,
type: 'user',
description: '***',
group_in_common_count: 0 },
views: 165,
forward_from_chat:
{ id: ***,
title: '***',
photo:
{ small_file_id: '***',
big_file_id: '***' },
type: 'channel',
sign_messages: false,
username: '***',
date: 1492916569,
status: { status: 'left' },
member_count: 151,
is_verified: false,
restriction_reason: '',
administrator_count: 0,
restricted_count: 0,
banned_count: 0,
can_get_members: false,
can_set_username: false,
can_set_sticker_set: false,
is_all_history_available: true,
pinned_message:
{ message_id: 1125,
date: 1521642088,
edit_date: 0,
is_channel_post: true,
can_be_deleted_for_all_users: false,
chat: [Object],
views: 567,
forward_from_chat: [Object],
forward_from_message_id: 199,
forward_date: 1521642038,
forward_signature: '凛',
text: '我高考考到985,211,我他媽就女裝' } },
forward_from_message_id: 1342,
forward_date: 1528463208,
forward_signature: '',
text: 'Aligram Telepay' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment