Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Bad usages of the API can trigger Telegram's anti-abuse system and ban all your

## What to do if I got banned?

First of all, there's no reason to panic.The automated anti-abuse system makes incorrect bans often.
First of all, there's no reason to panic. The automated anti-abuse system makes incorrect bans often.

See [discussions](https://github.com/lonamiwebs/telethon/issues/824#issuecomment-432182634) in other Telegram API libraries
for more context.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ jobs:
name: coverage

- name: Send coverage
uses: codecov/codecov-action@v2.0.2
uses: codecov/codecov-action@v2.0.3
with:
file: profile.out
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,27 @@ package main

import (
"context"

"github.com/gotd/td/telegram"
"github.com/gotd/td/tg"
)

func main() {
// https://core.telegram.org/api/obtaining_api_id
client := telegram.NewClient(appID, appHash, telegram.Options{})
err := client.Run(context.Background(), func(ctx context.Context) error {
api := tg.NewClient(client)
if err := client.Run(context.Background(), func(ctx context.Context) error {
// It is only valid to use client while this function is not returned
// and ctx is not cancelled.
api := client.API()

// Now you can invoke MTProto RPC requests by calling the API.
// ...

// Return to close client connection and free up resources.
return nil
})
if err != nil {
}); err != nil {
panic(err)
}
// Client is closed.
}
```

Expand All @@ -60,6 +63,7 @@ Also, see the [comparison](#difference-to-other-projects) with other Go Telegram

## Features

* Low memory overhead, 150kb per idle client
* Full MTProto 2.0 implementation in Golang
* Code for Telegram types generated by `./cmd/gotdgen` (based on [gotd/tl](https://github.com/gotd/tl) parser) with embedded [official documentation](https://core.telegram.org/schema)
* Pluggable session storage
Expand Down Expand Up @@ -148,7 +152,7 @@ client.Run(ctx, func(ctx context.Context) error) {
if err := client.Auth().Bot(ctx, "token:12345"); err != nil {
return err
}
state, err := tg.NewClient(client).UpdatesGetState(ctx)
state, err := client.API().UpdatesGetState(ctx)
if err != nil {
return err
}
Expand Down Expand Up @@ -231,12 +235,13 @@ Special thanks:
* Multiple major refactorings, including critical cryptographical scope reduction
* Code generation improvements (vector support, multiple modes for pretty-print)
* And many other cool things and performance improvements
* [zweihander](https://github.com/zweihander)
* [xjem](https://github.com/xjem)
* Background pings
* Links in generated documentation
* Message acknowledgements
* Retries
* RPC Engine
* Gap (Updates) engine

## Reference

Expand Down
34 changes: 20 additions & 14 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Roadmap

## Q3
## Q3 21

### Update key exchange
### ~~Update key exchange~~

An updated key exchange protocol should be implemented.
An updated key exchange protocol should be implemented. Done.

### Initial tracing

Expand All @@ -14,11 +14,26 @@ Add basic OpenTelemetry spans.

All Bot API Types should be parsed:

* Parser from docs.
* ~~Parser from docs.~~
* OpenAPI v3 generated spec from parsed types.
* Go structs generated from OpenAPI v3 spec.

## Q4
## Q4 21
### Documentation

Generate a static websites for documentations.

### Observability

* Advanced OpenTelemetry tracing.
* Prometheus metrics.

### Updates engine
* Refactor gap engine
* Simplify initialization
* Add example and documentation

## Q1 22

### Sugared client

Expand Down Expand Up @@ -46,15 +61,6 @@ server for `telegram-bot-api`.

A client for `telegram-bot-api`.

### Documentation

Generate a static websites for documentations.

### Observability

* Advanced OpenTelemetry tracing.
* Prometheus metrics.

### Goals

* Implement ecosystem of tools for Telegram in Go.
Expand Down
2 changes: 1 addition & 1 deletion cmd/gotdchats/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func run(ctx context.Context) error {
Logger: logger,
SessionStorage: storage,
Resolver: dcs.Plain(dcs.PlainOptions{Dial: proxy.Dial}),
DCList: dcs.Staging(),
DCList: dcs.Test(),
})

return client.Run(ctx, func(ctx context.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion examples/bg-run/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
github.com/gotd/contrib v0.9.1-0.20210712180501-4e445979e6df
github.com/gotd/td v0.49.0
github.com/gotd/td v0.50.0
go.uber.org/zap v1.19.0
)

Expand Down
2 changes: 1 addition & 1 deletion examples/gif-download/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
github.com/gotd/contrib v0.10.0
github.com/gotd/td v0.49.0
github.com/gotd/td v0.50.0
go.uber.org/atomic v1.9.0
go.uber.org/zap v1.19.0
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f
Expand Down
2 changes: 1 addition & 1 deletion telegram/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func ExampleClient_Auth_test() {
ctx := context.Background()
client := telegram.NewClient(telegram.TestAppID, telegram.TestAppHash, telegram.Options{
DC: dcID,
DCList: dcs.Staging(),
DCList: dcs.Test(),
})
if err := client.Run(ctx, func(ctx context.Context) error {
return auth.NewFlow(
Expand Down
4 changes: 2 additions & 2 deletions telegram/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ func retry(ctx context.Context, logger *zap.Logger, cb func(ctx context.Context)
}

// TestClient creates and authenticates user telegram.Client
// using Telegram staging server.
// using Telegram test server.
func TestClient(ctx context.Context, opts Options, cb func(ctx context.Context, client *Client) error) error {
if opts.DC == 0 {
opts.DC = 2
}
if opts.DCList.Zero() {
opts.DCList = dcs.Staging()
opts.DCList = dcs.Test()
}

logger := zap.NewNop()
Expand Down
2 changes: 1 addition & 1 deletion telegram/client_mtproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func testMTProxy(secretType string, m mtg, storage session.Storage) func(t *test
Resolver: resolver,
Logger: logger,
SessionStorage: storage,
DCList: dcs.Staging(),
DCList: dcs.Test(),
})
})

Expand Down
7 changes: 7 additions & 0 deletions telegram/dcs/staging.go → telegram/dcs/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ package dcs
import "github.com/gotd/td/tg"

// Staging returns staging DC list.
//
// Deprecated. Use Test().
func Staging() List {
return Test()
}

// Test returns test DC list.
func Test() List {
return List{
Options: []tg.DCOption{
{
Expand Down
6 changes: 3 additions & 3 deletions telegram/dcs/staging_test.go → telegram/dcs/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"github.com/stretchr/testify/require"
)

func TestStagingDCs(t *testing.T) {
func TestTestDCs(t *testing.T) {
require.NotEmpty(t, Prod())

// Check copying.
a := Staging().Options
a := Test().Options
a[0].IPAddress = "10"
b := Staging().Options
b := Test().Options
require.NotEqual(t, "10", b[0].IPAddress)
}
2 changes: 1 addition & 1 deletion telegram/internal/e2etest/e2etest.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Package e2etest contains some helpers to make external E2E tests
// using Telegram staging server.
// using Telegram test server.
package e2etest
2 changes: 1 addition & 1 deletion telegram/internal/e2etest/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewSuite(tb require.TestingT, config TestOptions) *Suite {
func (s *Suite) Client(logger *zap.Logger, handler telegram.UpdateHandler) *telegram.Client {
return telegram.NewClient(s.appID, s.appHash, telegram.Options{
DC: s.dc,
DCList: dcs.Staging(),
DCList: dcs.Test(),
Logger: logger,
UpdateHandler: handler,
})
Expand Down