Fix command descriptions

(needs tripple /// not double)
And clean up some commented out code.
Also update caches for viaplay to make a bit more sense
This commit is contained in:
Tom 2023-04-09 21:03:50 +02:00
parent df60ac6aae
commit 1db9ebdde2
10 changed files with 17 additions and 56 deletions

View file

@ -9,8 +9,6 @@ async fn autocomplete_command<'a>(ctx: Context<'_>, partial: &'a str) -> Vec<Str
};
let stmt = conn.prep("SELECT sign FROM commands WHERE sign LIKE CONCAT('%', :partial, '%') AND enabled ORDER BY priority DESC, sign ASC LIMIT 25").await.unwrap();
// let ding = con.exec(&stmt, params! {partial}).await?;
// let iter = ding.into_iter().map(|a| a.to_string());
let result = match conn.exec_iter(stmt, params! {partial}).await {
Ok(blah) => blah
.map_and_drop(|row| from_row::<String>(row))
@ -29,7 +27,7 @@ pub async fn get_command(sign: &str, con: &mut Conn) -> Result<Option<String>, m
Ok(a)
}
// Run any of a collection of arbitrary commands
/// Run any of a collection of arbitrary commands
#[poise::command(slash_command)]
pub async fn coms(
ctx: Context<'_>,

View file

@ -8,14 +8,11 @@ struct Message {
#[derive(Debug, Deserialize)]
struct InviteData {
// id: String,
// token: String,
// isUsed: bool,
#[serde(rename = "isHighTier")]
is_high_tier: bool,
// isCustom: bool,
}
/// Get information about an invite
#[poise::command(slash_command, ephemeral)]
pub async fn invites(
ctx: Context<'_>,

View file

@ -116,7 +116,7 @@ async fn get_events() -> Vec<Events> {
events
}
// All events filtered (Eurosport, NFL, Viaplay)
/// All events filtered (Eurosport, NFL, Viaplay)
#[poise::command(slash_command, ephemeral)]
pub async fn all(
ctx: Context<'_>,

View file

@ -22,13 +22,9 @@ pub struct CmoreData {
title: String,
subtitle: String,
duration: i64,
// #[serde(rename = "humanDuration")]
// hduration: String,
#[serde(rename = "liveBroadcastTime")]
#[serde(with = "cmore_date")]
start: DateTime<Utc>,
// #[serde(rename = "mainCategoryTitle")]
// category: String,
}
impl CmoreEvent {
@ -151,7 +147,7 @@ pub async fn get_schedule() -> Option<Vec<CmoreEvent>> {
result
}
// Cmore events listing
/// Cmore events listing
#[poise::command(slash_command, ephemeral)]
pub async fn cmore(
ctx: Context<'_>,

View file

@ -150,7 +150,6 @@ impl ESEvents {
pub fn to_string(&self) -> String {
match &self.sport {
// None => format!("```md\n({}) {}```\n", self.name, self.secondary),
None => format!(
"```md\n({}) {}```(<t:{}:R>-<t:{}:R>) {}\n https://tom.al/ms/euro/{}",
self.name,
@ -297,7 +296,7 @@ pub async fn get_eurosport_events(url: String) -> Option<Vec<ESEvents>> {
return result;
}
// Eurosport player events
/// Eurosport player events
#[poise::command(slash_command, ephemeral)]
pub async fn eurosport(
ctx: Context<'_>,

View file

@ -32,7 +32,6 @@ impl MSEvent {
fn get_title(&self) -> String {
let title = &self.metadata.attributes.series.replace("FORMULA", "F");
format!("**{}: {}**", title, self.metadata.brief)
// format!("", sport=self.content.format.sport, title=self.content.title, synopsis=self.content.synopsis, start=self.times.start.timestamp(), end=self.times.end.timestamp(), desc=self.content.description, id=self.system.product_key)
}
fn get_value(&self) -> String {
@ -195,7 +194,7 @@ async fn get_sessions(season: String) -> Option<Season> {
result
}
// F1TV links throughout the seasons
/// F1TV links throughout the seasons
#[poise::command(slash_command, ephemeral)]
pub async fn f1(
ctx: Context<'_>,

View file

@ -38,8 +38,6 @@ mod nfl_date {
#[derive(Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
struct NFLContext {
// current_season: String,
// current_season_type: String,
#[serde(with = "str_to_u8")]
current_week: u8,
}
@ -49,7 +47,6 @@ struct NFLContext {
pub struct NFLEvent {
home_nick_name: String,
visitor_nick_name: String,
// game_id: String,
#[serde(with = "nfl_date")]
game_date_time_utc: DateTime<Utc>,
video: NFLVideo,
@ -59,9 +56,7 @@ pub struct NFLEvent {
#[serde(rename_all = "camelCase")]
struct NFLVideo {
title: String,
// video_status: String,
video_id: String,
// schedule_date: String
}
impl NFLEvent {
@ -85,7 +80,6 @@ impl NFLEvent {
}
Timeframe::Future => (self.game_date_time_utc + Duration::minutes(240)) >= now,
Timeframe::Past => self.game_date_time_utc <= now,
// _ => (self.game_date_time_utc + Duration::minutes(240)) >= now,
}
}
@ -195,7 +189,7 @@ async fn get_schedule(week: u8) -> Option<Vec<NFLEvent>> {
result
}
//NFL events listing
/// NFL events listing
#[poise::command(slash_command, ephemeral)]
pub async fn nfl(
ctx: Context<'_>,

View file

@ -137,12 +137,15 @@ mod viaplay_sport {
"Bundesliiga" => Ok("Bundesliga".to_string()),
"2. Bundesliiga" => Ok("2. Bundesliga".to_string()),
"Hevosurheilu" => Ok("Equestrian sport".to_string()),
"Skotlannin Valioliiga" => Ok("Scottish Premier League".to_string()),
"Käsipallon Bundesliiga" => Ok("Handball Bundesliga".to_string()),
"Tanskan Bundesliiga" => Ok("Danish Superliga".to_string()),
_ => Ok(s.to_string()),
}
}
}
#[cached(time = 3600)]
#[cached(time = 7200)]
pub async fn get_schedule() -> Option<Vec<ViaplayEvent>> {
let token = super::super::super::SETTINGS
.read()
@ -193,7 +196,7 @@ pub async fn get_schedule() -> Option<Vec<ViaplayEvent>> {
result
}
#[cached(time = 3600)]
#[cached(time = 36000)]
pub async fn get_schedule_date(date: NaiveDate) -> Option<Vec<ViaplayEvent>> {
let client = reqwest::Client::new();
let req = client
@ -246,7 +249,7 @@ pub async fn get_schedule_date(date: NaiveDate) -> Option<Vec<ViaplayEvent>> {
result
}
#[cached(time = 3600)]
#[cached(time = 7200)]
pub async fn get_sports() -> Vec<String> {
// let events = get_schedule();
if let Some(events) = get_schedule().await {
@ -269,7 +272,7 @@ async fn autocomplete_sport<'a>(
.map(|name| name.to_string())
}
//Viaplay events listing
/// Viaplay schedule for the day
#[poise::command(slash_command, ephemeral)]
pub async fn viaplay(
ctx: Context<'_>,
@ -309,7 +312,7 @@ pub async fn viaplay(
Ok(())
}
//Viaplay schedule for date
/// Viaplay schedule for specified date
#[poise::command(slash_command, ephemeral)]
pub async fn viaplay_schedule(
ctx: Context<'_>,

View file

@ -22,10 +22,6 @@ mod wrc_date {
#[derive(Deserialize)]
struct WRC {
// #[serde(rename = "earliestPlayableStart")]
// #[serde(with = "es_date_time")]
// earliest_playable_start: DateTime<Utc>,
// id: u32,
name: String,
#[serde(rename = "eventDays")]
days: Vec<WRCDays>,
@ -33,7 +29,6 @@ struct WRC {
#[derive(Deserialize)]
struct WRCDays {
// id: u32,
#[serde(rename = "eventDay")]
event_day: String,
#[serde(rename = "spottChannel")]
@ -42,20 +37,15 @@ struct WRCDays {
#[derive(Deserialize)]
struct WRCChannel {
// id: u32,
// #[serde(rename = "displayName")]
// name: String,
assets: Vec<WRCAssets>,
}
#[derive(Deserialize)]
struct WRCAssets {
// id: u32,
#[serde(with = "wrc_date")]
start: DateTime<Utc>,
#[serde(with = "wrc_date")]
end: DateTime<Utc>,
// duration: u32,
content: WRCContent,
}
@ -84,13 +74,10 @@ async fn get_schedule() -> Result<Option<WRC>, Error> {
}
}
// WRC sessions
/// WRC sessions
#[poise::command(slash_command, ephemeral)]
pub async fn wrc(
ctx: Context<'_>,
// #[description = "Filter sessions for when they are/were happening, defaults to future"]
// timeframe: Option<super::Timeframe>,
// #[description = "Content to filter on"] filter: Option<String>,
) -> Result<(), Error> {
let wrc = get_schedule().await?;
match wrc {

View file

@ -3,7 +3,6 @@ use poise::serenity_prelude as serenity;
pub mod invites;
mod links;
// pub mod planning;
pub mod coms;
pub mod roles;
pub mod schedule;
@ -30,7 +29,6 @@ pub async fn boop(ctx: Context<'_>) -> Result<(), Error> {
let mut boop_count: i32 = 0;
while let Some(mci) = serenity::CollectComponentInteraction::new(ctx)
.channel_id(ctx.channel_id())
// .timeout(std::time::Duration::from_secs(1200))
.filter(move |mci| mci.data.custom_id == uuid_boop.to_string())
.await
{
@ -70,7 +68,7 @@ pub async fn boop(ctx: Context<'_>) -> Result<(), Error> {
Ok(())
}
// Imaginary fix button
/// Imaginary fix button
#[poise::command(track_edits, slash_command)]
pub async fn fix(ctx: Context<'_>) -> Result<(), Error> {
let uuid_fix = ctx.id();
@ -92,7 +90,6 @@ pub async fn fix(ctx: Context<'_>) -> Result<(), Error> {
let mut fix_count: i32 = 0;
while let Some(mci) = serenity::CollectComponentInteraction::new(ctx)
.channel_id(ctx.channel_id())
// .timeout(std::time::Duration::from_secs(1200))
.filter(move |mci| mci.data.custom_id == uuid_fix.to_string())
.await
{
@ -116,14 +113,5 @@ pub async fn fix(ctx: Context<'_>) -> Result<(), Error> {
pub fn get_links(
) -> poise::Command<super::Data, Box<(dyn std::error::Error + std::marker::Send + Sync + 'static)>>
{
// poise::Command {
// subcommands: vec![
// links::eurosport::eurosport(),
// links::eurosport::olympics(),
// links::links(),
// // Let's make sure poise isn't confused by the duplicate names!
// ],
// ..links::links()
// };
links::links()
}