From 54b15027a8017fa26e2aa62f15046c91158ff997 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 30 Nov 2024 14:39:46 +0100 Subject: [PATCH] hoooooooly cow --- holycow_backend/src/routes/matches.rs | 15 +++++---- .../src/app/[telegramId]/report/page.tsx | 1 - holycow_frontend/src/app/layout.css | 8 +++++ holycow_frontend/src/components/ReportBox.tsx | 32 +++++++++---------- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/holycow_backend/src/routes/matches.rs b/holycow_backend/src/routes/matches.rs index e33d1ff..eac8e96 100644 --- a/holycow_backend/src/routes/matches.rs +++ b/holycow_backend/src/routes/matches.rs @@ -5,7 +5,7 @@ use serde::Deserialize; use skillratings::weng_lin::WengLinConfig; use teloxide::Bot; use teloxide::requests::Requester; -use teloxide::types::{ChatId, MessageId, ThreadId}; +use teloxide::types::{ChatId, MessageId, ParseMode, ThreadId}; use crate::config; use crate::database::model::{Match, MatchI, Outcome, Player, WengLinRating}; @@ -33,6 +33,7 @@ pub struct MatchII { fn player_to_text(player: &Player, before: &WengLinRating, after: &WengLinRating) -> String { let name = &player.username; let competitive = &player.competitive; + let telegram_id = &player.telegram_id; match competitive { false => { @@ -43,7 +44,7 @@ fn player_to_text(player: &Player, before: &WengLinRating, after: &WengLinRating let after = after.human_score(); let change = after - before; - format!("{name} ({change})") + format!(r#"{name} ({change:+})"#) }, } } @@ -58,12 +59,12 @@ fn match_to_text(r#match: &Match, player_a: &Player, player_b: &Player) -> Strin None => format!("🔵 {player_a} ha trionfato su {player_b}!"), }, Outcome::BWins => match &r#match.name { - Some(name) => format!("⚪️ {player_a} è stato sconfitto da {player_b} in {name}!"), - None => format!("⚪️ {player_a} è stato sconfitto da {player_b}!"), + Some(name) => format!("🟠 {player_a} è stato sconfitto da {player_b} in {name}!"), + None => format!("🟠 {player_a} è stato sconfitto da {player_b}!"), }, Outcome::Tie => match &r#match.name { - Some(name) => format!("🟠 {player_a} e {player_b} hanno pareggiato in {name}!"), - None => format!("🟠 {player_a} e {player_b} hanno pareggiato!"), + Some(name) => format!("⚪️ {player_a} e {player_b} hanno pareggiato in {name}!"), + None => format!("⚪️ {player_a} e {player_b} hanno pareggiato!"), }, } } @@ -141,6 +142,8 @@ pub async fn post_match( let chat = ChatId(*chat); let mut send_message_future = bot.send_message(chat, match_to_text(&r#match, &player_a, &player_b)); + send_message_future.parse_mode = Some(ParseMode::Html); + let topic = config::TELEGRAM_NOTIFICATION_TOPIC_ID(); if let Some(topic) = topic { let topic = MessageId(*topic); diff --git a/holycow_frontend/src/app/[telegramId]/report/page.tsx b/holycow_frontend/src/app/[telegramId]/report/page.tsx index ce3ab82..05f5251 100644 --- a/holycow_frontend/src/app/[telegramId]/report/page.tsx +++ b/holycow_frontend/src/app/[telegramId]/report/page.tsx @@ -1,4 +1,3 @@ -import {ReportBox} from "@/components/ReportBox" import {ReportBoxInteractive} from "@/components/ReportBoxInteractive" import {PlayerO} from "@/holycow" diff --git a/holycow_frontend/src/app/layout.css b/holycow_frontend/src/app/layout.css index 2e0e87a..7a167a5 100644 --- a/holycow_frontend/src/app/layout.css +++ b/holycow_frontend/src/app/layout.css @@ -6,6 +6,14 @@ nextjs-portal { position: absolute; } +hr { + margin: 0.5em 0; +} + +.separator-lightest { + border-color: hsl(var(--bhsl-current-hue) var(--bhsl-current-saturation) var(--bhsl-current-lightness) / .05); +} + :where(body) :where(.form-flex) > :where(.form-flex-choice, label) > :where(*) { /* TODO: Fix in bluelib */ align-items: center; diff --git a/holycow_frontend/src/components/ReportBox.tsx b/holycow_frontend/src/components/ReportBox.tsx index 51e1389..702ac4e 100644 --- a/holycow_frontend/src/components/ReportBox.tsx +++ b/holycow_frontend/src/components/ReportBox.tsx @@ -38,16 +38,22 @@ export function ReportBox({players, playerA, playerB, setPlayerB, outcome, setOu

Registra risultato

-

+
+ +
-

+
- Risultato + Ris.
-

- -

+