1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2025-02-16 18:33:58 +00:00

Run "Reformat code..." IDE feature

This commit is contained in:
Steffo 2024-08-19 07:54:41 +02:00
parent b84b70080f
commit ec3f5daff7
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
34 changed files with 67626 additions and 67621 deletions

View file

@ -51,7 +51,7 @@ impl RoyalnetInstance {
fn run_pending_migrations() { fn run_pending_migrations() {
if !config::interface_database::DATABASE_AUTOMIGRATE() { if !config::interface_database::DATABASE_AUTOMIGRATE() {
log::warn!("Database automigration is disabled."); log::warn!("Database automigration is disabled.");
return return;
} }
log::debug!("Automatically applying database migrations..."); log::debug!("Automatically applying database migrations...");
@ -90,13 +90,13 @@ impl RoyalnetInstance {
} }
#[cfg(feature = "service_telegram")] #[cfg(feature = "service_telegram")]
fn get_telegram_future(service: &mut crate::services::telegram::TelegramService) -> impl Future<Output = ()> + '_ { fn get_telegram_future(service: &mut crate::services::telegram::TelegramService) -> impl Future<Output=()> + '_ {
service.run_loop() service.run_loop()
} }
#[cfg(not(feature = "service_telegram"))] #[cfg(not(feature = "service_telegram"))]
#[allow(clippy::manual_async_fn)] #[allow(clippy::manual_async_fn)]
fn get_telegram_future(_service: &mut ()) -> impl Future<Output = ()> + '_ { fn get_telegram_future(_service: &mut ()) -> impl Future<Output=()> + '_ {
async {} async {}
} }
@ -122,13 +122,13 @@ impl RoyalnetInstance {
} }
#[cfg(feature = "service_brooch")] #[cfg(feature = "service_brooch")]
fn get_brooch_future(service: &mut crate::services::brooch::BroochService) -> impl Future<Output = ()> + '_ { fn get_brooch_future(service: &mut crate::services::brooch::BroochService) -> impl Future<Output=()> + '_ {
service.run_loop() service.run_loop()
} }
#[cfg(not(feature = "service_brooch"))] #[cfg(not(feature = "service_brooch"))]
#[allow(clippy::manual_async_fn)] #[allow(clippy::manual_async_fn)]
fn get_brooch_future(_service: &mut ()) -> impl Future<Output = ()> + '_ { fn get_brooch_future(_service: &mut ()) -> impl Future<Output=()> + '_ {
async {} async {}
} }
} }

View file

