All Projects → Arman92 → Go Tdlib

Arman92 / Go Tdlib

Licence: gpl-3.0
Golang Telegram TdLib JSON bindings

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Go Tdlib

Kepka
Unofficial Telegram Desktop messaging app
Stars: ✭ 109 (-55.33%)
Mutual labels:  telegram-api, telegram
Node Telegram Api
A simple API to create and control Telegram bots
Stars: ✭ 117 (-52.05%)
Mutual labels:  telegram-api, telegram
Novagram
An Object-Oriented PHP library for Telegram Bots
Stars: ✭ 112 (-54.1%)
Mutual labels:  telegram-api, telegram
Core
PHP Telegram Bot based on the official Telegram Bot API
Stars: ✭ 2,899 (+1088.11%)
Mutual labels:  telegram-api, telegram
Micro Bot
🤖 Zero-configuration Telegram bot runner
Stars: ✭ 173 (-29.1%)
Mutual labels:  telegram-api, telegram
Mattata
A powerful, plugin-based, multi-purpose Telegram bot designed to serve a wide variety of purposes
Stars: ✭ 107 (-56.15%)
Mutual labels:  telegram-api, telegram
Telegram media downloader
Download media files from a telegram conversation/chat/channel up to 2GiB
Stars: ✭ 113 (-53.69%)
Mutual labels:  telegram-api, telegram
Mypackbot
🤖 Your own unlimited pack of Telegram-stickers
Stars: ✭ 18 (-92.62%)
Mutual labels:  telegram-api, telegram
Sentry Telegram
Plugin for Sentry which allows sending notification via Telegram messenger.
Stars: ✭ 168 (-31.15%)
Mutual labels:  telegram-api, telegram
Magento Chatbot
Magento Chatbot Integration with Telegram, Messenger, Whatsapp, WeChat, Skype and wit.ai.
Stars: ✭ 149 (-38.93%)
Mutual labels:  telegram-api, telegram
Tdsharp
C#/.NET Core bindings for TDLib (Telegram MTProto API)
Stars: ✭ 103 (-57.79%)
Mutual labels:  telegram-api, telegram
Telegram Bot Api
First Telegram Bot API node.js library
Stars: ✭ 205 (-15.98%)
Mutual labels:  telegram-api, telegram
Turibot
TuriBot is a simple way to communicate with Telegram APIs in PHP
Stars: ✭ 68 (-72.13%)
Mutual labels:  telegram-api, telegram
Grammers
(tele)gramme.rs - use Telegram's API from Rust
Stars: ✭ 109 (-55.33%)
Mutual labels:  telegram-api, telegram
Drone Telegram
Drone plugin for sending Telegram notifications
Stars: ✭ 67 (-72.54%)
Mutual labels:  telegram-api, telegram
Madelineproto
Async PHP client/server API for the telegram MTProto protocol
Stars: ✭ 1,776 (+627.87%)
Mutual labels:  telegram-api, telegram
Java Telegram Bot Api
Telegram Bot API for Java
Stars: ✭ 819 (+235.66%)
Mutual labels:  telegram-api, telegram
Tlsharp
Telegram client library implemented in C#
Stars: ✭ 895 (+266.8%)
Mutual labels:  telegram-api, telegram
Pyrogram
Telegram MTProto API Client Library and Framework in Pure Python for Users and Bots
Stars: ✭ 2,252 (+822.95%)
Mutual labels:  telegram-api, telegram
Tdl
Node.js bindings to TDLib.
Stars: ✭ 177 (-27.46%)
Mutual labels:  telegram-api, telegram

go-tdlib

All Contributors

Golang Telegram TdLib JSON bindings

Introduction

Telegram Tdlib is a complete library for creating telegram clients, it also has a simple tdjson ready-to-use library to ease the integration with different programming languages and platforms.

go-tdlib is a complete tdlib-tdjson binding package to help you create your own Telegram clients.

NOTE: basic tdjson-golang binding is inspired from this package: go-tdjson

All the classes and functions declared in Tdlib TypeLanguage schema file have been exported using the autogenerate tool tl-parser. So you can use every single type and method in Tdlib.

