Crate telebot [] [src]

Write a telegram bot in Rust

This library allows you to write a Telegram Bot in Rust. It's an almost complete wrapper for the Telegram Bot API and uses tokio-curl to send a request to the Telegram server. Each Telegram function call returns a future and carries the actual bot and the answer. You can find all available functions in src/functions.rs. The getter/setter etc. will be automatically implemented by telebot-derive.

Example usage

extern crate telebot;
extern crate tokio_core;
extern crate futures;
use telebot::bot;
use tokio_core::reactor::Core;                       
use futures::stream::Stream;
use futures::Future;
use std::fs::File;
 
// import all available functions
use telebot::functions::*;
fn main() {
    let mut lp = Core::new().unwrap();
    let bot = bot::RcBot::new(lp.handle(), "<TELEGRAM-BOT-TOKEN>")
        .update_interval(200);
    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()
    });
    bot.register(handle);

    bot.run(&mut lp).unwrap();
}

Modules

bot

This is the actual Bot module. For ergonomic reasons there is a RcBot which composes the real bot as an underlying field. You should always use RcBot.

error
file

A Telegram file which contains a readable source and a filename

functions

Available telegram functions, copied from https://core.telegram.org/bots/api#available-methods

objects

The complete list of telegram types, copied from: https://core.telegram.org/bots/api#available-types