Check-in [3dc9cddd4d]
Logged in as anonymous
Overview
Comment:v0.2.20: fix bug with sending wrong url in prev build, fix StreamExt, autodisable sources for users who blocked bot
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3dc9cddd4d641491d9a0db4fe9ca13b91ed84bad784ea7ce3adf193b7fb8d7d3
User & Date: arcade on 2023-08-04 16:19:21.893
Other Links: manifest | tags
Context
2023-10-04
07:36
bump check-in: 58da576b83 user: arcade tags: trunk
2023-08-04
16:19
v0.2.20: fix bug with sending wrong url in prev build, fix StreamExt, autodisable sources for users who blocked bot check-in: 3dc9cddd4d user: arcade tags: trunk
15:41
bump and rewrite all database access to macros check-in: 9910c2209c user: arcade tags: trunk
Changes
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
 "derive_builder 0.9.0",
 "quick-xml 0.17.2",
 "reqwest 0.9.24",
]

[[package]]
name = "rsstg"
version = "0.2.18"
dependencies = [
 "anyhow",
 "async-std",
 "atom_syndication",
 "chrono",
 "config",
 "futures 0.3.28",
 "futures-util",
 "lazy_static",
 "regex",
 "reqwest 0.11.18",
 "rss",
 "sedregex",
 "sqlx",







|






|







2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
 "derive_builder 0.9.0",
 "quick-xml 0.17.2",
 "reqwest 0.9.24",
]

[[package]]
name = "rsstg"
version = "0.2.19"
dependencies = [
 "anyhow",
 "async-std",
 "atom_syndication",
 "chrono",
 "config",
 "futures 0.1.31",
 "futures-util",
 "lazy_static",
 "regex",
 "reqwest 0.11.18",
 "rss",
 "sedregex",
 "sqlx",
1
2
3
4
5
6
7
8
9
10
[package]
name = "rsstg"
version = "0.2.19"
authors = ["arcade"]
edition = "2021"

[dependencies]
anyhow = "*"
async-std = { version = "*", features = [ "tokio1" ] }
atom_syndication = { version = "*", features = [ "with-serde" ] }


|







1
2
3
4
5
6
7
8
9
10
[package]
name = "rsstg"
version = "0.2.20"
authors = ["arcade"]
edition = "2021"

[dependencies]
anyhow = "*"
async-std = { version = "*", features = [ "tokio1" ] }
atom_syndication = { version = "*", features = [ "with-serde" ] }
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
					},
					rss::Error::Eof => (),
					_ => bail!("Unsupported or mangled content:\n{:?}\n{:#?}\n{:#?}\n", &source.url, err, status)
				}
			};
			for (date, url) in posts.iter() {
				let post_url: Cow<str> = match source.url_re {
					Some(ref x) => sedregex::ReplaceCommand::new(x)?.execute(&source.url),
					None => url.into(),
				};
				if let Some(exists) = sqlx::query!("select exists(select true from rsstg_post where url = $1 and source_id = $2) as exists;",
					&post_url, *id).fetch_one(&mut self.pool.acquire().await?).await?.exists {
					if ! exists {
						if this_fetch.is_none() || *date > this_fetch.unwrap() {
							this_fetch = Some(*date);







|







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
					},
					rss::Error::Eof => (),
					_ => bail!("Unsupported or mangled content:\n{:?}\n{:#?}\n{:#?}\n", &source.url, err, status)
				}
			};
			for (date, url) in posts.iter() {
				let post_url: Cow<str> = match source.url_re {
					Some(ref x) => sedregex::ReplaceCommand::new(x)?.execute(url),
					None => url.into(),
				};
				if let Some(exists) = sqlx::query!("select exists(select true from rsstg_post where url = $1 and source_id = $2) as exists;",
					&post_url, *id).fetch_one(&mut self.pool.acquire().await?).await?.exists {
					if ! exists {
						if this_fetch.is_none() || *date > this_fetch.unwrap() {
							this_fetch = Some(*date);
261
262
263
264
265
266
267

268
269
270
271
272
273
274
							owner_chat: telegram_bot::UserId::new(owner),
							..self.clone()
						};
						task::spawn(async move {
							if let Err(err) = clone.check(&source_id, owner, true).await {
								if let Err(err) = clone.send(&format!("🛑 {:?}", err), None, None).await {
									eprintln!("Check error: {}", err);

								};
							};
						});
					}
				} else if next_fetch - now < delay {
					delay = next_fetch - now;
				}







>







261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
							owner_chat: telegram_bot::UserId::new(owner),
							..self.clone()
						};
						task::spawn(async move {
							if let Err(err) = clone.check(&source_id, owner, true).await {
								if let Err(err) = clone.send(&format!("🛑 {:?}", 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;
				}
1
2
3
4
5
6
7
8
9
10
11
12
13
mod command;
mod core;

use anyhow::Result;
use async_std::task;
use futures::StreamExt;

fn main() -> Result<()> {
	let settings = config::Config::builder()
		.add_source(config::File::with_name("rsstg"))
		.build()?;

	let core = core::Core::new(settings)?;





|







1
2
3
4
5
6
7
8
9
10
11
12
13
mod command;
mod core;

use anyhow::Result;
use async_std::task;
use async_std::stream::StreamExt;

fn main() -> Result<()> {
	let settings = config::Config::builder()
		.add_source(config::File::with_name("rsstg"))
		.build()?;

	let core = core::Core::new(settings)?;