diff --git a/src/bin/patched_porobot_telegram.rs b/src/bin/patched_porobot_telegram.rs index 84259c3..e923d1d 100644 --- a/src/bin/patched_porobot_telegram.rs +++ b/src/bin/patched_porobot_telegram.rs @@ -6,18 +6,71 @@ //! //! [@patchedporobot] is a inline bot: this means that you can use it everywhere, without having to add it to chats. //! +//! ### Basic queries +//! //! 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 //! ``` +//! +//! You can specify multiple words to find cards that contain all of them: +//! //! ```text -//! @patchedporobot poro -//! ``` -//! ```text -//! @patchedporobot noxus +//! @patchedporobot mighty poro //! ``` //! +//! Terms will be searched in multiple fields, so to find [Daring Poro](https://leagueoflegends.fandom.com/wiki/Daring_Poro_(Legends_of_Runeterra)) you may search for: //! +//! ```text +//! @patchedporobot piltover poro +//! ``` +//! +//! ### Conjunctions +//! +//! By default, all terms in the query are joined by `AND` conjuctions, meaning that only cards containing **all** of the terms are retrieved. +//! +//! If you want to find cards matching **any** of the terms, you'll have to manually join them with the `OR` conjuction: +//! +//! ```text +//! @patchedporobot progress OR heimerdinger +//! ``` +//! +//! To have both `AND`s and `OR`s in the same query you'll need to specify all of them explicitly: +//! +//! ```text +//! @patchedporobot von AND yipp OR cat +//! ``` +//! +//! ### Fields +//! +//! You can perform searches about specific card properties: +//! +//! ```text +//! @patchedporobot cost:4 attack:7 health:7 +//! ``` +//! +//! Conjunctions are supported even when searching by specific fields: +//! +//! ```text +//! @patchedporobot name:Bard OR description:Chime +//! ``` +//! +//! #### Supported fields +//! +//! [@patchedporobot] supports the various fields for searching cards: see [**this table**](patched_porobot::search::cardsearch::CardSearchEngine::schema) for a list of all of them! +//! +//! ### Ranges +//! +//! Finally, you can request specific ranges for your search using square brackets and the `TO` keyword: +//! +//! ```text +//! @patchedporobot attack:[8 TO 12] +//! ``` +//! +//! ### Query parser +//! +//! Since [@patchedporobot] uses [`tantivy`] internally, you might find more information on even more advanced queries in the [documentation of their `QueryParser`](tantivy::query::QueryParser)! //! //! //! [@patchedporobot]: https://t.me/patchedporobot diff --git a/src/search/cardsearch.rs b/src/search/cardsearch.rs index 0198863..f4f20c1 100644 --- a/src/search/cardsearch.rs +++ b/src/search/cardsearch.rs @@ -107,24 +107,24 @@ impl CardSearchEngine { /// /// It will contain [Field]s with the following names: /// - /// | Name | Type | - /// |---------------|----------------------------------| - /// | `code` | [code](Self::options_code) | - /// | `name` | [text](Self::options_text) | - /// | `type` | [keyword](Self::options_keyword) | - /// | `set` | [keyword](Self::options_keyword) | - /// | `rarity` | [keyword](Self::options_keyword) | - /// | `collectible` | [number](Self::options_number) | - /// | `regions` | [keyword](Self::options_keyword) | - /// | `attack` | [number](Self::options_number) | - /// | `cost` | [number](Self::options_number) | - /// | `health` | [number](Self::options_number) | - /// | `spellspeed` | [keyword](Self::options_keyword) | - /// | `keywords` | [keyword](Self::options_keyword) | - /// | `description` | [text](Self::options_text) | - /// | `levelup` | [text](Self::options_text) | - /// | `flavor` | [text](Self::options_text) | - /// | `artist` | [text](Self::options_text) | + /// | Name | Type | Description | + /// |---------------|----------------------------------|-------------| + /// | `code` | [code](Self::options_code) | The internal [card code](Card::code), such as `01IO012`. | + /// | `name` | [text](Self::options_text) | The [name of the card](Card::name). | + /// | `type` | [keyword](Self::options_keyword) | The [type of the card](Card::type), such as `Unit`. | + /// | `set` | [keyword](Self::options_keyword) | The [set the card belongs to](Card::set), such as `Beyond the Bandlewood`. | + /// | `rarity` | [keyword](Self::options_keyword) | The [rarity of the card](patched_porobot::data::setbundle::card::Card::rarity), such as `Rare`, or `Champion`. | + /// | `collectible` | [number](Self::options_number) | `1` if the [card is collectible](Card::collectible), `0` otherwise. | + /// | `regions` | [keyword](Self::options_keyword) | The [regions of the card](Card::regions), separated by spaces. | + /// | `attack` | [number](Self::options_number) | The [attack of the unit](Card::attack); always `0` for non-units. | + /// | `cost` | [number](Self::options_number) | The [mana cost of the card](Card::cost); always `0` for non-playable cards. | + /// | `health` | [number](Self::options_number) | The [health of the unit](Card::health); always `0` for non-units. | + /// | `spellspeed` | [keyword](Self::options_keyword) | The [speed of the spell](Card::spell_speed), or an empty string for non-spells. Note that [`Focus`](crate::data::setbundle::keyword::CardKeyword::Focus) is a keyword, and not a spell speed. | + /// | `keywords` | [keyword](Self::options_keyword) | The [keywords of the card](Card::keywords), separated by spaces. | + /// | `description` | [text](Self::options_text) | The [description of the card](Card::localized_description_text). | + /// | `levelup` | [text](Self::options_text) | The [level up text of the champion](Card::localized_levelup_text). | + /// | `flavor` | [text](Self::options_text) | The [flavor text of the card](Card::localized_flavor_text). | + /// | `artist` | [text](Self::options_text) | The [artist(s) of the card's illustration](Card::artist_name). | /// /// Use [Self::schema_fields] to create the [CardSchemaFields] object containing all of them. /// diff --git a/src/telegram/USAGE.md b/src/telegram/USAGE.md deleted file mode 100644 index 8ae0569..0000000 --- a/src/telegram/USAGE.md +++ /dev/null @@ -1 +0,0 @@ -# Test