Diff
Logged in as anonymous

Differences From Artifact [18dde9282c]:

To Artifact [7f927a15c1]:


15
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

39
40
41
42
43
44
45
15
16
17
18
19
20
21

22




23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42







-
+
-
-
-
-












+







use async_compat::Compat;
use chrono::{
	DateTime,
	Local,
};
use lazy_static::lazy_static;
use regex::Regex;
use reqwest::header::{
use reqwest::header::LAST_MODIFIED;
	CACHE_CONTROL,
	EXPIRES,
	LAST_MODIFIED
};
use smol::{
	Timer,
	lock::Mutex,
};
use tgbot::{
	api::Client,
	handler::UpdateHandler,
	types::{
		Bot,
		ChatPeerId,
		Command,
		GetBot,
		InputText,
		Message,
		ParseMode,
		SendMessage,
		Update,
		UpdateType,
		UserPeerId,
	},
190
191
192
193
194
195
196
197
198


199
200
201
202
203
204
205
187
188
189
190
191
192
193


194
195
196
197
198
199
200
201
202







-
-
+
+







	pub async fn send <S>(&self, msg: S, target: Option<ChatPeerId>, mode: Option<ParseMode>) -> Result<Message>
	where S: Into<String> {
		let msg = msg.into();

		let mode = mode.unwrap_or(ParseMode::Html);
		let target = target.unwrap_or(self.owner_chat);
		self.tg.execute(
			SendMessage::new(target, msg)
				.with_parse_mode(mode)
			SendMessage::new(target, InputText::from(msg)
				.with_format(mode))
		).await.stack()
	}

	/// Fetches the feed for a source, sends any newly discovered posts to the appropriate chat, and records them in the database.
	///
	/// This acquires a per-source guard to prevent concurrent checks for the same `id`. If a check is already running for
	/// the given `id`, the function returns an error. If `last_scrape` is provided, it is sent as the `If-Modified-Since`
397
398
399
400
401
402
403
404
405


406
407
408
409
410
411
394
395
396
397
398
399
400


401
402
403
404
405
406
407
408







-
-
+
+






					"/add" | "/update" => command::update(self, command, msg, words).await,
					any => Err(anyhow!("Unknown command: {any}")),
				};
				if let Err(err) = res {
					if let Err(err2) = self.send(format!("\\#error\n```\n{err}\n```"),
						Some(msg.chat.get_id()),
						Some(ParseMode::MarkdownV2)
					).await{
						dbg!(err2);
					).await {
						let _ = dbg!(err2);
					};
				}
			};
		};
	}
}