Crates.io | rust_telegram_bot |
lib.rs | rust_telegram_bot |
version | 0.0.1 |
source | src |
created_at | 2023-09-20 11:10:50.327454 |
updated_at | 2023-09-20 11:10:50.327454 |
description | TelegramBot API implementation |
homepage | |
repository | https://github.com/NeverDieOne/rust_telegram_bot |
max_upload_size | |
id | 978037 |
size | 34,243 |
Имплементация TelegramBot API на Rust
use rust_telegram_bot::ext::{
updater::Updater,
context::Context
};
use rust_telegram_bot::telegram::types::Update;
fn echo(update: &Update, context: &Context) {
let user_id = update.get_effective_user().id;
let text = &update.message.text;
let _ = context.bot.send_message(user_id as i32, text);
}
fn main() {
let mut updater = Updater::new(String::from("YOUR TOKEN"));
updater.register_handler(echo);
updater.start_polling().expect("Something went wrong");
}