mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-24 20:14:19 +00:00
Run "Reformat code..." IDE feature
This commit is contained in:
parent
b84b70080f
commit
ec3f5daff7
34 changed files with 67626 additions and 67621 deletions
|
@ -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...");
|
||||
|
@ -90,13 +90,13 @@ impl RoyalnetInstance {
|
|||
}
|
||||
|
||||
#[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()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "service_telegram"))]
|
||||
#[allow(clippy::manual_async_fn)]
|
||||
fn get_telegram_future(_service: &mut ()) -> impl Future<Output = ()> + '_ {
|
||||
fn get_telegram_future(_service: &mut ()) -> impl Future<Output=()> + '_ {
|
||||
async {}
|
||||
}
|
||||
|
||||
|
@ -122,13 +122,13 @@ impl RoyalnetInstance {
|
|||
}
|
||||
|
||||
#[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()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "service_brooch"))]
|
||||
#[allow(clippy::manual_async_fn)]
|
||||
fn get_brooch_future(_service: &mut ()) -> impl Future<Output = ()> + '_ {
|
||||
fn get_brooch_future(_service: &mut ()) -> impl Future<Output=()> + '_ {
|
||||
async {}
|
||||
}
|
||||
}
|
|
@ -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<()>
|
||||
{
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
@ -534,14 +534,14 @@ impl BroochService {
|
|||
use Lane::*;
|
||||
|
||||
match (role, lane) {
|
||||
( Some(CORE), Some(SAFE_LANE)) => 1,
|
||||
( Some(CORE), Some(MID_LANE)) => 2,
|
||||
( Some(CORE), Some(OFF_LANE)) => 3,
|
||||
( _, Some(ROAMING)) => 4,
|
||||
( _, Some(JUNGLE)) => 5,
|
||||
(Some(CORE), Some(SAFE_LANE)) => 1,
|
||||
(Some(CORE), Some(MID_LANE)) => 2,
|
||||
(Some(CORE), Some(OFF_LANE)) => 3,
|
||||
(_, Some(ROAMING)) => 4,
|
||||
(_, Some(JUNGLE)) => 5,
|
||||
(Some(LIGHT_SUPPORT), _) => 6,
|
||||
( Some(HARD_SUPPORT), _) => 7,
|
||||
( _, _) => 8,
|
||||
(Some(HARD_SUPPORT), _) => 7,
|
||||
(_, _) => 8,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -552,14 +552,14 @@ impl BroochService {
|
|||
log::trace!("Stringifying role and lane...");
|
||||
|
||||
match (role, lane) {
|
||||
( CORE, SAFE_LANE) => "1️⃣ Safe Carry",
|
||||
( CORE, MID_LANE) => "2️⃣ Mid Carry",
|
||||
( CORE, OFF_LANE) => "3️⃣ Off Tank",
|
||||
( _, ROAMING) => "🔀 Roaming",
|
||||
( _, JUNGLE) => "⏫ Jungle",
|
||||
(CORE, SAFE_LANE) => "1️⃣ Safe Carry",
|
||||
(CORE, MID_LANE) => "2️⃣ Mid Carry",
|
||||
(CORE, OFF_LANE) => "3️⃣ Off Tank",
|
||||
(_, ROAMING) => "🔀 Roaming",
|
||||
(_, JUNGLE) => "⏫ Jungle",
|
||||
(LIGHT_SUPPORT, _) => "4️⃣ Soft Support",
|
||||
( HARD_SUPPORT, _) => "5️⃣ Hard Support",
|
||||
( _, _) => "🆕 Sconosciuto",
|
||||
(HARD_SUPPORT, _) => "5️⃣ Hard Support",
|
||||
(_, _) => "🆕 Sconosciuto",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -47,16 +47,16 @@ impl FromStr for DiarioArgs {
|
|||
let context = captures.name("context")
|
||||
.map(|s| s.as_str().to_owned());
|
||||
|
||||
DiarioArgs {warning, quote, quoted, context}
|
||||
},
|
||||
DiarioArgs { warning, quote, quoted, context }
|
||||
}
|
||||
None => {
|
||||
let warning = None;
|
||||
let quote = s.to_string();
|
||||
let quoted = None;
|
||||
let context = None;
|
||||
|
||||
DiarioArgs {warning, quote, quoted, context}
|
||||
},
|
||||
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)?;
|
||||
|
|
|
@ -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 {
|
||||
|
@ -201,7 +201,7 @@ pub async fn handler(bot: &Bot, message: &Message) -> CommandResult {
|
|||
.context("Non è stato possibile determinare chi ha inviato questo comando.")?;
|
||||
let author_id = author.id;
|
||||
|
||||
let key = FortuneKey {today, author_id};
|
||||
let key = FortuneKey { today, author_id };
|
||||
|
||||
let mut hasher = std::hash::DefaultHasher::new();
|
||||
key.hash(&mut hasher);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:?}")
|
||||
}
|
||||
|
|
|
@ -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![
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue