Website: Android screenshots first for a visitor on Android
Some checks are pending
CI / check (push) Waiting to run
CI / windows-build (push) Waiting to run
CI / macos-build (push) Waiting to run

Seven phone screens one by one (home with a put-aside game, a database's
games, the Opera game, Stockfish, the play sheet, «Who to play», a game
against Rodent IV) open the gallery and the lightbox on Android, under «On
the phone», before «On the computer»; the hero shows the four phone screens.
Other visitors see the page as before. Nine languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-27 15:47:09 +03:00
parent 20d9d018bb
commit 12e4c7d5e9
59 changed files with 645 additions and 82 deletions

View file

@ -16,7 +16,9 @@ pub struct Bot {
impl Bot {
pub fn from_env() -> Option<Arc<Bot>> {
let token = std::env::var("TELEGRAM_TOKEN").ok().filter(|t| !t.is_empty())?;
let token = std::env::var("TELEGRAM_TOKEN")
.ok()
.filter(|t| !t.is_empty())?;
let chat = std::env::var("TELEGRAM_CHAT").ok()?.trim().parse().ok()?;
let http = reqwest::Client::builder()
.user_agent("chesspenguin-site")
@ -43,7 +45,13 @@ impl Bot {
"text": text,
"disable_web_page_preview": true,
});
match self.http.post(self.url("sendMessage")).json(&body).send().await {
match self
.http
.post(self.url("sendMessage"))
.json(&body)
.send()
.await
{
Ok(r) if !r.status().is_success() => eprintln!("telegram: {}", r.status()),
Err(e) => eprintln!("telegram: {}", e.without_url()),
_ => {}
@ -56,7 +64,10 @@ impl Bot {
loop {
let got = self
.http
.get(format!("{}?timeout=50&offset={offset}", self.url("getUpdates")))
.get(format!(
"{}?timeout=50&offset={offset}",
self.url("getUpdates")
))
.send()
.await;
let updates: Value = match got {
@ -84,7 +95,12 @@ impl Bot {
continue;
}
// "/stat", "/stat@chessPenguin_bot".
let command = m["text"].as_str().unwrap_or("").split(['@', ' ']).next().unwrap_or("");
let command = m["text"]
.as_str()
.unwrap_or("")
.split(['@', ' '])
.next()
.unwrap_or("");
if let Some(text) = answer(command) {
self.send_now(&text).await;
}
@ -125,7 +141,10 @@ mod tests {
assert_eq!(flag(Some("kz")), "🇰🇿");
assert_eq!(flag(None), "");
assert_eq!(flag(Some("—")), "");
assert_eq!(place(Some("RU"), Some("Moscow"), Some("Moscow")), "🇷🇺 Moscow");
assert_eq!(
place(Some("RU"), Some("Moscow"), Some("Moscow")),
"🇷🇺 Moscow"
);
assert_eq!(place(Some("UZ"), None, None), "🇺🇿 UZ");
assert_eq!(place(None, None, None), "");
}