Overview
Comment: | add more details on errors |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | v0.4.2 |
Files: | files | file ages | folders |
SHA3-256: |
b4af85e31b429eb5c80924a7d163af07 |
User & Date: | arcade on 2025-06-29 17:30:44.844 |
Other Links: | manifest | tags |
Context
2025-06-29
| ||
19:04 | fix error formatting Leaf check-in: 5a4aab7687 user: arcade tags: trunk, v0.4.3 | |
17:30 | add more details on errors check-in: b4af85e31b user: arcade tags: trunk, v0.4.2 | |
2025-06-28
| ||
17:48 | cleanup, fix words processing, switch to async primitives check-in: fae13a0e55 user: arcade tags: trunk, v0.4.1 | |
Changes
Modified Cargo.lock
from [256ee88146]
to [1993bbc09e].
︙ | ︙ | |||
2096 2097 2098 2099 2100 2101 2102 | "derive_builder", "never", "quick-xml", ] [[package]] name = "rsstg" | | | 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 | "derive_builder", "never", "quick-xml", ] [[package]] name = "rsstg" version = "0.4.2" dependencies = [ "anyhow", "async-std", "atom_syndication", "chrono", "config", "futures", |
︙ | ︙ | |||
2726 2727 2728 2729 2730 2731 2732 | "once_cell", "rustix 1.0.7", "windows-sys 0.59.0", ] [[package]] name = "tgbot" | | | | 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 | "once_cell", "rustix 1.0.7", "windows-sys 0.59.0", ] [[package]] name = "tgbot" version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f93a57a73ceda468ee27ccfa9ee21b35891d72ad0ea9c48ba24ca96621f25ca" dependencies = [ "async-stream", "bytes", "derive_more", "futures-util", "log", "mime", |
︙ | ︙ |
Modified Cargo.toml
from [c885bd9ec2]
to [f63b30eaa6].
1 2 | [package] name = "rsstg" | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | [package] name = "rsstg" version = "0.4.2" authors = ["arcade"] edition = "2021" [dependencies] anyhow = "1.0.86" async-std = { version = "1.12.0", features = [ "attributes", "tokio1" ] } atom_syndication = { version = "0.12.4", features = [ "with-serde" ] } chrono = "0.4.38" config = { version = "0.15", default-features = false, features = [ "toml" ] } tgbot = "0.38" futures = "0.3.30" futures-util = "0.3.30" lazy_static = "1.5.0" regex = "1.10.6" reqwest = { version = "0.12.7", features = [ "brotli", "socks", "deflate" ]} rss = "2.0.9" sedregex = "0.2.5" |
︙ | ︙ |
Modified src/core.rs
from [540899dcce]
to [a6ef31f33f].
︙ | ︙ | |||
197 198 199 200 201 202 203 204 205 206 | for row in queue { if let Some(next_fetch) = row.next_fetch { if next_fetch < now { if let (Some(owner), Some(source_id)) = (row.owner, row.source_id) { let clone = Core { owner_chat: ChatPeerId::from(owner), ..self.clone() }; task::spawn(async move { if let Err(err) = clone.check(source_id, true).await { | > > > > > > > > | | < < < < < < < < < | < | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | for row in queue { if let Some(next_fetch) = row.next_fetch { if next_fetch < now { if let (Some(owner), Some(source_id)) = (row.owner, row.source_id) { let clone = Core { owner_chat: ChatPeerId::from(owner), ..self.clone() }; let source = { let mut conn = self.db.begin().await?; match conn.get_one(owner, source_id).await { Ok(Some(source)) => source.to_string(), Ok(None) => "Source not found in database?".to_string(), Err(err) => format!("Failed to fetch source data:\n{err}"), } }; task::spawn(async move { if let Err(err) = clone.check(source_id, true).await { if let Err(err) = clone.send(&format!("{source}\nš {err:?}"), None, None).await { eprintln!("Check error: {err:?}"); // clone.disable(&source_id, owner).await.unwrap(); }; }; }); } } else if next_fetch - now < delay { delay = next_fetch - now; } } }; Ok(delay.to_std()?) } pub async fn list (&self, owner: UserPeerId) -> Result<String> { let mut reply: Vec<String> = vec![]; reply.push("Channels:".into()); let mut conn = self.db.begin().await?; for row in conn.get_list(owner).await? { reply.push(row.to_string()); }; Ok(reply.join("\n\n")) } } impl UpdateHandler for Core { async fn handle (&self, update: Update) { if let UpdateType::Message(msg) = update.update_type { if let Ok(cmd) = Command::try_from(msg) { |
︙ | ︙ |
Modified src/sql.rs
from [2fd09e58c3]
to [ae3b49a367].
|
| | > > > | 1 2 3 4 5 6 7 8 9 10 11 | use std::{ borrow::Cow, fmt, }; use anyhow::{ Result, bail, }; use async_std::sync::{ Arc, |
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | pub source_id: i32, pub channel: String, pub enabled: bool, pub url: String, pub iv_hash: Option<String>, pub url_re: Option<String>, } #[derive(sqlx::FromRow, Debug)] pub struct Source { pub channel_id: i64, pub url: String, pub iv_hash: Option<String>, pub owner: i64, | > > > > > > > > > > > > > > > > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | pub source_id: i32, pub channel: String, pub enabled: bool, pub url: String, pub iv_hash: Option<String>, pub url_re: Option<String>, } impl fmt::Display for List { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { write!(f, "\\#ļøā£ {} \\*ļøā£ `{}` {}\nš `{}`", self.source_id, self.channel, match self.enabled { true => "š enabled", false => "ā disabled", }, self.url)?; if let Some(iv_hash) = &self.iv_hash { write!(f, "\nIV: `{iv_hash}`")?; } if let Some(url_re) = &self.url_re { write!(f, "\nRE: `{url_re}`")?; } Ok(()) } } #[derive(sqlx::FromRow, Debug)] pub struct Source { pub channel_id: i64, pub url: String, pub iv_hash: Option<String>, pub owner: i64, |
︙ | ︙ | |||
154 155 156 157 158 159 160 161 162 163 164 165 166 167 | pub async fn get_list <I> (&mut self, owner: I) -> Result<Vec<List>> where I: Into<i64> { let source: Vec<List> = sqlx::query_as("select source_id, channel, enabled, url, iv_hash, url_re from rsstg_source where owner = $1 order by source_id") .bind(owner.into()) .fetch_all(&mut *self.conn).await?; Ok(source) } pub async fn get_source <I> (&mut self, id: i32, owner: I) -> Result<Source> where I: Into<i64> { let source: Source = sqlx::query_as("select channel_id, url, iv_hash, owner, url_re from rsstg_source where source_id = $1 and owner = $2") .bind(id) .bind(owner.into()) .fetch_one(&mut *self.conn).await?; | > > > > > > > > > | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | pub async fn get_list <I> (&mut self, owner: I) -> Result<Vec<List>> where I: Into<i64> { let source: Vec<List> = sqlx::query_as("select source_id, channel, enabled, url, iv_hash, url_re from rsstg_source where owner = $1 order by source_id") .bind(owner.into()) .fetch_all(&mut *self.conn).await?; Ok(source) } pub async fn get_one <I> (&mut self, owner: I, id: i32) -> Result<Option<List>> where I: Into<i64> { let source: Option<List> = sqlx::query_as("select source_id, channel, enabled, url, iv_hash, url_re from rsstg_source where owner = $1 and source_id = $2") .bind(owner.into()) .bind(id) .fetch_optional(&mut *self.conn).await?; Ok(source) } pub async fn get_source <I> (&mut self, id: i32, owner: I) -> Result<Source> where I: Into<i64> { let source: Source = sqlx::query_as("select channel_id, url, iv_hash, owner, url_re from rsstg_source where source_id = $1 and owner = $2") .bind(id) .bind(owner.into()) .fetch_one(&mut *self.conn).await?; |
︙ | ︙ |