1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-21 18:44:19 +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() {
if !config::interface_database::DATABASE_AUTOMIGRATE() {
log::warn!("Database automigration is disabled.");
return
return;
}
log::debug!("Automatically applying database migrations...");

View file

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

View file

@ -40,7 +40,7 @@ impl BroochService {
min_players_to_process: usize,
telegram_bot_token: String,
notification_chat_id: ChatId,
max_imp_wait: TimeDelta
max_imp_wait: TimeDelta,
)
-> AnyResult<Self>
{
@ -352,21 +352,21 @@ impl BroochService {
side = match (side, player.is_radiant) {
(_, None) => {
anyhow::bail!("Non è stata ricevuta da STRATZ la squadra di almeno uno dei giocatori.")
},
}
(None, Some(true)) => {
Some(Radiant)
},
}
(None, Some(false)) => {
Some(Dire)
},
}
(Some(Radiant), Some(true)) |
(Some(Dire), Some(false)) => {
side
},
}
(Some(Radiant), Some(false)) |
(Some(Dire), Some(true)) => {
Some(Both)
},
}
(Some(Both), _) => {
break
}
@ -391,21 +391,21 @@ impl BroochService {
outcome = match (outcome, player.is_victory) {
(_, None) => {
anyhow::bail!("Non è stata ricevuta da STRATZ la squadra di almeno uno dei giocatori.")
},
}
(None, Some(true)) => {
Some(Victory)
},
}
(None, Some(false)) => {
Some(Defeat)
},
}
(Some(Victory), Some(true)) |
(Some(Defeat), Some(false)) => {
outcome
},
}
(Some(Victory), Some(false)) |
(Some(Defeat), Some(true)) => {
Some(Clash)
},
}
(Some(Clash), _) => {
break
}
@ -661,7 +661,7 @@ impl BroochService {
if !self.should_process_match_exists(database, match_id)? {
log::trace!("Skipping match, already parsed.");
return Ok((match_id, None))
return Ok((match_id, None));
}
let datetime = self.get_match_datetime(&r#match)?;
@ -675,12 +675,12 @@ impl BroochService {
if !self.should_process_match_players(&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) {
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));

View file

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

View file

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

View file

@ -181,7 +181,7 @@ const FORTUNES: [&str; 164] = [
struct FortuneKey {
today: chrono::NaiveDate,
author_id: teloxide::types::UserId
author_id: teloxide::types::UserId,
}
impl Hash for FortuneKey {

View file

@ -34,7 +34,9 @@ type CommandResult = AnyResult<()>;
pub enum Command {
#[command(description = "Invia messaggio di introduzione.")]
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),
#[command(description = "Mostra il tuo oroscopo di oggi.")]
Fortune,

View file

@ -18,7 +18,7 @@ pub async fn handler(bot: &Bot, message: &Message, roll: &str) -> CommandResult
.await
.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();

View file

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

View file

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

View file

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

View file

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