1
Fork 0
mirror of https://github.com/Steffo99/patched-porobot.git synced 2024-12-23 01:54:22 +00:00

Documentation and structure improvements

This commit is contained in:
Steffo 2022-08-08 19:55:59 +02:00
parent 86684d6840
commit bd335b4712
Signed by: steffo
GPG key ID: 6965406171929D01
9 changed files with 98 additions and 29 deletions

View file

@ -9,6 +9,7 @@ license = "AGPL-3.0-or-later"
keywords = ["game", "deserialization", "legends-of-runeterra", "bot", "search"] keywords = ["game", "deserialization", "legends-of-runeterra", "bot", "search"]
categories = ["games", "parser-implementations"] categories = ["games", "parser-implementations"]
[dependencies] [dependencies]
# base # base
log = { version = "0.4.17" } log = { version = "0.4.17" }
@ -30,10 +31,27 @@ tokio = { version = "1.20.1", features = ["rt-multi-thread", "macros"], optiona
# discord # discord
# matrix # matrix
[features] [features]
# data = [] # Always included # data = [] # Always included
exec = ["pretty_env_logger", "glob"] exec = ["pretty_env_logger", "glob"]
search = ["tantivy"] search = ["tantivy"]
telegram = ["exec", "search", "teloxide", "reqwest", "tokio"] telegram = ["exec", "search", "teloxide", "reqwest", "tokio"]
discord = ["exec", "search"] 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"]

View file

@ -0,0 +1,3 @@
fn main() {
todo!();
}

View file

@ -0,0 +1,3 @@
fn main() {
todo!();
}

View file

@ -1,11 +1,25 @@
#[cfg(not(feature = "telegram"))] //! # [@patchedporobot]
fn main() { //!
println!("The `telegram` feature was not included on compilation, therefore this binary is not available.") //! 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")]
#[tokio::main]
async fn main() {
use std::path::PathBuf; use std::path::PathBuf;
use log::*; use log::*;
use patched_porobot::data::setbundle::card::{Card, CardIndex}; use patched_porobot::data::setbundle::card::{Card, CardIndex};
@ -21,6 +35,10 @@ async fn main() {
use teloxide::prelude::*; use teloxide::prelude::*;
use itertools::Itertools; use itertools::Itertools;
#[doc(hidden)]
#[tokio::main]
async fn main() {
pretty_env_logger::init(); pretty_env_logger::init();
debug!("Logger initialized successfully!"); debug!("Logger initialized successfully!");

View file

@ -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.

View file

@ -1,16 +1,32 @@
//! Crate providing parsing, indexing, and displaying utilities for Legends of Runeterra data files. //! 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 //! # Features
//! //!
//! - `search`: Adds a search engine based on [tantivy] for Legends of Runeterra data. //! [`patched_porobot`](self) supports conditional compilation via [Cargo features](https://doc.rust-lang.org/cargo/reference/features.html).
//! - `telegram`: Adds a [Telegram bot] based on [teloxide] to send Legends of Runeterra cards in chats. //!
//! 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 //! # 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. //! [`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
#![warn(missing_docs)] #![warn(missing_docs)]
#![doc(html_logo_url = "https://raw.githubusercontent.com/Steffo99/patched-porobot/main/icon.png")] #![doc(html_logo_url = "https://raw.githubusercontent.com/Steffo99/patched-porobot/main/icon.png")]
@ -25,3 +41,6 @@ pub mod telegram;
#[cfg(feature = "discord")] #[cfg(feature = "discord")]
pub mod discord; pub mod discord;
#[cfg(feature = "matrix")]
pub mod matrix;

4
src/matrix/mod.rs Normal file
View file

@ -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.

1
src/telegram/USAGE.md Normal file
View file

@ -0,0 +1 @@
# Test

View file

@ -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 display;
pub mod inline; pub mod inline;