telegram-client

Build Status

Telegram client for rust.

This crate use td to call telegram client api, td create is rtdlib

Usage

1.3.*

toml [dependencies] telegram-client = "1.3.*"

1.4.*

toml [dependencies] telegram-client = "1.4.*"

version

Since the rtdlib version follows td, a version number less than 100 is reserved for td release.

Version mapping

| telegram-client | td | |--------------------|---------| | 1.3.* | 1.3.* | | 1.4.* | 1.4.* |

Note

Note that you need libtdjson.so in your path for building and running your application. See also rtdlib for more details.

Examples

```rust fn main() { let api = Api::default(); let mut client = Client::new(api.clone()); let listener = client.listener();

listener.on_receive(|(api, json)| { debug!("receive {}", json); Ok(()) });

client.daemon("telegram-rs"); } ```

more examples

Event

Most of the events are from td, two events of particular concern.

on_receive

This event is receive everything from td, returned data type is a json string.

on_exception

When td returned json can not deserialize, or your event handler returned error. will be call is event.

a sample of event handler returned error

rust listener.on_proxy(|(api, pxy)| { debug!("Proxy info => {:?}", pxy); Err(TGError::new("some error")) });