All Projects → zelenin → Go Tdlib

zelenin / Go Tdlib

Licence: mit
Go wrapper for TDLib (Telegram Database Library)

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Go Tdlib

Tg2sip
Telegram <-> SIP voice gateway
Stars: ✭ 142 (-12.35%)
Mutual labels:  telegram
Tgs To Gif
Converts animated Telegram stickers (*.tgs) to animated GIFs (.gif)
Stars: ✭ 148 (-8.64%)
Mutual labels:  telegram
Telegram Kraken Bot
Python bot to trade on Kraken via Telegram
Stars: ✭ 156 (-3.7%)
Mutual labels:  telegram
Teledart
A Dart library interfacing with the latest Telegram Bot API.
Stars: ✭ 142 (-12.35%)
Mutual labels:  telegram
Telegramgo
CLI telegram client written in golang
Stars: ✭ 145 (-10.49%)
Mutual labels:  telegram
Media Search Bot
Inline bot for channels and groups
Stars: ✭ 150 (-7.41%)
Mutual labels:  telegram
Claudia Bot Builder
Create chat bots for Facebook Messenger, Slack, Amazon Alexa, Skype, Telegram, Viber, Line, GroupMe, Kik and Twilio and deploy to AWS Lambda in minutes
Stars: ✭ 1,717 (+959.88%)
Mutual labels:  telegram
Slimbot
Telegram Bot API for Node.js
Stars: ✭ 157 (-3.09%)
Mutual labels:  telegram
Ton
Telegram Open Network research group. Telegram: https://t.me/ton_research
Stars: ✭ 146 (-9.88%)
Mutual labels:  telegram
Telegramapiserver
Fast, simple, async php telegram api server: MadelineProto + Amp HTTP Server
Stars: ✭ 152 (-6.17%)
Mutual labels:  telegram
Vk To Telegram Transfer Bot
Бот, пересылающий сообщения из чатов ВК в Telegram и обратно
Stars: ✭ 143 (-11.73%)
Mutual labels:  telegram
Transmission Telegram
Control your Transmission through a Telegram bot
Stars: ✭ 144 (-11.11%)
Mutual labels:  telegram
Smarthome Homeassistant Config
🏠 My Home Assistant configuration. This repo will be archived 🗄️ in the future
Stars: ✭ 152 (-6.17%)
Mutual labels:  telegram
Telebot
Advanced Telegram UserBot. [Python][Telethon]
Stars: ✭ 144 (-11.11%)
Mutual labels:  telegram
Webapp
Tinode web chat using React
Stars: ✭ 156 (-3.7%)
Mutual labels:  telegram
Telegram Bot Api
Telegram Bot API PHP
Stars: ✭ 139 (-14.2%)
Mutual labels:  telegram
Magento Chatbot
Magento Chatbot Integration with Telegram, Messenger, Whatsapp, WeChat, Skype and wit.ai.
Stars: ✭ 149 (-8.02%)
Mutual labels:  telegram
Awesome Telegram
Curated list of Telegram-related projects
Stars: ✭ 160 (-1.23%)
Mutual labels:  telegram
Tg Index
Python web app to index telegram channel and serve its files for download.
Stars: ✭ 157 (-3.09%)
Mutual labels:  telegram
Hubot Telegram
Hubot adapter for Telegram
Stars: ✭ 152 (-6.17%)
Mutual labels:  telegram

go-tdlib

Go wrapper for TDLib (Telegram Database Library) with full support of TDLib v1.7.0

TDLib installation

Use TDLib build instructions

Usage

Client

Register an application to obtain an api_id and api_hash

package main

import (
    "log"
    "path/filepath"

    "github.com/zelenin/go-tdlib/client"
)

func main() {
    // client authorizer
    authorizer := client.ClientAuthorizer()
    go client.CliInteractor(authorizer)

    // or bot authorizer
    // botToken := "000000000:gsVCGG5YbikxYHC7bP5vRvmBqJ7Xz6vG6td"
    // authorizer := client.BotAuthorizer(botToken)

    const (
        apiId   = 00000
        apiHash = "8pu9yg32qkuukj83ozaqo5zzjwhkxhnk"
    )

    authorizer.TdlibParameters <- &client.TdlibParameters{
        UseTestDc:              false,
        DatabaseDirectory:      filepath.Join(".tdlib", "database"),
        FilesDirectory:         filepath.Join(".tdlib", "files"),
        UseFileDatabase:        true,
        UseChatInfoDatabase:    true,
        UseMessageDatabase:     true,
        UseSecretChats:         false,
        ApiId:                  apiId,
        ApiHash:                apiHash,
        SystemLanguageCode:     "en",
        DeviceModel:            "Server",
        SystemVersion:          "1.0.0",
        ApplicationVersion:     "1.0.0",
        EnableStorageOptimizer: true,
        IgnoreFileNames:        false,
    }

    logVerbosity := client.WithLogVerbosity(&client.SetLogVerbosityLevelRequest{
        NewVerbosityLevel: 0,
    })

    tdlibClient, err := client.NewClient(authorizer, logVerbosity)
    if err != nil {
        log.Fatalf("NewClient error: %s", err)
    }

    optionValue, err := tdlibClient.GetOption(&client.GetOptionRequest{
        Name: "version",
    })
    if err != nil {
        log.Fatalf("GetOption error: %s", err)
    }

    log.Printf("TDLib version: %s", optionValue.(*client.OptionValueString).Value)

    me, err := tdlibClient.GetMe()
    if err != nil {
        log.Fatalf("GetMe error: %s", err)
    }

    log.Printf("Me: %s %s [%s]", me.FirstName, me.LastName, me.Username)
}

Receive updates

tdlibClient, err := client.NewClient(authorizer)
if err != nil {
    log.Fatalf("NewClient error: %s", err)
}

listener := tdlibClient.GetListener()
defer listener.Close()
 
for update := range listener.Updates {
    if update.GetClass() == client.ClassUpdate {
        log.Printf("%#v", update)
    }
}

Proxy support

proxy := client.WithProxy(&client.AddProxyRequest{
    Server: "1.1.1.1",
    Port:   1080,
    Enable: true,
    Type: &client.ProxyTypeSocks5{
        Username: "username",
        Password: "password",
    },
})

tdlibClient, err := client.NewClient(authorizer, proxy)

Notes

  • WIP. Library API can be changed in the future
  • The package includes a .tl-parser and generated json-schema for creating libraries in other languages

Author

Aleksandr Zelenin, e-mail: [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].