@ -63,7 +63,7 @@ pub(crate) mod telegram_ext {
text, text,
teloxide::types::InlineKeyboardButtonKind::CallbackData( teloxide::types::InlineKeyboardButtonKind::CallbackData(
self.callback_data(matchmaking_id) self.callback_data(matchmaking_id)
) ),
) )
} }
} }
@ -355,7 +355,7 @@ pub(crate) mod telegram_ext {
pub async fn destroy_and_send_delete( pub async fn destroy_and_send_delete(
self, self,
database: &mut PgConnection, database: &mut PgConnection,
bot: &teloxide::Bot bot: &teloxide::Bot,
) )
-> AnyResult<()> -> AnyResult<()>
{ {

View file

@ -1,9 +1,9 @@
// @generated automatically by Diesel CLI. // @generated automatically by Diesel CLI.
pub mod sql_types { pub mod sql_types {
#[derive(diesel::query_builder::QueryId, Clone, diesel::sql_types::SqlType)] #[derive(diesel::query_builder::QueryId, Clone, diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "matchmaking_choice"))] #[diesel(postgres_type(name = "matchmaking_choice"))]
pub struct MatchmakingChoice; pub struct MatchmakingChoice;
} }
diesel::table! { diesel::table! {

View file

@ -1,37 +1,37 @@
query Query($guild_id: Int!) { query Query($guild_id: Int!) {
guild(id: $guild_id) { guild(id: $guild_id) {
id id
matches(take: 10) { matches(take: 10) {
id id
lobbyType lobbyType
gameMode gameMode
durationSeconds durationSeconds
endDateTime endDateTime
players(steamAccountId: null) { players(steamAccountId: null) {
isRadiant isRadiant
isVictory isVictory
imp imp
kills kills
deaths deaths
assists assists
lane lane
role role
hero { hero {
displayName displayName
} }
steamAccount { steamAccount {
id id
name name
} }
stats { stats {
matchPlayerBuffEvent { matchPlayerBuffEvent {
time time
itemId itemId
abilityId abilityId
stackCount stackCount
} }
} }
} }
} }
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -7,15 +7,15 @@ pub(crate) mod utils;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
// Logging setup // Logging setup
pretty_env_logger::init(); pretty_env_logger::init();
log::debug!("Logging initialized successfully!"); log::debug!("Logging initialized successfully!");
// Create instance // Create instance
let instance = RoyalnetInstance::new().await; let instance = RoyalnetInstance::new().await;
log::trace!("Starting {instance:?}!"); log::trace!("Starting {instance:?}!");
instance.run().await; instance.run().await;
log::error!("No services configured."); log::error!("No services configured.");
} }

View file

@ -40,7 +40,7 @@ impl BroochService {
min_players_to_process: usize, min_players_to_process: usize,
telegram_bot_token: String, telegram_bot_token: String,
notification_chat_id: ChatId, notification_chat_id: ChatId,
max_imp_wait: TimeDelta max_imp_wait: TimeDelta,
) )
-> AnyResult<Self> -> AnyResult<Self>
{ {
@ -352,21 +352,21 @@ impl BroochService {
side = match (side, player.is_radiant) { side = match (side, player.is_radiant) {
(_, None) => { (_, None) => {
anyhow::bail!("Non è stata ricevuta da STRATZ la squadra di almeno uno dei giocatori.") anyhow::bail!("Non è stata ricevuta da STRATZ la squadra di almeno uno dei giocatori.")
}, }
(None, Some(true)) => { (None, Some(true)) => {
Some(Radiant) Some(Radiant)
}, }
(None, Some(false)) => { (None, Some(false)) => {
Some(Dire) Some(Dire)
}, }
(Some(Radiant), Some(true)) | (Some(Radiant), Some(true)) |
(Some(Dire), Some(false)) => { (Some(Dire), Some(false)) => {
side side
}, }
(Some(Radiant), Some(false)) | (Some(Radiant), Some(false)) |
(Some(Dire), Some(true)) => { (Some(Dire), Some(true)) => {
Some(Both) Some(Both)
}, }
(Some(Both), _) => { (Some(Both), _) => {
break break
} }
@ -391,21 +391,21 @@ impl BroochService {
outcome = match (outcome, player.is_victory) { outcome = match (outcome, player.is_victory) {
(_, None) => { (_, None) => {
anyhow::bail!("Non è stata ricevuta da STRATZ la squadra di almeno uno dei giocatori.") anyhow::bail!("Non è stata ricevuta da STRATZ la squadra di almeno uno dei giocatori.")
}, }
(None, Some(true)) => { (None, Some(true)) => {
Some(Victory) Some(Victory)
}, }
(None, Some(false)) => { (None, Some(false)) => {
Some(Defeat) Some(Defeat)
}, }
(Some(Victory), Some(true)) | (Some(Victory), Some(true)) |
(Some(Defeat), Some(false)) => { (Some(Defeat), Some(false)) => {
outcome outcome
}, }
(Some(Victory), Some(false)) | (Some(Victory), Some(false)) |
(Some(Defeat), Some(true)) => { (Some(Defeat), Some(true)) => {
Some(Clash) Some(Clash)
}, }
(Some(Clash), _) => { (Some(Clash), _) => {
break break
} }
@ -534,14 +534,14 @@ impl BroochService {
use Lane::*; use Lane::*;
match (role, lane) { match (role, lane) {
( Some(CORE), Some(SAFE_LANE)) => 1, (Some(CORE), Some(SAFE_LANE)) => 1,
( Some(CORE), Some(MID_LANE)) => 2, (Some(CORE), Some(MID_LANE)) => 2,
( Some(CORE), Some(OFF_LANE)) => 3, (Some(CORE), Some(OFF_LANE)) => 3,
( _, Some(ROAMING)) => 4, (_, Some(ROAMING)) => 4,
( _, Some(JUNGLE)) => 5, (_, Some(JUNGLE)) => 5,
(Some(LIGHT_SUPPORT), _) => 6, (Some(LIGHT_SUPPORT), _) => 6,
( Some(HARD_SUPPORT), _) => 7, (Some(HARD_SUPPORT), _) => 7,
( _, _) => 8, (_, _) => 8,
} }
} }
@ -552,14 +552,14 @@ impl BroochService {
log::trace!("Stringifying role and lane..."); log::trace!("Stringifying role and lane...");
match (role, lane) { match (role, lane) {
( CORE, SAFE_LANE) => "1⃣ Safe Carry", (CORE, SAFE_LANE) => "1⃣ Safe Carry",
( CORE, MID_LANE) => "2⃣ Mid Carry", (CORE, MID_LANE) => "2⃣ Mid Carry",
( CORE, OFF_LANE) => "3⃣ Off Tank", (CORE, OFF_LANE) => "3⃣ Off Tank",
( _, ROAMING) => "🔀 Roaming", (_, ROAMING) => "🔀 Roaming",
( _, JUNGLE) => "⏫ Jungle", (_, JUNGLE) => "⏫ Jungle",
(LIGHT_SUPPORT, _) => "4⃣ Soft Support", (LIGHT_SUPPORT, _) => "4⃣ Soft Support",
( HARD_SUPPORT, _) => "5⃣ Hard Support", (HARD_SUPPORT, _) => "5⃣ Hard Support",
( _, _) => "🆕 Sconosciuto", (_, _) => "🆕 Sconosciuto",
} }
} }
@ -661,7 +661,7 @@ impl BroochService {
if !self.should_process_match_exists(database, match_id)? { if !self.should_process_match_exists(database, match_id)? {
log::trace!("Skipping match, already parsed."); log::trace!("Skipping match, already parsed.");
return Ok((match_id, None)) return Ok((match_id, None));
} }
let datetime = self.get_match_datetime(&r#match)?; let datetime = self.get_match_datetime(&r#match)?;
@ -675,12 +675,12 @@ impl BroochService {
if !self.should_process_match_players(&players) { if !self.should_process_match_players(&players) {
log::trace!("Skipping match, not enough players."); log::trace!("Skipping match, not enough players.");
return Ok((match_id, None)) return Ok((match_id, None));
} }
if !self.should_process_match_imp(&players, &timedelta) { if !self.should_process_match_imp(&players, &timedelta) {
log::trace!("Skipping match, IMP is not ready."); log::trace!("Skipping match, IMP is not ready.");
return Ok((match_id, None)) return Ok((match_id, None));
} }
players.sort_unstable_by_key(|a| Self::numberify_role_lane(&a.role, &a.lane)); players.sort_unstable_by_key(|a| Self::numberify_role_lane(&a.role, &a.lane));

View file

@ -17,10 +17,10 @@ pub trait RoyalnetService {
match result { match result {
Err(e) => { Err(e) => {
log::error!("Service exited with error: {e:?}.") log::error!("Service exited with error: {e:?}.")
}, }
_ => { _ => {
log::debug!("Service exited successfully!") log::debug!("Service exited successfully!")
}, }
} }
let backoff_secs = backoff.as_secs(); let backoff_secs = backoff.as_secs();

View file

@ -12,70 +12,70 @@ use crate::services::telegram::commands::CommandResult;
// Se avete un'idea ma metterebbe troppe opzioni in un'unica categoria, mettetela sotto commento. // Se avete un'idea ma metterebbe troppe opzioni in un'unica categoria, mettetela sotto commento.
const ANSWERS: [&str; 60] = [ const ANSWERS: [&str; 60] = [
// risposte "sì": 20 // risposte "sì": 20
"🔵 Sì.", "🔵 Sì.",
"🔵 Decisamente sì!", "🔵 Decisamente sì!",
"🔵 Uhm, secondo me sì.", "🔵 Uhm, secondo me sì.",
"🔵 Sì! Sì! SÌ!", "🔵 Sì! Sì! SÌ!",
"🔵 Yup.", "🔵 Yup.",
"🔵 Direi proprio di sì.", "🔵 Direi proprio di sì.",
"🔵 Assolutamente sì.", "🔵 Assolutamente sì.",
"🔵 Ma certo!", "🔵 Ma certo!",
"🔵 Esatto!", "🔵 Esatto!",
"🔵 Senz'altro!", "🔵 Senz'altro!",
"🔵 Ovviamente.", "🔵 Ovviamente.",
"🔵 Questa domanda ha risposta affermativa.", "🔵 Questa domanda ha risposta affermativa.",
"🔵 Hell yeah.", "🔵 Hell yeah.",
"🔵 YES! YES! YES!", "🔵 YES! YES! YES!",
"🔵 yusssssss", "🔵 yusssssss",
"🔵 Non vedo perchè no", "🔵 Non vedo perchè no",
"🔵 Ha senso, ha perfettamente senso, nulla da obiettare, ha senso.", "🔵 Ha senso, ha perfettamente senso, nulla da obiettare, ha senso.",
"🔵 Yos!", "🔵 Yos!",
"🔵 Sì, ma tienilo segreto...", "🔵 Sì, ma tienilo segreto...",
"🔵 [RADIO] Affermativo.", "🔵 [RADIO] Affermativo.",
// risposte "no": 20 // risposte "no": 20
"❌ No.", "❌ No.",
"❌ Decisamente no!", "❌ Decisamente no!",
"❌ Uhm, secondo me sì. No, aspetta, ci ho ripensato. È un no.", "❌ Uhm, secondo me sì. No, aspetta, ci ho ripensato. È un no.",
"❌ No, no, e ancora NO!", "❌ No, no, e ancora NO!",
"❌ Nope.", "❌ Nope.",
"❌ Direi proprio di no.", "❌ Direi proprio di no.",
"❌ Assolutamente no.", "❌ Assolutamente no.",
"❌ Certo che no!", "❌ Certo che no!",
"❌ Neanche per idea!", "❌ Neanche per idea!",
"❌ Neanche per sogno!", "❌ Neanche per sogno!",
"❌ Niente affatto!", "❌ Niente affatto!",
"❌ Questa domanda ha risposta negativa.", "❌ Questa domanda ha risposta negativa.",
"❌ Hell no.", "❌ Hell no.",
"❌ NO! NO! NO!", "❌ NO! NO! NO!",
"❌ lolno", "❌ lolno",
"❌ NEIN NEIN NEIN NEIN", "❌ NEIN NEIN NEIN NEIN",
"❌ Delet dis", "❌ Delet dis",
"❌ Nopety nope!", "❌ Nopety nope!",
"❌ No, ma tienilo segreto.", "❌ No, ma tienilo segreto.",
"❌ [RADIO] Negativo.", "❌ [RADIO] Negativo.",
// risposte "boh": 20 // risposte "boh": 20
"❔ Boh.", "❔ Boh.",
"❔ E io che ne so?!", "❔ E io che ne so?!",
"❔ Non so proprio rispondere.", "❔ Non so proprio rispondere.",
"❔ Non lo so...", "❔ Non lo so...",
"❔ Mi avvalgo della facoltà di non rispondere.", "❔ Mi avvalgo della facoltà di non rispondere.",
"❔ Non parlerò senza il mio avvocato!", "❔ Non parlerò senza il mio avvocato!",
"❔ Dunno.", "❔ Dunno.",
"❔ Perché lo chiedi a me?", "❔ Perché lo chiedi a me?",
"❔ Ah, non lo so io!", "❔ Ah, non lo so io!",
r#"❔ ¯\_(ツ)_/¯"#, r#"❔ ¯\_(ツ)_/¯"#,
"❔ No idea.", "❔ No idea.",
"❔ Dunno.", "❔ Dunno.",
"❔ Boooooh!", "❔ Boooooh!",
"❔ Non ne ho la più pallida idea.", "❔ Non ne ho la più pallida idea.",
"❔ No comment.", "❔ No comment.",
"❔ maibi", "❔ maibi",
"❔ maibi not", "❔ maibi not",
"❔ idk dude", "❔ idk dude",
"❔ Non mi è permesso condividere questa informazione.", "❔ Non mi è permesso condividere questa informazione.",
"❔ [RADIO] Mantengo la posizione.", "❔ [RADIO] Mantengo la posizione.",
]; ];
pub async fn handler(bot: &Bot, message: &Message) -> CommandResult { pub async fn handler(bot: &Bot, message: &Message) -> CommandResult {

View file

@ -47,16 +47,16 @@ impl FromStr for DiarioArgs {
let context = captures.name("context") let context = captures.name("context")
.map(|s| s.as_str().to_owned()); .map(|s| s.as_str().to_owned());
DiarioArgs {warning, quote, quoted, context} DiarioArgs { warning, quote, quoted, context }
}, }
None => { None => {
let warning = None; let warning = None;
let quote = s.to_string(); let quote = s.to_string();
let quoted = None; let quoted = None;
let context = None; let context = None;
DiarioArgs {warning, quote, quoted, context} DiarioArgs { warning, quote, quoted, context }
}, }
}; };
Ok(args) Ok(args)
@ -65,7 +65,8 @@ impl FromStr for DiarioArgs {
impl TelegramWrite for Diario { impl TelegramWrite for Diario {
fn write_telegram<T>(&self, f: &mut T) -> Result<(), Error> fn write_telegram<T>(&self, f: &mut T) -> Result<(), Error>
where T: Write where
T: Write,
{ {
// Diario ID // Diario ID
write!(f, "<code>#{}</code>", self.id)?; write!(f, "<code>#{}</code>", self.id)?;

View file

@ -174,14 +174,14 @@ const FORTUNES: [&str; 164] = [
"🍻 Oggi una birra ti ridarà una vita!", "🍻 Oggi una birra ti ridarà una vita!",
"🎶 Oggi Hatsune Miku si nasconderà nella tua Wi-Fi!", "🎶 Oggi Hatsune Miku si nasconderà nella tua Wi-Fi!",
"🚽 Oggi delle telecamere combatteranno contro dei gabinetti!", "🚽 Oggi delle telecamere combatteranno contro dei gabinetti!",
"🌟 Oggi verrà scoperta una galassia grande quanto qualcuno della tua famiglia!", "🌟 Oggi verrà scoperta una galassia grande quanto qualcuno della tua famiglia!",
"🎶 Oggi Rick non rinuncerà mai a te!", "🎶 Oggi Rick non rinuncerà mai a te!",
"🏚 Oggi ristrutturerai una villa completando dei minigiochi match-3!", "🏚 Oggi ristrutturerai una villa completando dei minigiochi match-3!",
]; ];
struct FortuneKey { struct FortuneKey {
today: chrono::NaiveDate, today: chrono::NaiveDate,
author_id: teloxide::types::UserId author_id: teloxide::types::UserId,
} }
impl Hash for FortuneKey { impl Hash for FortuneKey {
@ -201,7 +201,7 @@ pub async fn handler(bot: &Bot, message: &Message) -> CommandResult {
.context("Non è stato possibile determinare chi ha inviato questo comando.")?; .context("Non è stato possibile determinare chi ha inviato questo comando.")?;
let author_id = author.id; let author_id = author.id;
let key = FortuneKey {today, author_id}; let key = FortuneKey { today, author_id };
let mut hasher = std::hash::DefaultHasher::new(); let mut hasher = std::hash::DefaultHasher::new();
key.hash(&mut hasher); key.hash(&mut hasher);

View file

@ -34,7 +34,9 @@ type CommandResult = AnyResult<()>;
pub enum Command { pub enum Command {
#[command(description = "Invia messaggio di introduzione.")] #[command(description = "Invia messaggio di introduzione.")]
Start, Start,
#[command(description = "Visualizza l'elenco dei comandi disponibili, o mostra informazioni su uno specifico comando.")] #[command(
description = "Visualizza l'elenco dei comandi disponibili, o mostra informazioni su uno specifico comando."
)]
Help(String), Help(String),
#[command(description = "Mostra il tuo oroscopo di oggi.")] #[command(description = "Mostra il tuo oroscopo di oggi.")]
Fortune, Fortune,

View file

@ -9,19 +9,19 @@ use teloxide::types::ReplyParameters;
use crate::services::telegram::commands::CommandResult; use crate::services::telegram::commands::CommandResult;
pub async fn handler(bot: &Bot, message: &Message, roll: &str) -> CommandResult { pub async fn handler(bot: &Bot, message: &Message, roll: &str) -> CommandResult {
let mut rng = rand::rngs::SmallRng::from_entropy(); let mut rng = rand::rngs::SmallRng::from_entropy();
if rng.gen_range(1..1001) == 1 { if rng.gen_range(1..1001) == 1 {
let _reply = bot let _reply = bot
.send_message(message.chat.id, "🎶 Roll? Rick roll! https://www.youtube.com/watch?v=dQw4w9WgXcQ") .send_message(message.chat.id, "🎶 Roll? Rick roll! https://www.youtube.com/watch?v=dQw4w9WgXcQ")
.reply_parameters(ReplyParameters::new(message.id)) .reply_parameters(ReplyParameters::new(message.id))
.await .await
.context("Non è stato possibile inviare la risposta.")?; .context("Non è stato possibile inviare la risposta.")?;
return Ok(()) return Ok(());
} }
let re = Regex::new(r#"(?P<qty>[0-9]*)?d(?P<die>[0-9]+)(?P<modifier>[+-]+[0-9]+)?"#).unwrap(); let re = Regex::new(r#"(?P<qty>[0-9]*)?d(?P<die>[0-9]+)(?P<modifier>[+-]+[0-9]+)?"#).unwrap();
let captures = re.captures(roll) let captures = re.captures(roll)
.context("Sintassi dei dadi non corretta.")?; .context("Sintassi dei dadi non corretta.")?;
@ -44,20 +44,20 @@ pub async fn handler(bot: &Bot, message: &Message, roll: &str) -> CommandResult
.unwrap_or(Ok(0)) .unwrap_or(Ok(0))
.context("Il modificatore dei dadi lanciati deve essere un numero intero.")?; .context("Il modificatore dei dadi lanciati deve essere un numero intero.")?;
if die == 0 { if die == 0 {
anyhow::bail!("Non è stato specificato nessun dado.") anyhow::bail!("Non è stato specificato nessun dado.")
} }
if qty < 1 { if qty < 1 {
anyhow::bail!("La quantità di dadi specificata deve essere un intero positivo.") anyhow::bail!("La quantità di dadi specificata deve essere un intero positivo.")
} }
let mut nums_rolled = Vec::<u32>::new(); let mut nums_rolled = Vec::<u32>::new();
for _ in 0..qty { for _ in 0..qty {
nums_rolled.push( nums_rolled.push(
rng.gen_range(1..=die) rng.gen_range(1..=die)
); );
} }
let roll_string = nums_rolled let roll_string = nums_rolled
.iter() .iter()
@ -65,18 +65,18 @@ pub async fn handler(bot: &Bot, message: &Message, roll: &str) -> CommandResult
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join("\n"); .join("\n");
let mut answer = format!("🎲 [{roll_string}]"); let mut answer = format!("🎲 [{roll_string}]");
if modifier != 0 { if modifier != 0 {
answer.push_str(&format!("{modifier:+}")) answer.push_str(&format!("{modifier:+}"))
} }
answer.push_str(" = "); answer.push_str(" = ");
let sum: u32 = nums_rolled.iter().sum(); let sum: u32 = nums_rolled.iter().sum();
let sum: i32 = sum as i32 + modifier; let sum: i32 = sum as i32 + modifier;
answer.push_str(&sum.to_string()); answer.push_str(&sum.to_string());
let _reply = bot let _reply = bot
.send_message(message.chat.id, answer) .send_message(message.chat.id, answer)

View file

@ -13,10 +13,10 @@ pub async fn handler(bot: &Bot, message: &Message) -> CommandResult {
let author_username = match author.username.as_ref() { let author_username = match author.username.as_ref() {
None => { None => {
author.first_name.clone() author.first_name.clone()
}, }
Some(username) => { Some(username) => {
format!("@{}", &username) format!("@{}", &username)
}, }
}; };
let me = bot let me = bot

View file

@ -36,7 +36,7 @@ impl FromStr for KeyboardCallback {
.parse() .parse()
.map(|c| Self::Matchmaking(id, c)) .map(|c| Self::Matchmaking(id, c))
.context("Impossibile processare i dati.") .context("Impossibile processare i dati.")
}, }
x => { x => {
anyhow::bail!("Keyword sconosciuta: {x:?}") anyhow::bail!("Keyword sconosciuta: {x:?}")
} }

View file

@ -46,7 +46,7 @@ impl TelegramService {
database_url, database_url,
bot, bot,
me, me,
notification_chat_id notification_chat_id,
}; };
log::trace!("Created service: {service:#?}"); log::trace!("Created service: {service:#?}");
@ -152,8 +152,8 @@ impl TelegramService {
.endpoint(KeyboardCallback::handle_self) .endpoint(KeyboardCallback::handle_self)
) )
.endpoint(KeyboardCallback::handle_unknown) .endpoint(KeyboardCallback::handle_unknown)
) ),
) )
.dependencies( .dependencies(
dptree::deps![ dptree::deps![
database database

View file

@ -2,7 +2,8 @@ use std::fmt::{Error, Write};
pub trait TelegramWrite { pub trait TelegramWrite {
fn write_telegram<T>(&self, f: &mut T) -> Result<(), Error> fn write_telegram<T>(&self, f: &mut T) -> Result<(), Error>
where T: Write; where
T: Write;
fn to_string_telegram(&self) -> String { fn to_string_telegram(&self) -> String {
let mut result = String::new(); let mut result = String::new();
@ -16,7 +17,8 @@ pub trait TelegramEscape {
} }
impl<T> TelegramEscape for T impl<T> TelegramEscape for T
where String: From<T> where
String: From<T>,
{ {
fn escape_telegram_html(self) -> String { fn escape_telegram_html(self) -> String {
String::from(self) String::from(self)