All Projects → xelaj → Mtproto

xelaj / Mtproto

Licence: mit
Full-native go implementation of Telegram API

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Mtproto

Madelineproto
Async PHP client/server API for the telegram MTProto protocol
Stars: ✭ 1,776 (+213.78%)
Mutual labels:  telegram-api, hacktoberfest, telegram, mtproto
Groupbutler
This bot can help you in managing your group with rules, anti-flood, description, custom triggers, and much more!
Stars: ✭ 399 (-29.51%)
Mutual labels:  telegram-api, telegram-bot, hacktoberfest, telegram
Novagram
An Object-Oriented PHP library for Telegram Bots
Stars: ✭ 112 (-80.21%)
Mutual labels:  telegram-api, telegram-bot, telegram, mtproto
Sentry Telegram
Plugin for Sentry which allows sending notification via Telegram messenger.
Stars: ✭ 168 (-70.32%)
Mutual labels:  telegram-api, telegram-bot, hacktoberfest, telegram
Telethon
Pure Python 3 MTProto API Telegram client library, for bots too!
Stars: ✭ 5,805 (+925.62%)
Mutual labels:  telegram-api, hacktoberfest, telegram, mtproto
Micro Bot
🤖 Zero-configuration Telegram bot runner
Stars: ✭ 173 (-69.43%)
Mutual labels:  telegram-api, telegram-bot, telegram
Telegram Bot Api
First Telegram Bot API node.js library
Stars: ✭ 205 (-63.78%)
Mutual labels:  telegram-api, telegram-bot, telegram
Trashemail
A hosted disposable email telegram bot; Extremely privacy friendly; Proudly hosted for community.
Stars: ✭ 408 (-27.92%)
Mutual labels:  telegram-bot, hacktoberfest, telegram
Kotlin Telegram Bot
🤖 A wrapper for the Telegram Bot API written in Kotlin
Stars: ✭ 337 (-40.46%)
Mutual labels:  telegram-bot, hacktoberfest, telegram
Core
PHP Telegram Bot based on the official Telegram Bot API
Stars: ✭ 2,899 (+412.19%)
Mutual labels:  telegram-api, telegram-bot, telegram
Tgbot Cpp
C++ library for Telegram bot API
Stars: ✭ 439 (-22.44%)
Mutual labels:  telegram-api, telegram-bot, telegram
WilliamButcherBot
Telegram Group Manager Bot Written In Python Using Pyrogram.
Stars: ✭ 187 (-66.96%)
Mutual labels:  telegram, telegram-bot, mtproto
Pyrogram
Telegram MTProto API Client Library and Framework in Pure Python for Users and Bots
Stars: ✭ 2,252 (+297.88%)
Mutual labels:  telegram-api, telegram, mtproto
tdlight-telegram-bot-api
The TDLight Telegram Bot API is an actively enhanced fork of the original Bot API, featuring experimental user support, proxies, unlimited files size, and more.
Stars: ✭ 71 (-87.46%)
Mutual labels:  telegram-bot, telegram-api, mtproto
Telegram
Telegram Bot API Wrapper for Scala
Stars: ✭ 310 (-45.23%)
Mutual labels:  telegram-api, telegram-bot, telegram
Node Telegram Api
A simple API to create and control Telegram bots
Stars: ✭ 117 (-79.33%)
Mutual labels:  telegram-api, telegram-bot, telegram
Mtproto Core
Telegram API JS (MTProto) client library for browser and nodejs
Stars: ✭ 242 (-57.24%)
Mutual labels:  telegram-api, telegram, mtproto
Grammers
(tele)gramme.rs - use Telegram's API from Rust
Stars: ✭ 109 (-80.74%)
Mutual labels:  telegram-api, telegram, mtproto
Python Telegram
Python client for the Telegram's tdlib
Stars: ✭ 246 (-56.54%)
Mutual labels:  telegram-api, telegram-bot, telegram
Telegram
✈️ Telegram Notifications Channel for Laravel
Stars: ✭ 450 (-20.49%)
Mutual labels:  telegram-bot, hacktoberfest, telegram

MTProto

godoc reference Go Report Card codecov license MIT chat telegram version v1.0.0 unstable

FINALLY! Full-native implementation of MTProto protocol on Golang!

english русский 简体中文

Features

Full native implementation

All code, from sending requests to encryption serialization is written on pure golang. You don't need to fetch any additional dependencies.

Latest API version (117+)

Lib is supports all the API and MTProto features, including video calls and post comments. You can create additional pull request to push api updates!

Reactive API updates (generated from TL schema)

All changes in TDLib and Android client are monitoring to get the latest features and changes in TL schemas. New methods are creates by adding new lines into TL schema and updating generated code!

Implements ONLY network tools

No more SQLite databases and caching unnecessary files, that you don't need. Also you can control how sessions are stored, auth process and literally everything that you want to!

Multiaccounting, Gateway mode

You can use more than 10 accounts at same time! xelaj/MTProto doesn't create huge overhead in memory or cpu consumption as TDLib. Thanks for that, you can create huge number of connection instances and don't worry about memory overload!

