Diff
Logged in as anonymous

Differences From Artifact [28430d049a]:

To Artifact [a915a95027]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23






24
25
26
27
28
29
30
use crate::{
	command,
	sql::Db,
};

use std::{
	borrow::Cow,
	collections::{
		BTreeMap,
		HashSet,
	},
	sync::{
		Arc,
		Mutex
	},
};

use anyhow::{
	anyhow,
	bail,
	Result,
};
use async_std::task;






use chrono::DateTime;
use lazy_static::lazy_static;
use regex::Regex;
use tgbot::{
	api::Client,
	handler::UpdateHandler,
	types::{











<
<
<
<







|
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11




12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::{
	command,
	sql::Db,
};

use std::{
	borrow::Cow,
	collections::{
		BTreeMap,
		HashSet,
	},




};

use anyhow::{
	anyhow,
	bail,
	Result,
};
use async_std::{
	task,
	sync::{
		Arc,
		Mutex
	},
};
use chrono::DateTime;
use lazy_static::lazy_static;
use regex::Regex;
use tgbot::{
	api::Client,
	handler::UpdateHandler,
	types::{
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
	}

	pub async fn check (&self, id: i32, real: bool) -> Result<String> {
		let mut posted: i32 = 0;
		let mut conn = self.db.begin().await?;

		let id = {
			let mut set = self.sources.lock().unwrap();
			match set.get(&id) {
				Some(id) => id.clone(),
				None => {
					let id = Arc::new(id);
					set.insert(id.clone());
					id.clone()
				},







|







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
	}

	pub async fn check (&self, id: i32, real: bool) -> Result<String> {
		let mut posted: i32 = 0;
		let mut conn = self.db.begin().await?;

		let id = {
			let mut set = self.sources.lock_arc().await;
			match set.get(&id) {
				Some(id) => id.clone(),
				None => {
					let id = Arc::new(id);
					set.insert(id.clone());
					id.clone()
				},
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
								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šŸ›‘ {}", encode(&err.to_string())), None, Some(ParseMode::MarkdownV2)).await {
									eprintln!("Check error: {err:?}");
									// clone.disable(&source_id, owner).await.unwrap();
								};
							};
						});
					}
				} else if next_fetch - now < delay {







|







221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
								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\nšŸ›‘ {}", encode(&err.to_string())), None, Some(ParseMode::MarkdownV2)).await {
									eprintln!("Check error: {err:?}");
									// clone.disable(&source_id, owner).await.unwrap();
								};
							};
						});
					}
				} else if next_fetch - now < delay {