All Projects → tg-rs → tgbot

tg-rs / tgbot

Licence: MIT license
A full-featured Telegram Bot API client

Programming Languages

rust
11053 projects
shell
77523 projects

Projects that are alternatives of or similar to tgbot

ZEGBot
Build your Telegram Bot with Swift! (works on macOS / Ubuntu)
Stars: ✭ 52 (+100%)
Mutual labels:  telegram-bot-api
Nutgram
The Telegram bot framework that doesn't drive you nuts.
Stars: ✭ 206 (+692.31%)
Mutual labels:  telegram-bot-api
teleflask
A python telegram bot framework based on flask and pytgbot
Stars: ✭ 43 (+65.38%)
Mutual labels:  telegram-bot-api
telegram-log
Send a Telegram message when your scripts fire an exception or when they finish their execution.
Stars: ✭ 16 (-38.46%)
Mutual labels:  telegram-bot-api
telresender
A Telegram bot, which resend your message to another account
Stars: ✭ 22 (-15.38%)
Mutual labels:  telegram-bot-api
telegram-bot-sdk
🤖 Telegram Bot API PHP SDK. Create Telegram Bots with PHP Easily! [WIP - DO NOT USE IN PRODUCTION YET]
Stars: ✭ 64 (+146.15%)
Mutual labels:  telegram-bot-api
python-telegram-bot-calendar
Python inline calendar for Telegram bots
Stars: ✭ 71 (+173.08%)
Mutual labels:  telegram-bot-api
aiogram dialog
GUI framework on top of aiogram
Stars: ✭ 263 (+911.54%)
Mutual labels:  telegram-bot-api
finch
A Golang Telegram Bot framework
Stars: ✭ 23 (-11.54%)
Mutual labels:  telegram-bot-api
github client
Open source bot telegram menggunakan bahasa code dart
Stars: ✭ 24 (-7.69%)
Mutual labels:  telegram-bot-api
wikibot
A 🤖 which provides features from Wikipedia like summary, title searches, location API etc.
Stars: ✭ 25 (-3.85%)
Mutual labels:  telegram-bot-api
react-telegram
(WIP) A React custom renderer for the Telegram Bot API.
Stars: ✭ 14 (-46.15%)
Mutual labels:  telegram-bot-api
todoist bot
@Todoist_bot for Telegram (UNofficial)
Stars: ✭ 35 (+34.62%)
Mutual labels:  telegram-bot-api
botBasicoGlitch
Bot básico hecho mediante www.glitch.com y con Python3 , el cual irá creciendo conforme hagamos tutoriales/clases/dudas/llamadas en discord. Grupo de Telegram: http://t.me/boterostg
Stars: ✭ 23 (-11.54%)
Mutual labels:  telegram-bot-api
tdlight-java
Complete Bot and Userbot Telegram library based on TDLib
Stars: ✭ 128 (+392.31%)
Mutual labels:  telegram-bot-api
nestjs-telegraf
🤖 Powerful Nest module for easy and fast creation Telegram bots
Stars: ✭ 300 (+1053.85%)
Mutual labels:  telegram-bot-api
telegram-standup-bot
Very simple telegram bot for submitting daily standups
Stars: ✭ 23 (-11.54%)
Mutual labels:  telegram-bot-api
JavaTelegramBot-API
Java Telegram Bot API
Stars: ✭ 34 (+30.77%)
Mutual labels:  telegram-bot-api
telega
Telegram Bot API implementation
Stars: ✭ 21 (-19.23%)
Mutual labels:  telegram-bot-api
telegram
Golang Telegram Bot API
Stars: ✭ 13 (-50%)
Mutual labels:  telegram-bot-api

TGBOT

A full-featured Telegram Bot API client

CI Coverage Version Downloads Release Documentation Master Documentation Telegram Chat License

Installation

[dependencies]
tgbot = "0.18.0"

Versioning

This project adheres to ZeroVer

Example

Long polling:

use futures_util::future::BoxFuture;
use std::env;
use tgbot::{Api, UpdateHandler};
use tgbot::longpoll::LongPoll;
use tgbot::methods::SendMessage;
use tgbot::types::{Update, UpdateKind};

struct Handler {
    api: Api,
}

impl UpdateHandler for Handler {
    type Future = BoxFuture<'static, ()>;

    fn handle(&self, update: Update) -> Self::Future {
        println!("got an update: {:?}\n", update);
        let api = self.api.clone();
        Box::pin(async move {
            if let UpdateKind::Message(message) = update.kind {
                if let Some(text) = message.get_text() {
                    let chat_id = message.get_chat_id();
                    let method = SendMessage::new(chat_id, text.data.clone());
                    api.execute(method).await.unwrap();
                }
            }
        })
    }
}

#[tokio::main]
async fn main() {
    let token = env::var("TGBOT_TOKEN").expect("TGBOT_TOKEN is not set");
    let api = Api::new(token).expect("Failed to create API");
    LongPoll::new(api.clone(), Handler { api }).run().await;
}

Webhook:

use futures_util::future::BoxFuture;
use tgbot::{UpdateHandler, types::Update, webhook};

struct Handler;

impl UpdateHandler for Handler {
    type Future = BoxFuture<'static, ()>;

    fn handle(&self, update: Update) -> Self::Future {
        Box::pin(async move {
            println!("got an update: {:?}\n", update);
        })
    }
}

#[tokio::main]
async fn main() {
    webhook::run_server(([127, 0, 0, 1], 8080), "/", Handler).await.unwrap();
}

See more examples in examples directory.

In order to run an example you need to create a .env file:

cp sample.env .env

Don't forget to change value of TGBOT_TOKEN and other variables if required.

Changelog

See CHANGELOG.md

Code of Conduct

See CODE_OF_CONDUCT.md.

LICENSE

The MIT License (MIT)

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