diff --git a/Cargo.toml b/Cargo.toml index 18c1d9c..a4db3c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ license = "AGPL-3.0-or-later" keywords = ["game", "deserialization", "legends-of-runeterra", "bot", "search"] categories = ["games", "parser-implementations"] + [dependencies] # base log = { version = "0.4.17" } @@ -30,10 +31,27 @@ tokio = { version = "1.20.1", features = ["rt-multi-thread", "macros"], optiona # discord # matrix + [features] # data = [] # Always included exec = ["pretty_env_logger", "glob"] search = ["tantivy"] telegram = ["exec", "search", "teloxide", "reqwest", "tokio"] discord = ["exec", "search"] -# matrix = ["exec", "search"] +matrix = ["exec", "search"] + + +[lib] +name = "patched_porobot" + +[[bin]] +name = "patched_porobot_telegram" +required-features = ["telegram"] + +[[bin]] +name = "patched_porobot_discord" +required-features = ["discord"] + +[[bin]] +name = "patched_porobot_matrix" +required-features = ["matrix"] diff --git a/src/bin/patched_porobot_discord.rs b/src/bin/patched_porobot_discord.rs new file mode 100644 index 0000000..c89b901 --- /dev/null +++ b/src/bin/patched_porobot_discord.rs @@ -0,0 +1,3 @@ +fn main() { + todo!(); +} diff --git a/src/bin/patched_porobot_matrix.rs b/src/bin/patched_porobot_matrix.rs new file mode 100644 index 0000000..c89b901 --- /dev/null +++ b/src/bin/patched_porobot_matrix.rs @@ -0,0 +1,3 @@ +fn main() { + todo!(); +} diff --git a/src/bin/patched_porobot_telegram.rs b/src/bin/patched_porobot_telegram.rs index a9ec725..77ca0f9 100644 --- a/src/bin/patched_porobot_telegram.rs +++ b/src/bin/patched_porobot_telegram.rs @@ -1,26 +1,44 @@ -#[cfg(not(feature = "telegram"))] -fn main() { - println!("The `telegram` feature was not included on compilation, therefore this binary is not available.") -} +//! # [@patchedporobot] +//! +//! Inline bot for searching and sending Legends of Runeterra cards in Telegram chats +//! +//! ## Usage +//! +//! [@patchedporobot] is a inline bot: this means that you can use it everywhere, without having to add it to chats. +//! +//! You can search for a card by entering in the "Write a message..." bot the username of the bot, followed by the card you want to search for: +//! ```text +//! @patchedporobot braum +//! ``` +//! ```text +//! @patchedporobot poro +//! ``` +//! ```text +//! @patchedporobot noxus +//! ``` +//! +//! +//! [@patchedporobot]: https://t.me/patchedporobot -#[cfg(feature = "telegram")] +use std::path::PathBuf; +use log::*; +use patched_porobot::data::setbundle::card::{Card, CardIndex}; +use patched_porobot::data::corebundle::CoreBundle; +use patched_porobot::data::setbundle::SetBundle; +use patched_porobot::data::corebundle::globals::LocalizedGlobalsIndexes; +use patched_porobot::search::cardsearch::CardSearchEngine; +use patched_porobot::telegram::inline::card_to_inlinequeryresult; +use patched_porobot::telegram::handler::{inline_query_handler, message_handler}; +use teloxide::payloads::{AnswerInlineQuery, SendMessage}; +use teloxide::requests::JsonRequest; +use teloxide::types::{Recipient, ParseMode}; +use teloxide::prelude::*; +use itertools::Itertools; + + +#[doc(hidden)] #[tokio::main] async fn main() { - use std::path::PathBuf; - use log::*; - use patched_porobot::data::setbundle::card::{Card, CardIndex}; - use patched_porobot::data::corebundle::CoreBundle; - use patched_porobot::data::setbundle::SetBundle; - use patched_porobot::data::corebundle::globals::LocalizedGlobalsIndexes; - use patched_porobot::search::cardsearch::CardSearchEngine; - use patched_porobot::telegram::inline::card_to_inlinequeryresult; - use patched_porobot::telegram::handler::{inline_query_handler, message_handler}; - use teloxide::payloads::{AnswerInlineQuery, SendMessage}; - use teloxide::requests::JsonRequest; - use teloxide::types::{Recipient, ParseMode}; - use teloxide::prelude::*; - use itertools::Itertools; - pretty_env_logger::init(); debug!("Logger initialized successfully!"); diff --git a/src/discord/mod.rs b/src/discord/mod.rs index e69de29..bccbf63 100644 --- a/src/discord/mod.rs +++ b/src/discord/mod.rs @@ -0,0 +1,3 @@ +//! Module providing utilities to be used in the `patched_porobot_discord` executable target. +//! +//! While adding new features to this module, remember that binaries [can only access the public API of the crate](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#binaries), as they considered a separate crate from the rest of the project. diff --git a/src/lib.rs b/src/lib.rs index ac0ef5a..8971342 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,16 +1,32 @@ //! Crate providing parsing, indexing, and displaying utilities for Legends of Runeterra data files. //! +//! # Usage +//! +//! This is the technical documentation of the [`patched_porobot`](self) Rust crate. +//! +//! If you are looking for the documentation of its implementations, please visit one of the following pages: +//! +//! - [Usage of the Telegram bot](../patched_porobot_telegram) +//! - [Usage of the Discord bot](../patched_porobot_discord) +//! - [Usage of the Matrix bot](../patched_porobot_matrix) +//! //! # Features //! -//! - `search`: Adds a search engine based on [tantivy] for Legends of Runeterra data. -//! - `telegram`: Adds a [Telegram bot] based on [teloxide] to send Legends of Runeterra cards in chats. +//! [`patched_porobot`](self) supports conditional compilation via [Cargo features](https://doc.rust-lang.org/cargo/reference/features.html). +//! +//! While the [`data`] module is always included, [the other modules](#modules) provided by this crate may be used by selecting the features of the same name. +//! +//! ## Binaries +//! +//! Additionally, every one of the following features enables the compilation of an additional binary target: +//! +//! - [`telegram`] enables the compilation of `patched_porobot_telegram`, a [Telegram inline bot](https://core.telegram.org/bots/api) allowing users to search and send cards in any Telegram chat; +//! - [`discord`] enables the compilation of `patched_porobot_discord`, a [Discord bot](https://discord.com/developers/docs/intro#bots-and-apps) allowing Discord servers the bot is added to to search and send cards in their channels; +//! - [`matrix`] enables the compilation of `patched_porobot_matrix`, a Matrix bot parsing messages in the rooms where it is added to to send details about the cards mentioned in messages. //! //! # Legal //! -//! [patched_porobot](self) isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games, and all associated properties are trademarks or registered trademarks of Riot Games, Inc. -//! -//! -//! [Telegram bot]: https://core.telegram.org/bots/api +//! [`patched_porobot`](self) isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games, and all associated properties are trademarks or registered trademarks of Riot Games, Inc. #![warn(missing_docs)] #![doc(html_logo_url = "https://raw.githubusercontent.com/Steffo99/patched-porobot/main/icon.png")] @@ -25,3 +41,6 @@ pub mod telegram; #[cfg(feature = "discord")] pub mod discord; + +#[cfg(feature = "matrix")] +pub mod matrix; diff --git a/src/matrix/mod.rs b/src/matrix/mod.rs new file mode 100644 index 0000000..419eee7 --- /dev/null +++ b/src/matrix/mod.rs @@ -0,0 +1,4 @@ +//! Module providing utilities to be used in the `patched_porobot_matrix` executable target. +//! +//! While adding new features to this module, remember that binaries [can only access the public API of the crate](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#binaries), as they considered a separate crate from the rest of the project. + diff --git a/src/telegram/USAGE.md b/src/telegram/USAGE.md new file mode 100644 index 0000000..8ae0569 --- /dev/null +++ b/src/telegram/USAGE.md @@ -0,0 +1 @@ +# Test diff --git a/src/telegram/mod.rs b/src/telegram/mod.rs index 6352696..b396088 100644 --- a/src/telegram/mod.rs +++ b/src/telegram/mod.rs @@ -1,6 +1,6 @@ -//! Module providing utilities to be used in the [crate::bin::telegrambot]. +//! Module providing utilities to be used in the `patched_porobot_telegram` executable target. //! -//! Remember while adding new features to this module that binaries [can only access the public API of the crate](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#binaries). +//! While adding new features to this module, remember that binaries [can only access the public API of the crate](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#binaries), as they considered a separate crate from the rest of the project. pub mod display; pub mod inline;