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

Compare commits

..

1 commit

Author SHA1 Message Date
dependabot[bot]
56434357b6
Merge 57403b235a into 0c81b64030 2024-04-05 16:16:34 +00:00
15 changed files with 666 additions and 748 deletions

View file

@ -1 +0,0 @@
Patched Porobot

View file

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="PWA"> <component name="PWA">
<option name="wasEnabledAtLeastOnce" value="true" /> <option name="wasEnabledAtLeastOnce" value="true" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_22"> <component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

1260
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[package] [package]
name = "patched_porobot" name = "patched_porobot"
version = "1.0.1" version = "0.15.0"
authors = ["Stefano Pigozzi <me@steffo.eu>"] authors = ["Stefano Pigozzi <me@steffo.eu>"]
edition = "2021" edition = "2021"
description = "Legends of Runeterra card database utilities and bots" description = "Legends of Runeterra card database utilities and bots"
@ -46,6 +46,7 @@ rand = { version = "0.8.5", optional = true }
# discord # discord
serenity = { version = "0.11.5", features = ["client", "cache", "gateway", "rustls_backend", "model"], default-features = false, optional = true } serenity = { version = "0.11.5", features = ["client", "cache", "gateway", "rustls_backend", "model"], default-features = false, optional = true }
anyhow = { version = "^1.0.68", optional = true } anyhow = { version = "^1.0.68", optional = true }
# matrix
[dev-dependencies] [dev-dependencies]
@ -59,6 +60,7 @@ exec = ["pretty_env_logger"]
search = ["tantivy"] search = ["tantivy"]
telegram = ["exec", "search", "jpg", "teloxide", "tokio", "md5", "rand"] telegram = ["exec", "search", "jpg", "teloxide", "tokio", "md5", "rand"]
discord = ["exec", "search", "serenity", "tokio", "anyhow"] discord = ["exec", "search", "serenity", "tokio", "anyhow"]
matrix = ["exec", "search"]
[lib] [lib]
@ -71,3 +73,7 @@ required-features = ["telegram"]
[[bin]] [[bin]]
name = "patched_porobot_discord" name = "patched_porobot_discord"
required-features = ["discord"] required-features = ["discord"]
[[bin]]
name = "patched_porobot_matrix"
required-features = ["matrix"]

View file

@ -1,4 +1,4 @@
FROM --platform=${BUILDPLATFORM} rust:1.81-bookworm AS builder FROM --platform=${BUILDPLATFORM} rust:1.68-bullseye AS builder
ARG BUILDPLATFORM ARG BUILDPLATFORM
ARG TARGETPLATFORM ARG TARGETPLATFORM
@ -60,7 +60,7 @@ RUN \
############################################################################# #############################################################################
FROM --platform=${TARGETPLATFORM} rust:1.81-slim-bookworm AS final FROM --platform=${TARGETPLATFORM} rust:1.68-slim-bullseye AS final
WORKDIR /usr/src/patched_porobot/ WORKDIR /usr/src/patched_porobot/
COPY --from=builder \ COPY --from=builder \

View file

