{"id":13648696,"url":"https://github.com/bytesnake/telebot","last_synced_at":"2025-04-04T14:06:23.191Z","repository":{"id":44642584,"uuid":"77736801","full_name":"bytesnake/telebot","owner":"bytesnake","description":"Write Telegram bots in Rust with Tokio and Futures","archived":false,"fork":false,"pushed_at":"2022-02-02T16:52:22.000Z","size":549,"stargazers_count":210,"open_issues_count":10,"forks_count":33,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-14T17:34:36.400Z","etag":null,"topics":["async","bot","chat","rust","telegram","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bytesnake.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-31T11:01:46.000Z","updated_at":"2024-10-07T21:29:14.000Z","dependencies_parsed_at":"2022-09-26T20:40:53.276Z","dependency_job_id":null,"html_url":"https://github.com/bytesnake/telebot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytesnake%2Ftelebot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytesnake%2Ftelebot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytesnake%2Ftelebot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bytesnake%2Ftelebot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bytesnake","download_url":"https://codeload.github.com/bytesnake/telebot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247190231,"owners_count":20898700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","bot","chat","rust","telegram","telegram-bot"],"created_at":"2024-08-02T01:04:27.845Z","updated_at":"2025-04-04T14:06:23.165Z","avatar_url":"https://github.com/bytesnake.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"Telebot - Telegram Bot Library for Rust\n======================================\n\n[![Travis Build Status](https://travis-ci.org/bytesnake/telebot.svg)](https://travis-ci.org/bytesnake/telebot)\n[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/bytesnake/telebot/blob/master/LICENSE)\n[![Crates.io](https://img.shields.io/crates/v/telebot.svg)](https://crates.io/crates/telebot)\n[![doc.rs](https://docs.rs/telebot/badge.svg)](https://docs.rs/telebot)\n\nThis library allows you to write a Telegram Bot in the Rust language. It's an almost complete wrapper for the Telegram Bot API and uses hyper to send requests to the Telegram server. Each Telegram function call returns a future which carries the actual bot and the answer. \n\n## Usage\nAdd this to your `Cargo.toml`\n``` toml\n[dependencies]\ntelebot = \"0.3.1\"\n```\n## How it works\nThis example shows the basic usage of the telebot library. It creates a new handler for a simple \"/reply\" command and replies the received text. The tokio eventloop polls every 200ms for new updates and matches them with the registered events. If the command matches with \"/reply\" it will call the function and execute the returned future.\n\n``` rust\nuse telebot::Bot;\nuse futures::stream::Stream;\nuse std::env;\n\n// import all available functions\nuse telebot::functions::*;\n\nfn main() {\n    // Create the bot\n    let mut bot = Bot::new(\u0026env::var(\"TELEGRAM_BOT_KEY\").unwrap()).update_interval(200);\n\n    // Register a reply command which answers a message\n    let handle = bot.new_cmd(\"/reply\")\n        .and_then(|(bot, msg)| {\n            let mut text = msg.text.unwrap().clone();\n            if text.is_empty() {\n                text = \"\u003cempty\u003e\".into();\n            }\n\n            bot.message(msg.chat.id, text).send()\n        })\n        .for_each(|_| Ok(()));\n\n    bot.run_with(handle);\n}\n```\n\n## Additional example\nThe former example was very simple with just one handler and no error handling. If you want to see a further explained and illustrated one, please see [here](example.md).\n\n## Find a Telegram function in the source code\nThis crate uses custom derive to generate functions of the Telegram API. Therefore each complete function is described with a struct in [functions.rs](src/functions.rs) and the supplemental crate telebot-derive generates the complete signature. In order to find a function, the struct signature can be used. For example consider sendLocation:\n``` rust\n/// Use this method to send point on the map. On success, the sent Message is returned.\n#[derive(TelegramFunction, Serialize)]\n#[call = \"sendLocation\"]\n#[answer = \"Message\"]\n#[function = \"location\"]\npub struct SendLocation {\n    chat_id: u32,\n    latitude: f32,\n    longitude: f32,\n#[serde(skip_serializing_if=\"Option::is_none\")]\n    disable_notification: Option\u003cbool\u003e,\n#[serde(skip_serializing_if=\"Option::is_none\")]\n    reply_to_message_id: Option\u003cu32\u003e,\n#[serde(skip_serializing_if=\"Option::is_none\")]\n    reply_markup: Option\u003cNotImplemented\u003e\n}\n```\n\nThe field \"function\" defines the name of the function in the local API. Each optional field in the struct can be changed by calling an additional function with the name of the field.\nSo for example to send the location of Paris to chat 432432 without notification: `bot.location(432432, 48.8566, 2.3522).disable_notification(true).send() `\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in the work by you, as defined in the Apache-2.0\nlicense, shall be dual licensed as above, without any additional terms or\nconditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytesnake%2Ftelebot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytesnake%2Ftelebot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytesnake%2Ftelebot/lists"}