mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-21 18:44:19 +00:00
Run "Optimize imports..." IDE feature
This commit is contained in:
parent
b476a77fad
commit
9337834797
35 changed files with 128 additions and 80 deletions
|
@ -2,6 +2,7 @@ use anyhow::anyhow;
|
|||
use diesel::migration::MigrationVersion;
|
||||
use diesel::PgConnection;
|
||||
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
|
||||
|
||||
use crate::utils::anyhow_result::AnyResult;
|
||||
|
||||
const MIGRATIONS: EmbeddedMigrations = embed_migrations!();
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
pub use connect::connect;
|
||||
pub use migrations::migrate;
|
||||
|
||||
pub mod schema;
|
||||
pub mod models;
|
||||
pub mod query_prelude;
|
||||
|
@ -6,5 +9,3 @@ mod migrations;
|
|||
mod macros;
|
||||
mod connect;
|
||||
|
||||
pub use connect::connect;
|
||||
pub use migrations::migrate;
|
||||
|
|
|
@ -3,8 +3,10 @@ use diesel::{AsExpression, FromSqlRow, Identifiable, Insertable, PgConnection, Q
|
|||
use diesel::deserialize::FromSql;
|
||||
use diesel::pg::{Pg, PgValue};
|
||||
use diesel::serialize::ToSql;
|
||||
|
||||
use crate::newtype_sql;
|
||||
use crate::utils::anyhow_result::AnyResult;
|
||||
|
||||
use super::super::schema::brooch_match;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Identifiable, Queryable, Selectable, Insertable)]
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use diesel::{Identifiable, Insertable, Queryable, Selectable};
|
||||
use diesel::pg::Pg;
|
||||
|
||||
use crate::interfaces::database::models::users::RoyalnetUserId;
|
||||
use crate::newtype_sql;
|
||||
|
||||
use super::super::schema::diario;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Insertable)]
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use diesel::{Associations, Identifiable, Insertable, Queryable, Selectable};
|
||||
use diesel::pg::Pg;
|
||||
|
||||
use crate::newtype_sql;
|
||||
|
||||
use super::super::schema::discord;
|
||||
use super::users::{RoyalnetUser, RoyalnetUserId};
|
||||
|
||||
|
|
|
@ -3,8 +3,10 @@ use diesel::{AsExpression, FromSqlRow, Identifiable, Insertable, PgConnection, Q
|
|||
use diesel::deserialize::FromSql;
|
||||
use diesel::pg::{Pg, PgValue};
|
||||
use diesel::serialize::ToSql;
|
||||
|
||||
use crate::newtype_sql;
|
||||
use crate::utils::anyhow_result::AnyResult;
|
||||
|
||||
use super::super::schema::matchmaking_events;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Identifiable, Queryable, Selectable, Insertable)]
|
||||
|
@ -19,8 +21,6 @@ pub struct MatchmakingEvent {
|
|||
impl MatchmakingEvent {
|
||||
/// Create a new [MatchmakingEvent].
|
||||
pub fn create(database: &mut PgConnection, text: &str, starts_at: &chrono::DateTime<chrono::Local>) -> AnyResult<Self> {
|
||||
use crate::interfaces::database::query_prelude::*;
|
||||
|
||||
insert_into(matchmaking_events::table)
|
||||
.values(&(
|
||||
matchmaking_events::text.eq(text),
|
||||
|
@ -32,8 +32,6 @@ impl MatchmakingEvent {
|
|||
|
||||
/// Retrieve a [MatchmakingEvent] from the database, given its [MatchmakingId].
|
||||
pub fn get(database: &mut PgConnection, matchmaking_id: MatchmakingId) -> AnyResult<Self> {
|
||||
use crate::interfaces::database::query_prelude::*;
|
||||
|
||||
matchmaking_events::table
|
||||
.filter(matchmaking_events::id.eq(matchmaking_id.0))
|
||||
.get_result::<Self>(database)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use diesel::{Associations, Identifiable, Insertable, Queryable, Selectable};
|
||||
use diesel::pg::Pg;
|
||||
|
||||
use crate::interfaces::database::models::MatchmakingId;
|
||||
use crate::interfaces::database::models::telegram::{TelegramChatId, TelegramMessageId};
|
||||
|
||||
use super::matchmaking_events::MatchmakingEvent;
|
||||
use super::super::schema::matchmaking_messages_telegram;
|
||||
|
||||
|
@ -20,20 +22,24 @@ pub struct MatchmakingMessageTelegram {
|
|||
pub(crate) mod telegram_ext {
|
||||
use std::cmp::Ordering;
|
||||
use std::str::FromStr;
|
||||
|
||||
use anyhow::Context;
|
||||
use chrono::DateTime;
|
||||
use chrono::Local;
|
||||
use matchmaking_messages_telegram::star;
|
||||
use super::*;
|
||||
use diesel::PgConnection;
|
||||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::payloads::EditMessageTextSetters;
|
||||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::requests::Requester;
|
||||
use teloxide::types::ParseMode;
|
||||
|
||||
use matchmaking_messages_telegram::star;
|
||||
|
||||
use crate::interfaces::database::models::{MatchmakingChoice, MatchmakingId, MatchmakingReply, RoyalnetUser, TelegramUser};
|
||||
use crate::utils::anyhow_result::AnyResult;
|
||||
use crate::utils::telegram_string::TelegramEscape;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum MatchmakingTelegramKeyboardCallback {
|
||||
Yes,
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
use std::ops::Add;
|
||||
|
||||
use anyhow::Context;
|
||||
use diesel::{Associations, Identifiable, Insertable, PgConnection, Queryable, Selectable};
|
||||
use diesel::pg::Pg;
|
||||
|
||||
use crate::interfaces::database::models::{MatchmakingId, RoyalnetUserId, TelegramUser};
|
||||
use crate::utils::anyhow_result::AnyResult;
|
||||
|
||||
use super::matchmaking_choice::MatchmakingChoice;
|
||||
use super::matchmaking_events::MatchmakingEvent;
|
||||
use super::super::schema::matchmaking_replies;
|
||||
|
@ -24,8 +27,7 @@ pub struct MatchmakingReply {
|
|||
|
||||
impl MatchmakingReply {
|
||||
pub fn get_all_telegram(database: &mut PgConnection, matchmaking_id: MatchmakingId) -> AnyResult<Vec<(Self, RoyalnetUser, TelegramUser)>> {
|
||||
use crate::interfaces::database::query_prelude::*;
|
||||
use schema::{matchmaking_replies, users, telegram};
|
||||
use schema::{matchmaking_replies, telegram, users};
|
||||
|
||||
matchmaking_replies::table
|
||||
.filter(matchmaking_replies::matchmaking_id.eq(matchmaking_id))
|
||||
|
@ -36,7 +38,6 @@ impl MatchmakingReply {
|
|||
}
|
||||
|
||||
pub fn set(database: &mut PgConnection, matchmaking_id: MatchmakingId, user_id: RoyalnetUserId, choice: MatchmakingChoice) -> AnyResult<Self> {
|
||||
use crate::interfaces::database::query_prelude::*;
|
||||
use schema::matchmaking_replies;
|
||||
|
||||
insert_into(matchmaking_replies::table)
|
||||
|
@ -57,7 +58,6 @@ impl MatchmakingReply {
|
|||
}
|
||||
|
||||
pub fn add_late_minutes(database: &mut PgConnection, matchmaking_id: MatchmakingId, user_id: RoyalnetUserId, increase_by: i32) -> AnyResult<Self> {
|
||||
use crate::interfaces::database::query_prelude::*;
|
||||
use schema::matchmaking_replies;
|
||||
|
||||
insert_into(matchmaking_replies::table)
|
||||
|
|
|
@ -5,6 +5,17 @@ use std::io::Write;
|
|||
use diesel::deserialize::FromSql;
|
||||
use diesel::serialize::ToSql;
|
||||
|
||||
pub use brooch_match::{BroochMatch, DotaMatchId};
|
||||
pub use diario::{Diario, DiarioId};
|
||||
pub use discord::DiscordUserId;
|
||||
pub use matchmaking_choice::MatchmakingChoice;
|
||||
pub use matchmaking_events::{MatchmakingEvent, MatchmakingId};
|
||||
pub use matchmaking_messages_telegram::{MatchmakingMessageTelegram, telegram_ext::MatchmakingTelegramKeyboardCallback};
|
||||
pub use matchmaking_replies::MatchmakingReply;
|
||||
pub use steam::SteamId64;
|
||||
pub use telegram::{TelegramChatId, TelegramMessageId, TelegramUser, TelegramUserId};
|
||||
pub use users::{RoyalnetUser, RoyalnetUserId};
|
||||
|
||||
mod users;
|
||||
mod telegram;
|
||||
mod discord;
|
||||
|
@ -16,13 +27,3 @@ mod matchmaking_replies;
|
|||
mod matchmaking_messages_telegram;
|
||||
mod matchmaking_choice;
|
||||
|
||||
pub use users::{RoyalnetUser, RoyalnetUserId};
|
||||
pub use telegram::{TelegramUser, TelegramChatId, TelegramMessageId, TelegramUserId};
|
||||
pub use discord::{DiscordUser, DiscordUserId};
|
||||
pub use steam::{SteamUser, SteamId64};
|
||||
pub use brooch_match::{BroochMatch, DotaMatchId};
|
||||
pub use diario::{Diario, DiarioId};
|
||||
pub use matchmaking_events::{MatchmakingEvent, MatchmakingId};
|
||||
pub use matchmaking_replies::MatchmakingReply;
|
||||
pub use matchmaking_messages_telegram::{MatchmakingMessageTelegram, telegram_ext::MatchmakingTelegramKeyboardCallback};
|
||||
pub use matchmaking_choice::MatchmakingChoice;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use diesel::{Associations, Identifiable, Insertable, Queryable, Selectable};
|
||||
use diesel::pg::Pg;
|
||||
|
||||
use crate::newtype_sql;
|
||||
|
||||
use super::super::schema::steam;
|
||||
use super::users::{RoyalnetUser, RoyalnetUserId};
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use diesel::{Associations, Identifiable, Insertable, Queryable, Selectable};
|
||||
use diesel::pg::Pg;
|
||||
|
||||
use crate::newtype_sql;
|
||||
|
||||
use super::super::schema::telegram;
|
||||
use super::users::{RoyalnetUser, RoyalnetUserId};
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ use diesel::{Identifiable, Insertable, Queryable, Selectable};
|
|||
use diesel::deserialize::FromSql;
|
||||
use diesel::pg::Pg;
|
||||
use diesel::serialize::ToSql;
|
||||
|
||||
use crate::newtype_sql;
|
||||
|
||||
use super::super::schema::users;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Identifiable, Queryable, Selectable, Insertable)]
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
#![allow(unused_imports)]
|
||||
|
||||
pub use diesel::dsl::*;
|
||||
pub use diesel::query_dsl::*;
|
||||
pub use diesel::upsert::*;
|
||||
pub use diesel::OptionalExtension;
|
||||
pub use diesel::ExpressionMethods;
|
||||
pub use diesel::OptionalExtension;
|
||||
pub use diesel::query_dsl::*;
|
||||
pub use diesel::SelectableHelper;
|
||||
pub use super::schema;
|
||||
pub use super::models;
|
||||
pub use diesel::upsert::*;
|
||||
|
||||
|
|
|
@ -2,10 +2,22 @@
|
|||
|
||||
use graphql_client::GraphQLQuery;
|
||||
use reqwest::Url;
|
||||
pub use super::Short;
|
||||
pub use super::Long;
|
||||
|
||||
pub use query::GameModeEnumType as GameMode;
|
||||
pub use query::LobbyTypeEnum as LobbyType;
|
||||
pub use query::MatchLaneType as Lane;
|
||||
pub use query::MatchPlayerRoleType as Role;
|
||||
pub use query::QueryGuild as Guild;
|
||||
pub use query::QueryGuildMatches as Match;
|
||||
pub use query::QueryGuildMatchesPlayers as Player;
|
||||
pub use query::QueryGuildMatchesPlayersHero as Hero;
|
||||
pub use query::QueryGuildMatchesPlayersStatsMatchPlayerBuffEvent as Buff;
|
||||
pub use query::QueryGuildMatchesPlayersSteamAccount as Steam;
|
||||
|
||||
pub use super::Byte;
|
||||
pub use super::Long;
|
||||
pub use super::QueryError as Error;
|
||||
pub use super::Short;
|
||||
|
||||
#[derive(graphql_client::GraphQLQuery)]
|
||||
#[graphql(
|
||||
|
@ -18,17 +30,6 @@ struct Query;
|
|||
pub type QueryResponse = graphql_client::Response<query::ResponseData>;
|
||||
pub type QueryResult = Result<QueryResponse, Error>;
|
||||
|
||||
pub use query::LobbyTypeEnum as LobbyType;
|
||||
pub use query::GameModeEnumType as GameMode;
|
||||
pub use query::MatchLaneType as Lane;
|
||||
pub use query::MatchPlayerRoleType as Role;
|
||||
pub use query::QueryGuild as Guild;
|
||||
pub use query::QueryGuildMatches as Match;
|
||||
pub use query::QueryGuildMatchesPlayers as Player;
|
||||
pub use query::QueryGuildMatchesPlayersHero as Hero;
|
||||
pub use query::QueryGuildMatchesPlayersSteamAccount as Steam;
|
||||
pub use query::QueryGuildMatchesPlayersStatsMatchPlayerBuffEvent as Buff;
|
||||
|
||||
pub async fn query(client: &reqwest::Client, url: Url, guild_id: i64) -> QueryResult {
|
||||
log::debug!("Querying guild_matches of guild {guild_id}...");
|
||||
log::trace!("Using client: {client:?}");
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
use std::cmp::PartialEq;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::Context;
|
||||
use chrono::{DateTime, Local, TimeDelta, TimeZone};
|
||||
use diesel::{PgConnection};
|
||||
use diesel::PgConnection;
|
||||
use reqwest::Url;
|
||||
use teloxide::Bot;
|
||||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::requests::Requester;
|
||||
use teloxide::types::{ChatId, LinkPreviewOptions, Message};
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::interfaces::database;
|
||||
use crate::interfaces::database::models::{BroochMatch, DotaMatchId, TelegramUserId};
|
||||
use crate::services::RoyalnetService;
|
||||
use crate::utils::anyhow_result::AnyResult;
|
||||
use crate::interfaces::stratz::{Byte, guild_matches, Short};
|
||||
use crate::interfaces::stratz::guild_matches::{GameMode, Lane, LobbyType, Match, Player, Role, Steam};
|
||||
use crate::services::RoyalnetService;
|
||||
use crate::utils::anyhow_result::AnyResult;
|
||||
use crate::utils::telegram_string::TelegramEscape;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -434,7 +436,7 @@ impl BroochService {
|
|||
fn get_player_telegram_id(&self, database: &mut PgConnection, player_steam: Steam) -> AnyResult<Option<TelegramUserId>> {
|
||||
use diesel::prelude::*;
|
||||
use diesel::{ExpressionMethods, QueryDsl};
|
||||
use crate::interfaces::database::schema::{steam, users, telegram};
|
||||
use crate::interfaces::database::schema::{steam, telegram, users};
|
||||
use crate::interfaces::database::models::TelegramUser;
|
||||
|
||||
log::trace!("Getting player's Steam name...");
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::utils::anyhow_result::AnyResult;
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use anyhow::{Context};
|
||||
use anyhow::Context;
|
||||
use rand::SeedableRng;
|
||||
use rand::seq::SliceRandom;
|
||||
use teloxide::Bot;
|
||||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::prelude::{Message, Requester};
|
||||
use teloxide::types::ReplyParameters;
|
||||
use crate::services::telegram::commands::{CommandResult};
|
||||
|
||||
use crate::services::telegram::commands::CommandResult;
|
||||
|
||||
// Cerchiamo di tenere bilanciate le tre colonne, o almeno le prime due.
|
||||
// Se avete un'idea ma metterebbe troppe opzioni in un'unica categoria, mettetela sotto commento.
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use anyhow::Context;
|
||||
use reqwest::Url;
|
||||
use serde::Deserialize;
|
||||
use teloxide::Bot;
|
||||
use teloxide::payloads::SendPhotoSetters;
|
||||
use teloxide::requests::Requester;
|
||||
use teloxide::types::{InputFile, Message, ReplyParameters};
|
||||
use serde::Deserialize;
|
||||
use super::{CommandResult};
|
||||
|
||||
use super::CommandResult;
|
||||
|
||||
const CAT_API_URL: &str = "https://api.thecatapi.com/v1/images/search";
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::fmt::{Error, Write};
|
||||
use std::str::FromStr;
|
||||
|
||||
use anyhow::Context;
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
|
@ -7,6 +8,7 @@ use teloxide::Bot;
|
|||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::prelude::Requester;
|
||||
use teloxide::types::{Message, ParseMode, ReplyParameters};
|
||||
|
||||
use crate::interfaces::database::models::Diario;
|
||||
use crate::interfaces::database::models::RoyalnetUser;
|
||||
use crate::services::telegram::commands::CommandResult;
|
||||
|
@ -122,7 +124,6 @@ pub async fn handler(bot: &Bot, message: &Message, args: &DiarioArgs, database:
|
|||
};
|
||||
|
||||
let entry = {
|
||||
use crate::interfaces::database::query_prelude::*;
|
||||
use schema::diario;
|
||||
|
||||
insert_into(diario::table)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use anyhow::Context;
|
||||
use reqwest::Url;
|
||||
use serde::Deserialize;
|
||||
use teloxide::Bot;
|
||||
use teloxide::payloads::SendPhotoSetters;
|
||||
use teloxide::requests::Requester;
|
||||
use teloxide::types::{InputFile, Message, ReplyParameters};
|
||||
use serde::Deserialize;
|
||||
use super::{CommandResult};
|
||||
|
||||
use super::CommandResult;
|
||||
|
||||
const DOG_API_URL: &str = "https://dog.ceo/api/breeds/image/random";
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@ use teloxide::Bot;
|
|||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::requests::Requester;
|
||||
use teloxide::types::{Message, ReplyParameters};
|
||||
use super::{CommandResult};
|
||||
|
||||
use super::CommandResult;
|
||||
|
||||
pub async fn handler(bot: &Bot, message: &Message, text: &str) -> CommandResult {
|
||||
let text = format!(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::hash::{Hash, Hasher};
|
||||
use anyhow::{Context};
|
||||
|
||||
use anyhow::Context;
|
||||
use chrono::Datelike;
|
||||
use rand::SeedableRng;
|
||||
use rand::seq::SliceRandom;
|
||||
|
@ -7,7 +8,8 @@ use teloxide::Bot;
|
|||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::prelude::{Message, Requester};
|
||||
use teloxide::types::ReplyParameters;
|
||||
use crate::services::telegram::commands::{CommandResult};
|
||||
|
||||
use crate::services::telegram::commands::CommandResult;
|
||||
|
||||
// Tutte le fortune devono essere positive, o almeno neutrali, per poter essere aggiunte.
|
||||
const FORTUNES: [&str; 164] = [
|
||||
|
|
|
@ -4,7 +4,8 @@ use teloxide::payloads::SendMessageSetters;
|
|||
use teloxide::requests::Requester;
|
||||
use teloxide::types::{BotCommand, Message, ParseMode, ReplyParameters};
|
||||
use teloxide::utils::command::BotCommands;
|
||||
use super::{CommandResult};
|
||||
|
||||
use super::CommandResult;
|
||||
|
||||
pub async fn handler_all(bot: &Bot, message: &Message) -> CommandResult {
|
||||
let descriptions = super::Command::descriptions().to_string();
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use anyhow::Context;
|
||||
use once_cell::sync::Lazy;
|
||||
use parse_datetime::parse_datetime_at_date;
|
||||
use regex::Regex;
|
||||
use teloxide::Bot;
|
||||
use teloxide::prelude::Message;
|
||||
|
||||
use crate::interfaces::database::models::MatchmakingEvent;
|
||||
use crate::interfaces::database::models::MatchmakingMessageTelegram;
|
||||
use crate::services::telegram::commands::CommandResult;
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
// https://github.com/teloxide/teloxide/blob/master/crates/teloxide/examples/dispatching_features.rs
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{Context, Error};
|
||||
use teloxide::Bot;
|
||||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::requests::Requester;
|
||||
use teloxide::types::{Message, ReplyParameters};
|
||||
use teloxide::utils::command::BotCommands;
|
||||
|
||||
use crate::services::telegram::dependencies::interface_database::DatabaseInterface;
|
||||
use crate::utils::anyhow_result::AnyResult;
|
||||
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use anyhow::Context;
|
||||
use once_cell::sync::Lazy;
|
||||
use parse_datetime::parse_datetime_at_date;
|
||||
use regex::Regex;
|
||||
use teloxide::Bot;
|
||||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::requests::Requester;
|
||||
use teloxide::types::{Message, ParseMode, ReplyParameters};
|
||||
use parse_datetime::parse_datetime_at_date;
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
|
||||
use crate::utils::telegram_string::TelegramEscape;
|
||||
use crate::utils::time::sleep_chrono;
|
||||
use super::CommandResult;
|
||||
|
||||
use super::CommandResult;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ReminderArgs {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use anyhow::{Context};
|
||||
use anyhow::Context;
|
||||
use rand::{Rng, SeedableRng};
|
||||
use regex::Regex;
|
||||
use teloxide::Bot;
|
||||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::prelude::{Message, Requester};
|
||||
use crate::services::telegram::commands::{CommandResult};
|
||||
use regex::Regex;
|
||||
use teloxide::types::ReplyParameters;
|
||||
|
||||
use crate::services::telegram::commands::CommandResult;
|
||||
|
||||
pub async fn handler(bot: &Bot, message: &Message, roll: &str) -> CommandResult {
|
||||
let mut rng = rand::rngs::SmallRng::from_entropy();
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ use teloxide::Bot;
|
|||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::requests::Requester;
|
||||
use teloxide::types::{Message, ReplyParameters};
|
||||
use super::{CommandResult};
|
||||
|
||||
use super::CommandResult;
|
||||
|
||||
pub async fn handler(bot: &Bot, message: &Message) -> CommandResult {
|
||||
let author = message.from.as_ref()
|
||||
|
|
|
@ -3,9 +3,11 @@ use teloxide::Bot;
|
|||
use teloxide::payloads::SendMessageSetters;
|
||||
use teloxide::requests::Requester;
|
||||
use teloxide::types::{Message, ParseMode, ReplyParameters};
|
||||
|
||||
use crate::interfaces::database::models::RoyalnetUser;
|
||||
use crate::services::telegram::dependencies::interface_database::DatabaseInterface;
|
||||
use crate::utils::telegram_string::TelegramEscape;
|
||||
|
||||
use super::CommandResult;
|
||||
|
||||
pub async fn handler(bot: &Bot, message: &Message, database: &DatabaseInterface) -> CommandResult {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use anyhow::Context;
|
||||
use diesel::PgConnection;
|
||||
|
||||
use crate::utils::anyhow_result::AnyResult;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
@ -3,6 +3,7 @@ use teloxide::Bot;
|
|||
use teloxide::payloads::AnswerCallbackQuerySetters;
|
||||
use teloxide::requests::Requester;
|
||||
use teloxide::types::CallbackQuery;
|
||||
|
||||
use crate::interfaces::database::models::{MatchmakingChoice, MatchmakingId, MatchmakingMessageTelegram, MatchmakingReply, MatchmakingTelegramKeyboardCallback, RoyalnetUser};
|
||||
use crate::services::telegram::dependencies::interface_database::DatabaseInterface;
|
||||
use crate::services::telegram::keyboard_callbacks::KeyboardCallbackResult;
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
mod matchmaking;
|
||||
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Context;
|
||||
use teloxide::Bot;
|
||||
use teloxide::payloads::AnswerCallbackQuerySetters;
|
||||
use teloxide::prelude::CallbackQuery;
|
||||
use teloxide::requests::Requester;
|
||||
|
||||
use crate::interfaces::database::models::{MatchmakingId, MatchmakingTelegramKeyboardCallback};
|
||||
use crate::services::telegram::dependencies::interface_database::DatabaseInterface;
|
||||
|
||||
mod matchmaking;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum KeyboardCallback {
|
||||
Matchmaking(MatchmakingId, MatchmakingTelegramKeyboardCallback),
|
||||
|
|
|
@ -1,22 +1,26 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Context;
|
||||
use regex::Regex;
|
||||
use teloxide::dispatching::DefaultKey;
|
||||
use teloxide::dptree::entry;
|
||||
use teloxide::prelude::*;
|
||||
use teloxide::types::{Me, ParseMode};
|
||||
|
||||
use commands::Command;
|
||||
use dependencies::interface_database::DatabaseInterface;
|
||||
use keyboard_callbacks::KeyboardCallback;
|
||||
|
||||
use crate::utils::anyhow_result::{AnyError, AnyResult};
|
||||
use crate::utils::telegram_string::TelegramEscape;
|
||||
|
||||
use super::RoyalnetService;
|
||||
|
||||
mod commands;
|
||||
mod dependencies;
|
||||
mod keyboard_callbacks;
|
||||
mod utils;
|
||||
|
||||
use std::sync::Arc;
|
||||
use anyhow::Context;
|
||||
use teloxide::prelude::*;
|
||||
use teloxide::types::{Me, ParseMode};
|
||||
use regex::Regex;
|
||||
use teloxide::dispatching::DefaultKey;
|
||||
use teloxide::dptree::entry;
|
||||
use commands::Command;
|
||||
use dependencies::interface_database::DatabaseInterface;
|
||||
use keyboard_callbacks::KeyboardCallback;
|
||||
use crate::utils::anyhow_result::{AnyError, AnyResult};
|
||||
use crate::utils::telegram_string::TelegramEscape;
|
||||
use super::RoyalnetService;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TelegramService {
|
||||
database_url: String,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use anyhow::Context;
|
||||
use diesel::PgConnection;
|
||||
use teloxide::types::UserId;
|
||||
|
||||
use crate::interfaces::database::models::RoyalnetUser;
|
||||
use crate::utils::anyhow_result::AnyResult;
|
||||
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
pub use anyhow::Result as AnyResult;
|
||||
|
||||
|
|
Loading…
Reference in a new issue