@ -1,18 +1,16 @@
<div align="center"> # ![](icon.png) Patched Porobot
![](icon.png)
# Patched Porobot
Legends of Runeterra game data crate and chat bots Legends of Runeterra game data crate and chat bots
</div>
## Links ## Links
[![Telegram Bot](https://img.shields.io/badge/telegram%20bot-done-success)](https://t.me/patchedporobot) [![Telegram Bot](https://img.shields.io/badge/telegram%20bot-done-success)](https://t.me/patchedporobot)
[![Discord Bot](https://img.shields.io/badge/discord%20bot-done-success)](https://discord.com/api/oauth2/authorize?client_id=1071989978743193672&scope=applications.commands) [![Discord Bot](https://img.shields.io/badge/discord%20bot-done-success)](https://discord.com/api/oauth2/authorize?client_id=1071989978743193672&scope=applications.commands)
![Matrix Bot](https://img.shields.io/badge/matrix%20bot-to%20do-inactive)
![Fediverse Bot](https://img.shields.io/badge/fediverse%20bot-to%20do-inactive)
[![Crates.io](https://img.shields.io/crates/v/patched_porobot)](https://crates.io/crates/patched_porobot) [![Crates.io](https://img.shields.io/crates/v/patched_porobot)](https://crates.io/crates/patched_porobot)

View file

@ -0,0 +1,7 @@
//! This bot isn't yet available.
#![doc(html_logo_url = "https://raw.githubusercontent.com/Steffo99/patched-porobot/main/icon.png")]
fn main() {
todo!();
}

View file

@ -118,8 +118,8 @@ mod tests {
}; };
} }
test_fetch!(test_fetch_5_9_0_en_us, "5_9_0", "en_us"); test_fetch!(test_fetch_4_9_0_en_us, "4_9_0", "en_us");
test_fetch!(test_fetch_5_9_0_it_it, "5_9_0", "it_it"); test_fetch!(test_fetch_4_9_0_it_it, "4_9_0", "it_it");
test_fetch!(test_fetch_latest_en_us, "latest", "en_us"); test_fetch!(test_fetch_latest_en_us, "latest", "en_us");
macro_rules! test_supported { macro_rules! test_supported {
@ -140,7 +140,7 @@ mod tests {
}; };
} }
test_supported!(test_supported_5_9_0_en_us, "5_9_0", "en_us"); test_supported!(test_supported_4_9_0_en_us, "4_9_0", "en_us");
test_supported!(test_supported_5_9_0_it_it, "5_9_0", "it_it"); test_supported!(test_supported_4_9_0_it_it, "4_9_0", "it_it");
test_supported!(test_supported_latest_en_us, "latest", "en_us"); test_supported!(test_supported_latest_en_us, "latest", "en_us");
} }

View file

@ -33,7 +33,6 @@ impl CardArt {
fn imgproxy_convert_to_jpg(url: &str) -> String { fn imgproxy_convert_to_jpg(url: &str) -> String {
use base64::Engine; use base64::Engine;
let url = url.replace("http:", "https:");
let url = base64::prelude::BASE64_URL_SAFE.encode(url); let url = base64::prelude::BASE64_URL_SAFE.encode(url);
let url = format!("/{url}.jpg"); let url = format!("/{url}.jpg");

View file

@ -220,11 +220,10 @@ pub enum CardKeyword {
Fated, Fated,
#[serde(alias = "BlocksElusive")] #[serde(alias = "BlocksElusive")]
#[serde(alias = "BlockElusive")] /// ???
/// Sharpsight.
/// ///
/// > Can block Elusive units. /// > Can block Elusive units.
Sharpsight, BlockElusive,
/// Fury. /// Fury.
/// ///
@ -333,11 +332,6 @@ pub enum CardKeyword {
/// > Can only be blocked by enemies with 3 or more Power. /// > Can only be blocked by enemies with 3 or more Power.
Fearsome, Fearsome,
/// Deathless.
///
/// > The next time this unit dies, remove Deathless and revive it Stunned with 1 Health.
Deathless,
/// Can't Block. /// Can't Block.
CantBlock, CantBlock,
@ -378,23 +372,6 @@ pub enum CardKeyword {
/// ??? /// ???
Freljord, Freljord,
/// > Activatable once per round. When activated, play the skill of the current Act at Focus speed, then transform me to the next Act.
#[serde(rename = "Story:Focus")]
StoryFocus,
/// > Activatable once per round. When activated, play the skill of the current Act at Slow speed, then transform me to the next Act.
#[serde(rename = "Story:Slow")]
StorySlow,
/// > Applies a negative effect as long as it's in hand. Multiples of the same curse on a unit combine, increasing their cost and effect. Cannot be targeted in hand.
Curse,
/// This unit has +1|+1. This keyword can stack.
Spirit,
/// > This unit has -1|-1. This keyword can stack.
Gloom,
/// Unsupported card keyword. /// Unsupported card keyword.
#[serde(other)] #[serde(other)]
Unsupported, Unsupported,
@ -487,18 +464,12 @@ impl CardKeyword {
CardKeyword::Nightfall => "", CardKeyword::Nightfall => "",
CardKeyword::Daybreak => "", CardKeyword::Daybreak => "",
CardKeyword::Plunder => "", CardKeyword::Plunder => "",
CardKeyword::Sharpsight => "", CardKeyword::BlockElusive => "",
CardKeyword::Flow => "", CardKeyword::Flow => "",
CardKeyword::Capture => "<:capture:1056024295190577153>", CardKeyword::Capture => "<:capture:1056024295190577153>",
CardKeyword::Attack => "", CardKeyword::Attack => "",
CardKeyword::ElementalSkill => "<:elementalskill:1165762476974026814>", CardKeyword::ElementalSkill => "<:elementalskill:1165762476974026814>",
CardKeyword::LevelUp => "", CardKeyword::LevelUp => "",
CardKeyword::StoryFocus => "", // TODO
CardKeyword::StorySlow => "", // TODO
CardKeyword::Spirit => "", // TODO
CardKeyword::Gloom => "", // TODO
CardKeyword::Curse => "", // TODO
CardKeyword::Deathless => "", // TODO
CardKeyword::Freljord => "<:freljord:1056024331437735936>", CardKeyword::Freljord => "<:freljord:1056024331437735936>",
CardKeyword::Unsupported => "<:invaliddeck:1056022952396730438>", CardKeyword::Unsupported => "<:invaliddeck:1056022952396730438>",
} }
@ -567,9 +538,8 @@ mod tests {
test_deserialization!(deserialize_elusive, r#""Elusive""#, CardKeyword::Elusive); test_deserialization!(deserialize_elusive, r#""Elusive""#, CardKeyword::Elusive);
test_deserialization!(deserialize_stun, r#""Stun""#, CardKeyword::Stun); test_deserialization!(deserialize_stun, r#""Stun""#, CardKeyword::Stun);
test_deserialization!(deserialize_fated, r#""Fated""#, CardKeyword::Fated); test_deserialization!(deserialize_fated, r#""Fated""#, CardKeyword::Fated);
test_deserialization!(deserialize_blockelusive, r#""BlockElusive""#, CardKeyword::Sharpsight); test_deserialization!(deserialize_blockelusive, r#""BlockElusive""#, CardKeyword::BlockElusive);
test_deserialization!(deserialize_blockelusive2, r#""BlocksElusive""#, CardKeyword::Sharpsight); test_deserialization!(deserialize_blockelusive2, r#""BlocksElusive""#, CardKeyword::BlockElusive);
test_deserialization!(deserialize_sharpsight, r#""Sharpsight""#, CardKeyword::Sharpsight);
test_deserialization!(deserialize_fury, r#""Fury""#, CardKeyword::Fury); test_deserialization!(deserialize_fury, r#""Fury""#, CardKeyword::Fury);
test_deserialization!(deserialize_barrier, r#""Barrier""#, CardKeyword::Barrier); test_deserialization!(deserialize_barrier, r#""Barrier""#, CardKeyword::Barrier);
test_deserialization!(deserialize_immobile, r#""Immobile""#, CardKeyword::Immobile); test_deserialization!(deserialize_immobile, r#""Immobile""#, CardKeyword::Immobile);
@ -600,11 +570,5 @@ mod tests {
test_deserialization!(deserialize_elementalskill, r#""ElementalSkill""#, CardKeyword::ElementalSkill); test_deserialization!(deserialize_elementalskill, r#""ElementalSkill""#, CardKeyword::ElementalSkill);
test_deserialization!(deserialize_levelup, r#""LevelUp""#, CardKeyword::LevelUp); test_deserialization!(deserialize_levelup, r#""LevelUp""#, CardKeyword::LevelUp);
test_deserialization!(deserialize_freljord, r#""Freljord""#, CardKeyword::Freljord); test_deserialization!(deserialize_freljord, r#""Freljord""#, CardKeyword::Freljord);
test_deserialization!(deserialize_curse, r#""Curse""#, CardKeyword::Curse);
test_deserialization!(deserialize_spirit, r#""Spirit""#, CardKeyword::Spirit);
test_deserialization!(deserialize_gloom, r#""Gloom""#, CardKeyword::Gloom);
test_deserialization!(deserialize_deathless, r#""Deathless""#, CardKeyword::Deathless);
test_deserialization!(deserialize_storyslow, r#""Story:Slow""#, CardKeyword::StorySlow);
test_deserialization!(deserialize_storyfocus, r#""Story:Focus""#, CardKeyword::StoryFocus);
test_deserialization!(deserialize_unsupported, r#""Xyzzy""#, CardKeyword::Unsupported); test_deserialization!(deserialize_unsupported, r#""Xyzzy""#, CardKeyword::Unsupported);
} }

View file

@ -96,29 +96,27 @@ mod tests {
}; };
} }
test_fetch!(test_fetch_5_9_0_en_us_set1, "5_9_0", "en_us", "set1"); test_fetch!(test_fetch_4_9_0_en_us_set1, "4_9_0", "en_us", "set1");
test_fetch!(test_fetch_5_9_0_en_us_set2, "5_9_0", "en_us", "set2"); test_fetch!(test_fetch_4_9_0_en_us_set2, "4_9_0", "en_us", "set2");
test_fetch!(test_fetch_5_9_0_en_us_set3, "5_9_0", "en_us", "set3"); test_fetch!(test_fetch_4_9_0_en_us_set3, "4_9_0", "en_us", "set3");
test_fetch!(test_fetch_5_9_0_en_us_set4, "5_9_0", "en_us", "set4"); test_fetch!(test_fetch_4_9_0_en_us_set4, "4_9_0", "en_us", "set4");
test_fetch!(test_fetch_5_9_0_en_us_set5, "5_9_0", "en_us", "set5"); test_fetch!(test_fetch_4_9_0_en_us_set5, "4_9_0", "en_us", "set5");
test_fetch!(test_fetch_5_9_0_en_us_set6, "5_9_0", "en_us", "set6"); test_fetch!(test_fetch_4_9_0_en_us_set6, "4_9_0", "en_us", "set6");
test_fetch!(test_fetch_5_9_0_en_us_set6cde, "5_9_0", "en_us", "set6cde"); test_fetch!(test_fetch_4_9_0_en_us_set6cde, "4_9_0", "en_us", "set6cde");
test_fetch!(test_fetch_5_9_0_en_us_set7, "5_9_0", "en_us", "set7"); test_fetch!(test_fetch_4_9_0_en_us_set7, "4_9_0", "en_us", "set7");
test_fetch!(test_fetch_5_9_0_en_us_set7b, "5_9_0", "en_us", "set7b"); test_fetch!(test_fetch_4_9_0_en_us_set7b, "4_9_0", "en_us", "set7b");
test_fetch!(test_fetch_5_9_0_en_us_set8, "5_9_0", "en_us", "set8"); test_fetch!(test_fetch_4_9_0_en_us_set8, "4_9_0", "en_us", "set8");
test_fetch!(test_fetch_5_9_0_en_us_set9, "5_9_0", "en_us", "set9");
test_fetch!(test_fetch_5_9_0_it_it_set1, "5_9_0", "it_it", "set1"); test_fetch!(test_fetch_4_9_0_it_it_set1, "4_9_0", "it_it", "set1");
test_fetch!(test_fetch_5_9_0_it_it_set2, "5_9_0", "it_it", "set2"); test_fetch!(test_fetch_4_9_0_it_it_set2, "4_9_0", "it_it", "set2");
test_fetch!(test_fetch_5_9_0_it_it_set3, "5_9_0", "it_it", "set3"); test_fetch!(test_fetch_4_9_0_it_it_set3, "4_9_0", "it_it", "set3");
test_fetch!(test_fetch_5_9_0_it_it_set4, "5_9_0", "it_it", "set4"); test_fetch!(test_fetch_4_9_0_it_it_set4, "4_9_0", "it_it", "set4");
test_fetch!(test_fetch_5_9_0_it_it_set5, "5_9_0", "it_it", "set5"); test_fetch!(test_fetch_4_9_0_it_it_set5, "4_9_0", "it_it", "set5");
test_fetch!(test_fetch_5_9_0_it_it_set6, "5_9_0", "it_it", "set6"); test_fetch!(test_fetch_4_9_0_it_it_set6, "4_9_0", "it_it", "set6");
test_fetch!(test_fetch_5_9_0_it_it_set6cde, "5_9_0", "it_it", "set6cde"); test_fetch!(test_fetch_4_9_0_it_it_set6cde, "4_9_0", "it_it", "set6cde");
test_fetch!(test_fetch_5_9_0_it_it_set7, "5_9_0", "it_it", "set7"); test_fetch!(test_fetch_4_9_0_it_it_set7, "4_9_0", "it_it", "set7");
test_fetch!(test_fetch_5_9_0_it_it_set7b, "5_9_0", "it_it", "set7b"); test_fetch!(test_fetch_4_9_0_it_it_set7b, "4_9_0", "it_it", "set7b");
test_fetch!(test_fetch_5_9_0_it_it_set8, "5_9_0", "it_it", "set8"); test_fetch!(test_fetch_4_9_0_it_it_set8, "4_9_0", "it_it", "set8");
test_fetch!(test_fetch_5_9_0_it_it_set9, "5_9_0", "it_it", "set9");
test_fetch!(test_fetch_latest_en_us_set1, "latest", "en_us", "set1"); test_fetch!(test_fetch_latest_en_us_set1, "latest", "en_us", "set1");
test_fetch!(test_fetch_latest_en_us_set2, "latest", "en_us", "set2"); test_fetch!(test_fetch_latest_en_us_set2, "latest", "en_us", "set2");
@ -130,7 +128,6 @@ mod tests {
test_fetch!(test_fetch_latest_en_us_set7, "latest", "en_us", "set7"); test_fetch!(test_fetch_latest_en_us_set7, "latest", "en_us", "set7");
test_fetch!(test_fetch_latest_en_us_set7b, "latest", "en_us", "set7b"); test_fetch!(test_fetch_latest_en_us_set7b, "latest", "en_us", "set7b");
test_fetch!(test_fetch_latest_en_us_set8, "latest", "en_us", "set8"); test_fetch!(test_fetch_latest_en_us_set8, "latest", "en_us", "set8");
test_fetch!(test_fetch_latest_en_us_set9, "latest", "en_us", "set9");
} }

View file

@ -52,8 +52,7 @@ pub enum CardRegion {
Evelynn, Evelynn,
/// Runeterra: Bard. /// Runeterra: Bard.
Bard, Bard,
/// Runeterra: Elder Dragon.
ElderDragon,
/// Unsupported region. /// Unsupported region.
#[serde(other)] #[serde(other)]
@ -161,7 +160,6 @@ impl CardRegion {
CardRegion::PoroKing => "", CardRegion::PoroKing => "",
CardRegion::Evelynn => "", CardRegion::Evelynn => "",
CardRegion::Bard => "", CardRegion::Bard => "",
CardRegion::ElderDragon => "",
CardRegion::Unsupported => "<:invaliddeck:1056022952396730438>", CardRegion::Unsupported => "<:invaliddeck:1056022952396730438>",
} }
} }

View file

@ -48,10 +48,6 @@ pub enum CardSet {
#[serde(rename = "Set8")] #[serde(rename = "Set8")]
FatesVoyage, FatesVoyage,
/// Dreamlit Paths.
#[serde(rename = "Set9")]
DreamlitPaths,
/// Events, cards released "outside" a set. /// Events, cards released "outside" a set.
#[serde(rename = "SetEvent")] #[serde(rename = "SetEvent")]
Events, Events,
@ -120,8 +116,7 @@ impl CardSet {
CardSet::GloryInNavori => "<:glory_in_navori:1095363395890458756>", CardSet::GloryInNavori => "<:glory_in_navori:1095363395890458756>",
CardSet::HeartOfTheHuntress => "<:heart_of_the_huntress:1165769749922320494>", CardSet::HeartOfTheHuntress => "<:heart_of_the_huntress:1165769749922320494>",
CardSet::FatesVoyage => "<:fates_voyage:1165769932995317851>", CardSet::FatesVoyage => "<:fates_voyage:1165769932995317851>",
CardSet::DreamlitPaths => "", // TODO CardSet::Events => "",
CardSet::Events => "", // TODO
CardSet::Unsupported => "<:invaliddeck:1056022952396730438>", CardSet::Unsupported => "<:invaliddeck:1056022952396730438>",
} }
} }

View file

@ -8,6 +8,7 @@
//! //!
//! - [Usage of the Telegram bot](../patched_porobot_telegram/index.html) //! - [Usage of the Telegram bot](../patched_porobot_telegram/index.html)
//! - [Usage of the Discord bot](../patched_porobot_discord/index.html) //! - [Usage of the Discord bot](../patched_porobot_discord/index.html)
//! - ~~[Usage of the Matrix bot](../patched_porobot_matrix/index.html)~~
//! //!
//! # Features //! # Features
//! //!
@ -21,6 +22,7 @@
//! //!
//! - [`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; //! - [`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; //! - [`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
//! //!
@ -39,3 +41,6 @@ pub mod telegram;
#[cfg(feature = "discord")] #[cfg(feature = "discord")]
pub mod discord; pub mod discord;
#[cfg(feature = "matrix")]
pub mod matrix;

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

@ -0,0 +1,3 @@
//! 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.