Check-in [b2b8005309]
Logged in as anonymous
Overview
Comment:log errors to user
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b2b8005309a68cb9af9bf53c7ae93fcedb422e8e6c5cfdb9a07058f369ae8a16
User & Date: arcade on 2020-12-18 19:15:56.282
Other Links: manifest | tags
Context
2021-01-22
13:11
0.1.15: just build changes check-in: f5365bf71c user: arcade tags: trunk
2020-12-18
19:15
log errors to user check-in: b2b8005309 user: arcade tags: trunk
2020-12-15
14:40
0.1.13: fix error handling from stream, fix messages check-in: a68576cc1b user: arcade tags: trunk
Changes
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480

[[package]]
name = "crypto-mac"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "subtle 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "darling"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [







|







466
467
468
469
470
471
472
473
474
475
476
477
478
479
480

[[package]]
name = "crypto-mac"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "subtle 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "darling"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
 "h2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
 "http 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "httpdate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
 "pin-project 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "socket2 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
 "tokio 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
 "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "tracing 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]







|







984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
 "h2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
 "http 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "httpdate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "itoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
 "pin-project 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "socket2 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
 "tokio 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
 "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "tracing 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
 "want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
[[package]]
name = "rsstg"
version = "0.1.13"
dependencies = [
 "anyhow 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
 "chrono 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
 "config 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "futures 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
 "futures-util 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "regex 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "rss 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "sqlx 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "telegram-bot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "tokio 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",







|







1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
[[package]]
name = "rsstg"
version = "0.1.13"
dependencies = [
 "anyhow 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
 "chrono 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
 "config 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "futures 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
 "futures-util 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "regex 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "rss 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "sqlx 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "telegram-bot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "tokio 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
[[package]]
name = "smallvec"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "socket2"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.81 (registry+https://github.com/rust-lang/crates.io-index)",
 "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)",
 "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "sqlformat"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"







|




<







2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109

2110
2111
2112
2113
2114
2115
2116
[[package]]
name = "smallvec"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "socket2"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "libc 0.2.81 (registry+https://github.com/rust-lang/crates.io-index)",

 "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "sqlformat"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
[[package]]
name = "strsim"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "subtle"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "syn"
version = "1.0.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [







|







2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
[[package]]
name = "strsim"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "subtle"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "syn"
version = "1.0.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
"checksum sha2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8"
"checksum signal-hook 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed"
"checksum signal-hook-registry 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab"
"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6"
"checksum smallvec 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75"
"checksum socket2 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902"
"checksum sqlformat 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "74c70f0235b9925cbb106c52af1a28b5ea4885a8b851e328b8562e257a389c2d"
"checksum sqlx 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d1f8eb788e1733bdbf69a8f97087213ebdebd253d4782c686d3cfd586b0a9453"
"checksum sqlx-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e647268dc1239dd9db2d3103fefd61151971a2214882cff9efea6f60cf50840"
"checksum sqlx-macros 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7acd32cba35531345f8a94a038874baf00efd0b701c913f5b00d2870b474b64"
"checksum sqlx-rt 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63fc5454c9dd7aaea3a0eeeb65ca40d06d0d8e7413a8184f7c3a3ffa5056190b"
"checksum static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
"checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d"
"checksum stringprep 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1"
"checksum strsim 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
"checksum subtle 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd"
"checksum syn 1.0.54 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44"
"checksum synstructure 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
"checksum tap 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36474e732d1affd3a6ed582781b3683df3d0563714c59c39591e8ff707cf078e"
"checksum telegram-bot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc9552e972bcb551705fcad45bd0b86eca12a22379db36cdfa6d053e1a19b2de"
"checksum telegram-bot-raw 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e4fc120e2b85d639fc932a4aa7c1b6a5f1189fb86948d7a02037d1d8f1ef559"
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
"checksum thiserror 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e"







|









|







3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
"checksum sha2 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8"
"checksum signal-hook 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed"
"checksum signal-hook-registry 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab"
"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6"
"checksum smallvec 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75"
"checksum socket2 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "97e0e9fd577458a4f61fb91fcb559ea2afecc54c934119421f9f5d3d5b1a1057"
"checksum sqlformat 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "74c70f0235b9925cbb106c52af1a28b5ea4885a8b851e328b8562e257a389c2d"
"checksum sqlx 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d1f8eb788e1733bdbf69a8f97087213ebdebd253d4782c686d3cfd586b0a9453"
"checksum sqlx-core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e647268dc1239dd9db2d3103fefd61151971a2214882cff9efea6f60cf50840"
"checksum sqlx-macros 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7acd32cba35531345f8a94a038874baf00efd0b701c913f5b00d2870b474b64"
"checksum sqlx-rt 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63fc5454c9dd7aaea3a0eeeb65ca40d06d0d8e7413a8184f7c3a3ffa5056190b"
"checksum static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
"checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d"
"checksum stringprep 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1"
"checksum strsim 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
"checksum subtle 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
"checksum syn 1.0.54 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44"
"checksum synstructure 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701"
"checksum tap 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36474e732d1affd3a6ed582781b3683df3d0563714c59c39591e8ff707cf078e"
"checksum telegram-bot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc9552e972bcb551705fcad45bd0b86eca12a22379db36cdfa6d053e1a19b2de"
"checksum telegram-bot-raw 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e4fc120e2b85d639fc932a4aa7c1b6a5f1189fb86948d7a02037d1d8f1ef559"
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
"checksum thiserror 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e"
1
2
3
4
5
6
7
8
9
10
[package]
name = "rsstg"
version = "0.1.13"
authors = ["arcade"]
edition = "2018"

[dependencies]
chrono = "*"
config = "*"
futures = "*"


|







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

[dependencies]
chrono = "*"
config = "*"
futures = "*"
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71



72
73
74
75
76
77
78
				.idle_timeout(std::time::Duration::new(60, 0))
				.connect_lazy(&settings.get_str("pg")?)?,
			sources: Arc::new(Mutex::new(HashSet::new())),
		};
		let clone = core.clone();
		tokio::spawn(async move {
			if let Err(err) = &clone.autofetch().await {
				if let Err(err) = clone.debug(&format!("🛑 {:?}", err)) {
					eprintln!("Autofetch error: {}", err);
				};
			}
		});
		Ok(core)
	}

	fn stream(&self) -> telegram_bot::UpdatesStream {
		self.tg.stream()
	}

	fn debug(&self, msg: &str) -> Result<()> {
		self.tg.spawn(SendMessage::new(self.owner_chat, msg));



		Ok(())
	}

	async fn check<S>(&self, id: i32, owner: S, real: bool) -> Result<()>
	where S: Into<i64> {
		let owner: i64 = owner.into();
		let id = {







|











|
|
>
>
>







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
				.idle_timeout(std::time::Duration::new(60, 0))
				.connect_lazy(&settings.get_str("pg")?)?,
			sources: Arc::new(Mutex::new(HashSet::new())),
		};
		let clone = core.clone();
		tokio::spawn(async move {
			if let Err(err) = &clone.autofetch().await {
				if let Err(err) = clone.debug(&format!("🛑 {:?}", err), None) {
					eprintln!("Autofetch error: {}", err);
				};
			}
		});
		Ok(core)
	}

	fn stream(&self) -> telegram_bot::UpdatesStream {
		self.tg.stream()
	}

	fn debug(&self, msg: &str, target: Option<UserId>) -> Result<()> {
		self.tg.spawn(SendMessage::new(match target {
			Some(user) => user,
			None => self.owner_chat,
		}, msg));
		Ok(())
	}

	async fn check<S>(&self, id: i32, owner: S, real: bool) -> Result<()>
	where S: Into<i64> {
		let owner: i64 = owner.into();
		let id = {
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
					//clone.owner_chat(UserId::new(owner));
					let clone = Core {
						owner_chat: UserId::new(owner),
						..self.clone()
					};
					tokio::spawn(async move {
						if let Err(err) = clone.check(source_id, owner, true).await {
							if let Err(err) = clone.debug(&format!("🛑 {:?}", err)) {
								eprintln!("Check error: {}", err);
							};
						};
					});
				} else {
					if next_fetch - now < delay {
						delay = next_fetch - now;







|







281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
					//clone.owner_chat(UserId::new(owner));
					let clone = Core {
						owner_chat: UserId::new(owner),
						..self.clone()
					};
					tokio::spawn(async move {
						if let Err(err) = clone.check(source_id, owner, true).await {
							if let Err(err) = clone.debug(&format!("🛑 {:?}", err), None) {
								eprintln!("Check error: {}", err);
							};
						};
					});
				} else {
					if next_fetch - now < delay {
						delay = next_fetch - now;
332
333
334
335
336
337
338

339
340

341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
async fn main() -> Result<()> {
	let mut settings = config::Config::default();
	settings.merge(config::File::with_name("rsstg"))?;

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

	let mut stream = core.stream();


	loop {

		match stream.next().await {
			Some(update) => {
				if let Err(err) = handle(update?, &core).await {
					core.debug(&format!("🛑 {:?}", err))?;
				};
			},
			None => {
				core.debug(&format!("🛑 None error."))?;
			}
		};
	}

	//Ok(())
}

async fn handle(update: telegram_bot::Update, core: &Core) -> Result<()> {
	lazy_static! {
		static ref RE_USERNAME: Regex = Regex::new(r"^@[a-zA-Z][a-zA-Z0-9_]+$").unwrap();
		static ref RE_LINK: Regex = Regex::new(r"^https?://[a-zA-Z.0-9-]+/[-_a-zA-Z.0-9/?=]+$").unwrap();
		static ref RE_IV_HASH: Regex = Regex::new(r"^[a-f0-9]{14}$").unwrap();
	}

	match update.kind {







>


>


|
|



|







|







335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
async fn main() -> Result<()> {
	let mut settings = config::Config::default();
	settings.merge(config::File::with_name("rsstg"))?;

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

	let mut stream = core.stream();
	let mut reply_to: Option<UserId>;

	loop {
		reply_to = None;
		match stream.next().await {
			Some(update) => {
				if let Err(err) = handle(update?, &core, &mut reply_to).await {
					core.debug(&format!("🛑 {:?}", err), reply_to)?;
				};
			},
			None => {
				core.debug(&format!("🛑 None error."), None)?;
			}
		};
	}

	//Ok(())
}

async fn handle(update: telegram_bot::Update, core: &Core, mut _reply_to: &Option<UserId>) -> Result<()> {
	lazy_static! {
		static ref RE_USERNAME: Regex = Regex::new(r"^@[a-zA-Z][a-zA-Z0-9_]+$").unwrap();
		static ref RE_LINK: Regex = Regex::new(r"^https?://[a-zA-Z.0-9-]+/[-_a-zA-Z.0-9/?=]+$").unwrap();
		static ref RE_IV_HASH: Regex = Regex::new(r"^[a-f0-9]{14}$").unwrap();
	}

	match update.kind {
380
381
382
383
384
385
386

387
388
389
390
391
392
393
						"/list" => {
							reply.append(&mut core.list(message.from.id).await?);
						},

// add

						"/add" | "/update" => {

							let mut source_id: Option<i32> = None;
							let at_least = "Requires at least 3 parameters.";
							if cmd == "/update" {
								let first_word = words.next()
									.context(at_least)?;
								source_id = Some(first_word.parse::<i32>()
									.with_context(|| format!("I need a number, but got {}.", first_word))?);







>







385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
						"/list" => {
							reply.append(&mut core.list(message.from.id).await?);
						},

// add

						"/add" | "/update" => {
							_reply_to = &Some(message.from.id);
							let mut source_id: Option<i32> = None;
							let at_least = "Requires at least 3 parameters.";
							if cmd == "/update" {
								let first_word = words.next()
									.context(at_least)?;
								source_id = Some(first_word.parse::<i32>()
									.with_context(|| format!("I need a number, but got {}.", first_word))?);