base project

This commit is contained in:
Hamcha 2023-07-24 14:37:30 +02:00
commit 7929eeed7d
Signed by: hamcha
GPG Key ID: 1669C533B8CF6D89
7 changed files with 3305 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
.env

1966
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

20
Cargo.toml Normal file
View File

@ -0,0 +1,20 @@
[package]
name = "clessy-rs"
version = "0.1.0"
edition = "2021"
[dependencies]
teloxide = { version = "0.12", features = [
"macros",
"rustls",
"throttle",
"cache-me",
"webhooks",
"webhooks-axum",
] }
tracing = "0.1"
tracing-subscriber = "0.3"
tokio = { version = "1.28", features = ["rt-multi-thread"] }
dotenvy = "0.15"
anyhow = "1"
fastrand = "2"

118
src/commands/metafora.rs Normal file
View File

@ -0,0 +1,118 @@
pub fn generate() -> String {
let n = fastrand::usize(..META_ACTIONS.len());
let m = fastrand::usize(..META_OBJECTS.len());
format!("{} {}", META_ACTIONS[n], META_OBJECTS[m])
}
const META_ACTIONS: [&str; 51] = [
"Puppami",
"Degustami",
"Lucidami",
"Manipolami",
"Disidratami",
"Irritami",
"Martorizzami",
"Lustrami",
"Osannami",
"Sorseggiami",
"Assaporami",
"Apostrofami",
"Spremimi",
"Dimenami",
"Agitami",
"Stimolami",
"Suonami",
"Strimpellami",
"Stuzzicami",
"Spintonami",
"Sguinzagliami",
"Modellami",
"Sgrullami",
"Cavalcami",
"Perquotimi",
"Misurami",
"Sventolami",
"Induriscimi",
"Accordami",
"Debuggami",
"Accarezzami",
"Revisionami",
"Imbottigliami",
"Badami",
"Scuotimi",
"Terremotami",
"Incentivami",
"Sollecitami",
"Allenami",
"Censiscimi",
"Decollami",
"Smagnetizzami",
"Nobilitami",
"Elevami",
"Accrescimi",
"Impostami",
"Ereggimi",
"Fischiettami",
"Scaldami",
"Gonfiami",
"Lubrificami",
];
const META_OBJECTS: [&str; 56] = [
"il birillo",
"il bastone",
"l'ombrello",
"il malloppo",
"il manico",
"il manganello",
"il ferro",
"la mazza",
"l'archibugio",
"il timone",
"l'arpione",
"il flauto",
"la reliquia",
"il fioretto",
"lo scettro",
"il campanile",
"la proboscide",
"il pino",
"il maritozzo",
"il perno",
"il tubo da 100",
"la verga",
"l'idrante",
"il pendolo",
"la torre di Pisa",
"la lancia",
"il cilindro",
"il lampione",
"il joystick",
"il Wiimote",
"il PSMove",
"l'albero maestro",
"il trenino",
"la sciabola",
"il weedle",
"il serpente",
"il missile",
"la limousine",
"il selfie-stick",
"il candelotto",
"la falce",
"la biscia",
"la banana",
"la pannocchia",
"il papavero",
"la carota",
"la fava",
"la salsiccia",
"il cono",
"l'hard drive",
"la manopola",
"la manovella",
"il pennello",
"l'asta",
"il cacciavite",
"lo spazzolino",
];

2
src/commands/mod.rs Normal file
View File

@ -0,0 +1,2 @@
pub mod metafora;
pub mod proverbio;

1155
src/commands/proverbio.rs Normal file

File diff suppressed because it is too large Load Diff

42
src/main.rs Normal file
View File

@ -0,0 +1,42 @@
use anyhow::Result;
use commands::{metafora, proverbio};
use teloxide::{prelude::*, utils::command::BotCommands};
mod commands;
#[tokio::main]
async fn main() -> Result<()> {
dotenvy::dotenv()?;
tracing_subscriber::fmt::init();
let bot = Bot::from_env();
Command::repl(bot, answer).await;
Ok(())
}
#[derive(BotCommands, Clone)]
#[command(rename_rule = "lowercase", description = "Comandi del bot:")]
enum Command {
#[command(description = "mostra questo testo")]
Help,
#[command(description = "genera metafora")]
Metafora,
#[command(description = "genera proverbio")]
Proverbio,
}
async fn answer(bot: Bot, msg: Message, cmd: Command) -> ResponseResult<()> {
match cmd {
Command::Help => {
bot.send_message(msg.chat.id, Command::descriptions().to_string())
.await?
}
Command::Metafora => bot.send_message(msg.chat.id, metafora::generate()).await?,
Command::Proverbio => bot.send_message(msg.chat.id, proverbio::generate()).await?,
};
Ok(())
}