How to use

MTProto is really hard in implementation, but it's really easy to use. Basically, this lib sends serialized structures to Telegram servers (just like gRPC, but from Telegram LLC.). It looks like this:

func main() {
    client := &Telegram.NewClient()
    // for each method there is specific struct for serialization (<method_name>Params{})
    result, err := client.MakeRequest(&telegram.GetSomeInfoParams{FromChatId: 12345})
    if err != nil {
        panic(err)
    }

    resp, ok := result.(*SomeResponseObject)
    if !ok {
        panic("Oh no! Wrong type!")
    }
}

Not so hard, huh? But there is even easier way to send request, which is included in TL API specification:

func main() {
    client := &Telegram.NewClient()
    resp, err := client.GetSomeInfo(12345)
    if err != nil {
        panic(err)
    }

    // resp will be already asserted as described in TL specs of API
    // if _, ok := resp.(*SomeResponseObject); !ok {
    //     panic("No way, we found a bug! Create new issue!")
    // }

    println(resp.InfoAboutSomething)
}

You do not need to think about encryption, key exchange, saving and restoring session, and more routine things. It is already implemented just for you.

Code examples are here

Full docs are here

Getting started

Simple How-To

Installation is simple. Just do go get:

go get github.com/xelaj/mtproto

After that you can generate source structures of methods and functions if you wish to. To do it, use go generate

go generate github.com/xelaj/mtproto

That's it! You don't need to do anything more!

What is InvokeWithLayer?

It's Telegram specific feature. I you want to create client instance and get information about the current servers configuration, you need to do something like this:

    resp, err := client.InvokeWithLayer(apiVersion, &telegram.InitConnectionParams{
        ApiID:          124100,
        DeviceModel:    "Unknown",
        SystemVersion:  "linux/amd64",
        AppVersion:     "0.1.0",
        // just use "en", any other language codes will receive error. See telegram docs for more info.
        SystemLangCode: "en",
        LangCode:       "en",
        // HelpGetConfig() is ACTUAL request, but wrapped in InvokeWithLayer
        Query:          &telegram.HelpGetConfigParams{},
    })

Why? We don't know! This method is described in Telegram API docs, any other starting requests will receive error.

How to use phone authorization?

Example here

func AuthByPhone() {
    resp, err := client.AuthSendCode(
        yourPhone,
        appID,
        appHash,
        &telegram.CodeSettings{},
    )
	if err != nil {
        panic(err)
    }


    // You can make any way to enter verification code, like in
    // http requests, or what you like. You just need to call two
    // requests, that's main method.
	fmt.Print("Auth code:")
	code, _ := bufio.NewReader(os.Stdin).ReadString('\n')
    code = strings.Replace(code, "\n", "", -1)

    // this is ALL process of authorization! :)
    fmt.Println(client.AuthSignIn(yourPhone, resp.PhoneCodeHash, code))
}

That's it! You don't need any cycles, code is ready-to-go for async execution. You just need to follow the official Telegram API documentation.

Telegram Deeplinks

Want to deal those freaky tg:// links? See deeplinks package, here is the simplest how-to:

package main

import (
    "fmt"

    "github.com/xelaj/mtproto/telegram/deeplinks"
)

func main() {
    link, _ := deeplinks.Resolve("t.me/xelaj_developers")
    // btw, ResolveParameters is just struct for tg://resolve links, not all links are resolve
    resolve := link.(*deeplinks.ResolveParameters)
    fmt.Printf("Oh! Looks like @%v is the best developers channel in telegram!\n", resolve.Domain)
}

Docs are empty. Why?

There is a pretty huge chunk of documentation. We are ready to describe every method and object, but its requires a lot of work. Although all methods are already described here.

Does this project support Windows?

Technically — yes. In practice — components don't require specific architecture, but we didn't test it yet. If you have any problems running it, just create an issue, we will try to help.

Why Telegram API soooo unusable?

Well... Read this issue about TON source code. Use google translate, this issue will answer to all your questions.

Who use it

Contributing

Please read contributing guide if you want to help. And the help is very necessary!

Don't want code? Read this page! We love nocoders!

Security bugs?

Please, don't create issue which is describe security bug, this can be too offensive! Instead, please read this notifiaction and follow that steps to notify us about problem.

TODO

  • [x] Basic MTProto implementation
  • [x] Implement all Methods for latest layer
  • [x] Make TL Encoder/Decoder
  • [x] Get away from panics in parsing TL
  • [ ] Support MTProxy
  • [ ] Support socks5 as well
  • [ ] Multiple tests
  • [ ] Write amazing docs

Authors

License

WARNING! This project is only maintained by Xelaj inc., however copyright of this source code IS NOT owned by Xelaj inc. at all. If you want to connect with code owners, write mail to this email. For all other questions like any issues, PRs, questions, etc. Use GitHub issues, or find email on official website.

This project is licensed under the MIT License - see the LICENSE file for details

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