Skip to content

Repository files navigation

Rust Telegram Bot Library

Build StatusLicenseCrates.io

Documentation:Latest crates.io versionmaster

A library for writing your own Telegram bots. More information here. Official API here.

Example

Here is a simple example (see example/simple.rs):

externcrate futures;externcrate telegram_bot;externcrate tokio_core;use std::env;use futures::Stream;use tokio_core::reactor::Core;use telegram_bot::*;fnmain(){letmut core = Core::new().unwrap();let token = env::var("TELEGRAM_BOT_TOKEN").unwrap();let api = Api::configure(token).build(core.handle()).unwrap();// Fetch new updates via long poll methodlet future = api.stream().for_each(|update| {// If the received update contains a new message...ifletUpdateKind::Message(message) = update.kind{ifletMessageKind::Text{ref data, ..} = message.kind{// Print received text message to stdout.println!("<{}>: {}",&message.from.first_name, data);// Answer message with "Hi".
api.spawn(message.text_reply(format!("Hi, {}! You just wrote '{}'",&message.from.first_name, data)));}}Ok(())});
core.run(future).unwrap();}

You can find a bigger examples in the examples.

Usage

This library is available via crates.io. In order to use it, just add this to your Cargo.toml:

telegram-bot = "0.6"

Collaboration

Yes please! Every type of contribution is welcome: Create issues, hack some code or make suggestions. Don't know where to start? Good first issues are tagged with up for grab.

About

Rust Library for creating a Telegram Bot

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages