vaegram 0.2.0

Telegram MTProto client library for users and bots
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::future::Future;

use crate::Client;
use crate::errors::Result;
use crate::handlers::{HandlerRef, UpdateKind, callback};

impl Client {
    /// Runs when `run` starts, before the first update; `run` waits for it. An `Err` goes to `on_error` and `run`
    /// carries on. Registering again replaces it; `group` and `stop` don't apply.
    pub fn on_start<F, Fut, T>(&self, f: F) -> HandlerRef<'_>
    where
        F: Fn(Client) -> Fut + Send + Sync + 'static,
        Fut: Future<Output = Result<T>> + Send + 'static,
    {
        self.register(UpdateKind::Start, |r, id| r.hooks.set(UpdateKind::Start, id, callback(f)))
    }
}