Key features:

  • Autogenerated golang structs and methods of tdlib .tl schema
  • Custom event receivers defined by user (e.g. get only text messages from a specific user)
  • Supports all tdjson functions: Send(), Execute(), Receive(), Destroy(), SetFilePath(), SetLogVerbosityLevel()
  • Supports all tdlib functions and types

Installation

First of all you need to clone the Tdlib repo and build it:

git clone [email protected]:tdlib/td.git --depth 1
cd td
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . -- -j5
make install

# -j5 refers to number of your cpu cores + 1 for multi-threaded build.

If hit any build errors, refer to Tdlib build instructions I'm using static linking against tdlib so it won't require to build the whole tdlib source files.

Docker

You can use the prebuilt tdlib image and Go image of your liking:

FROM golang:1.15-alpine AS golang

COPY --from=wcsiu/tdlib:1.7-alpine /usr/local/include/td /usr/local/include/td
COPY --from=wcsiu/tdlib:1.7-alpine /usr/local/lib/libtd* /usr/local/lib/
COPY --from=wcsiu/tdlib:1.7-alpine /usr/lib/libssl.a /usr/local/lib/libssl.a
COPY --from=wcsiu/tdlib:1.7-alpine /usr/lib/libcrypto.a /usr/local/lib/libcrypto.a
COPY --from=wcsiu/tdlib:1.7-alpine /lib/libz.a /usr/local/lib/libz.a
RUN apk add build-base

WORKDIR /myApp

COPY . .

RUN go build --ldflags "-extldflags '-static -L/usr/local/lib -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdactor -ltddb -ltdsqlite -ltdnet -ltdutils -ldl -lm -lssl -lcrypto -lstdc++ -lz'" -o /tmp/getChats getChats.go

FROM gcr.io/distroless/base:latest
COPY --from=golang /tmp/getChats /getChats
ENTRYPOINT [ "/getChats" ]
$ docker build -fDockerfile -ttelegram-client .

Example

Here is a simple example for authorization and fetching updates:

package main

import (
	"fmt"

	"github.com/Arman92/go-tdlib"
)

func main() {
	tdlib.SetLogVerbosityLevel(1)
	tdlib.SetFilePath("./errors.txt")

	// Create new instance of client
	client := tdlib.NewClient(tdlib.Config{
		APIID:               "187786",
		APIHash:             "e782045df67ba48e441ccb105da8fc85",
		SystemLanguageCode:  "en",
		DeviceModel:         "Server",
		SystemVersion:       "1.0.0",
		ApplicationVersion:  "1.0.0",
		UseMessageDatabase:  true,
		UseFileDatabase:     true,
		UseChatInfoDatabase: true,
		UseTestDataCenter:   false,
		DatabaseDirectory:   "./tdlib-db",
		FileDirectory:       "./tdlib-files",
		IgnoreFileNames:     false,
	})

	for {
		currentState, _ := client.Authorize()
		if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitPhoneNumberType {
			fmt.Print("Enter phone: ")
			var number string
			fmt.Scanln(&number)
			_, err := client.SendPhoneNumber(number)
			if err != nil {
				fmt.Printf("Error sending phone number: %v", err)
			}
		} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitCodeType {
			fmt.Print("Enter code: ")
			var code string
			fmt.Scanln(&code)
			_, err := client.SendAuthCode(code)
			if err != nil {
				fmt.Printf("Error sending auth code : %v", err)
			}
		} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitPasswordType {
			fmt.Print("Enter Password: ")
			var password string
			fmt.Scanln(&password)
			_, err := client.SendAuthPassword(password)
			if err != nil {
				fmt.Printf("Error sending auth password: %v", err)
			}
		} else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateReadyType {
			fmt.Println("Authorization Ready! Let's rock")
			break
		}
	}

	// Main loop
	for update := range client.RawUpdates {
		// Show all updates
		fmt.Println(update.Data)
		fmt.Print("\n\n")
	}

}

More examples can be found on examples folder

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Aleksandr Zelenin

💡

for

🐛

Ahmadreza Zibaei

💻

Max

💻

Ruben Vermeersch

🐛

Alexander Shelepenok

💻 🚧 ⚠️

Karim Nahas

💻 🚧 🐛

Wachiu Siu

💡 🐛 📖

motylkov

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

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].