td

package module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 0 Imported by: 3

README

td

Telegram client implementation in go.

Status

Work in progress. Only go1.15 is supported and no backward compatibility is provided.

Goal of this project is to implement Telegram client while providing building blocks for the other client or even server implementation without performance bottlenecks.

Features

  • Full MTProto 2.0 implementation in go
  • Code for Telegram types automatically generated by ./cmd/gotdgen (based on ernado/tl parser)
  • Pluggable session storage
  • Vendored Telegram public keys that are kept up-to-date
  • Testing and fuzzing applied to improve durability

Example

You can see cmd/gotdecho for echo bot example.

Calling MTProto directly

You can use generated tg.Client that allows calling any MTProto methods directly.

client, err := telegram.Dial(dialCtx, telegram.Options{
    Addr:   "149.154.167.40:443",

    // Grab these from https://my.telegram.org/apps.
    // Never share it or hardcode!
    AppID:   appID,
    AppHash: appHash,
})
if err != nil {
    panic(err)
}

// updates.getState#edd4882a
state, err := tg.NewClient(client).UpdatesGetState(ctx, &tg.UpdatesGetStateRequest{})
if err != nil {
    panic(err)
}
// Got state: &{Pts:197 Qts:0 Date:1606855030 Seq:1 UnreadCount:106}

Reference

The MTProto protocol description is hosted by Telegram.

Most important parts for client impelemtations:

Current implementation does not conform to security guidelines and should be used only as reference or for testing.

Prior art

License

MIT License, created by Aleksandr (ernado) Razumov in 2020

Documentation

Overview

Package td implements MTProto encoding and decoding.

Directories

Path Synopsis
Package bin implements binary serialization and deserialization for TL, providing Buffer that can decode and encode basic Type Language types.
Package bin implements binary serialization and deserialization for TL, providing Buffer that can decode and encode basic Type Language types.
cmd
gotdecho command
gotdgen command
examples module
bg-run module
gif-download module
crypto
Package crypto implements cryptographical primitives for MTproto.
Package crypto implements cryptographical primitives for MTproto.
gen
gen/internal
Code generated for package internal by go-bindata DO NOT EDIT.
Code generated for package internal by go-bindata DO NOT EDIT.
mt
proto
Proto implements MTProto 2.0 primitives.
Proto implements MTProto 2.0 primitives.
internal
Code generated for package internal by go-bindata DO NOT EDIT.
Code generated for package internal by go-bindata DO NOT EDIT.
Package tg contains generated types from MTProto Telegram API.
Package tg contains generated types from MTProto Telegram API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL