All Projects → bytesnake → Telebot

bytesnake / Telebot

Licence: other
Write Telegram bots in Rust with Tokio and Futures

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Telebot

Telebot.nim
Async client for Telegram Bot API in pure Nim [Bot API 5.1]
Stars: ✭ 93 (-48.04%)
Mutual labels:  bot, telegram-bot, async, chat, telegram
Groupbutler
This bot can help you in managing your group with rules, anti-flood, description, custom triggers, and much more!
Stars: ✭ 399 (+122.91%)
Mutual labels:  bot, telegram-bot, chat, telegram
Telegram Bot
Ruby gem for building Telegram Bot with optional Rails integration
Stars: ✭ 433 (+141.9%)
Mutual labels:  bot, telegram-bot, async, telegram
Vk To Telegram Transfer Bot
Бот, пересылающий сообщения из чатов ВК в Telegram и обратно
Stars: ✭ 143 (-20.11%)
Mutual labels:  bot, telegram-bot, telegram
Tgdr
Telegram directory to discover channels, bots and groups.
Stars: ✭ 91 (-49.16%)
Mutual labels:  bot, telegram-bot, telegram
Telegram Bot
Telegram Bot using AWS API Gateway and AWS Lambda
Stars: ✭ 96 (-46.37%)
Mutual labels:  bot, telegram-bot, telegram
Callsmusic
The first open-source PyTgCalls-based project.
Stars: ✭ 62 (-65.36%)
Mutual labels:  telegram-bot, async, telegram
Zanzara
Asynchronous PHP Telegram Bot Framework built on top of ReactPHP
Stars: ✭ 107 (-40.22%)
Mutual labels:  bot, telegram-bot, telegram
Telegram Bot Github
Allows to you receive GitHub notifications right in the Telegram
Stars: ✭ 103 (-42.46%)
Mutual labels:  bot, telegram-bot, telegram
Novagram
An Object-Oriented PHP library for Telegram Bots
Stars: ✭ 112 (-37.43%)
Mutual labels:  bot, telegram-bot, telegram
Telegram Bot Sdk
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
Stars: ✭ 2,212 (+1135.75%)
Mutual labels:  bot, telegram-bot, telegram
Micro Bot
🤖 Zero-configuration Telegram bot runner
Stars: ✭ 173 (-3.35%)
Mutual labels:  bot, telegram-bot, telegram
Telegram Pm Chat Bot
Telegram Private Message Chat Bot
Stars: ✭ 69 (-61.45%)
Mutual labels:  bot, chat, telegram
Turibot
TuriBot is a simple way to communicate with Telegram APIs in PHP
Stars: ✭ 68 (-62.01%)
Mutual labels:  bot, telegram-bot, telegram
Telegram Clonebot
Simple Bot to clone Google Drive Files (or Folders) to your Team Drive[or Normal Drive]. P.S This is not a Mirror Bot. Enjoy ✌🏻
Stars: ✭ 114 (-36.31%)
Mutual labels:  bot, telegram-bot, telegram
Node Telegram Api
A simple API to create and control Telegram bots
Stars: ✭ 117 (-34.64%)
Mutual labels:  bot, telegram-bot, telegram
Hackernewsbot
📰 Telegram bot that posts new hot stories from Hacker News to telegram channel
Stars: ✭ 103 (-42.46%)
Mutual labels:  bot, telegram-bot, telegram
Expressbot
一个可以帮你订阅、查询快递物流、跟你闲聊Telegram机器人
Stars: ✭ 137 (-23.46%)
Mutual labels:  bot, telegram-bot, telegram
Pockebot
Read It Later for Telegram
Stars: ✭ 56 (-68.72%)
Mutual labels:  bot, telegram-bot, telegram
Telebot
The easy way to write Telegram bots in Node.js
Stars: ✭ 1,096 (+512.29%)
Mutual labels:  bot, telegram-bot, telegram

Telebot - Telegram Bot Library for Rust

Travis Build Status License MIT Crates.io doc.rs

This library allows you to write a Telegram Bot in the Rust language. It's an almost complete wrapper for the Telegram Bot API and uses hyper to send requests to the Telegram server. Each Telegram function call returns a future which carries the actual bot and the answer.

Usage

Add this to your Cargo.toml

[dependencies]
telebot = "0.3.1"

How it works

This example shows the basic usage of the telebot library. It creates a new handler for a simple "/reply" command and replies the received text. The tokio eventloop polls every 200ms for new updates and matches them with the registered events. If the command matches with "/reply" it will call the function and execute the returned future.

use telebot::Bot;
use futures::stream::Stream;
use std::env;

// import all available functions
use telebot::functions::*;

fn main() {
    // Create the bot
    let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);

    // Register a reply command which answers a message
    let handle = bot.new_cmd("/reply")
        .and_then(|(bot, msg)| {
            let mut text = msg.text.unwrap().clone();
            if text.is_empty() {
                text = "<empty>".into();
            }

            bot.message(msg.chat.id, text).send()
        })
        .for_each(|_| Ok(()));

    bot.run_with(handle);
}

Additional example

The former example was very simple with just one handler and no error handling. If you want to see a further explained and illustrated one, please see here.

Find a Telegram function in the source code

This crate uses custom derive to generate functions of the Telegram API. Therefore each complete function is described with a struct in functions.rs and the supplemental crate telebot-derive generates the complete signature. In order to find a function, the struct signature can be used. For example consider sendLocation:

/// Use this method to send point on the map. On success, the sent Message is returned.
#[derive(TelegramFunction, Serialize)]
#[call = "sendLocation"]
#[answer = "Message"]
#[function = "location"]
pub struct SendLocation {
    chat_id: u32,
    latitude: f32,
    longitude: f32,
#[serde(skip_serializing_if="Option::is_none")]
    disable_notification: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")]
    reply_to_message_id: Option<u32>,
#[serde(skip_serializing_if="Option::is_none")]
    reply_markup: Option<NotImplemented>
}

The field "function" defines the name of the function in the local API. Each optional field in the struct can be changed by calling an additional function with the name of the field. So for example to send the location of Paris to chat 432432 without notification: bot.location(432432, 48.8566, 2.3522).disable_notification(true).send()

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

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