Crate teleborg [] [src]

teleborg

The teleborg library provides an interface to the Telegram bot API.

Getting started

extern crate teleborg;
use teleborg::{Dispatcher, Bot, Updater};
use teleborg::objects::Update;

fn main() {
    // Make sure you have your token
    let bot_token = "bot_token".to_string();
    // Creating a dispatcher which registers all the command and message handlers
    let mut dispatcher = Dispatcher::new();
    // Registering our command which we create below in the form as a function
    dispatcher.add_command_handler("test", test, false);
    // Start the updater, the Updater will start the threads, one of which will poll for updates
    // and send those to the Dispatcher's thread which will act upon it with the registered handlers
    Updater::start(Some(bot_token), None, None, None, dispatcher);
}

// Our first command handler
fn test(bot: &Bot, update: Update, args: Option<Vec<&str>>) {
    bot.reply_to_message(&update, "It works!").unwrap();
}

Modules

error
objects

Structs

Bot

A Bot which will do all the API calls.

Dispatcher

A Dispatcher which will receive updates from the Updater and dispatches them to the registered handlers.

Updater

An Updater which will request updates from the API.

Enums

ChatAction

Represents each chat action.

ParseMode

The parse modes for messages.

StatusCode

An HTTP status code (status-code in RFC 7230 et al.).

Traits

Command

A trait which has to be implemented for all handlers.