Telegram入门

基本常识

词汇

telegram最主要的对象就是消息,目前为止有不止35种类型的消息内容,主要有:

  • 文本消息( messageText)
  • 图片消息(messagePhoto)
  • 截图(messageScreenshotTaken )

6种不同的成员状态:

  • chatMemberStatusAdministrator
  • chatMemberStatusBanned,
  • chatMemberStatusCreator,
  • chatMemberStatusLeft,
  • chatMemberStatusMember
  • chatMemberStatusRestricted.

四种不同的聊天形式:

  • private chats
  • basic groups
  • supergroups
  • secret chats

聊天消息去向

  • The correct order of chats in the chat list is maintained by TDLib, so the Application only needs to listen to updates that change the chat.order field and sort all chats by the pair (chat.order, chat.id) in a given chat.list.
  • TDLib通过updates向应用传递数据

用户认证

当用户需要认证时,TDLib向应用程序发送一个 updateAuthorizationState 为了描述目前的认证状态AuthorizationState
应用收到的第一种验证类型是authorizationStateWaitTdlibParameters,应用通过setTdlibParameters方法来给TDLib提供初始化参数。参数主要有:

  • api_id
  • api_hash
  • database_directory
  • use_message_database
  • use_secret_chats
  • system_language_code
  • device_model
  • system_version

如果验证成功,应用会收到新的updateAuthorizationState;如果失败,收到的updateAuthorizationState不会更新。
应用收到的第二种认证状态是authorizationStateWaitEncryptionKey。当收到此状态信息时,应用必须通过checkDatabaseEncryptionKey提供数据库加密秘钥。
完成这些认证之后,应用将会收到authorizationStateReady,意味着认证成功并可以进行request操作。

updates

updates列表和被处理的方法

  • updateAuthorizationState
  • updateNewChat:当有新的chat时,会收到此update。当应用收到chat_id时,就不需要用getChat请求去获得chat对象,会有一个缓存接收chat对象
  • updateUser:
  • updateBasicGroup
  • updateSupergroup
  • updateSecretChat
  • updateNewMessage
  • updateMessageSendSucceeded
  • updateMessageContent
  • updateFile

得到聊天信息

应用可以通过getChatHistory 方法得到一个chat中的信息。信息会以逆时间顺序返回(也就是message_id的降序)。应用传递from_message_id=0会得到最后一个消息。如果应用需要更多的消息,需要调整from_message_id参数并且不断请求。

CMake C++ projects for telegram Client

Td::TdStatic

一般方法的c++接口静态库

Client Class

通用的使用模式:

std::shared_ptr<td::Client> client = std::make_shared<td::Client>();
// somehow share the client with other t
  • 3
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值