Diff
Logged in as anonymous

Differences From Artifact [3d73f41850]:

To Artifact [08ae8be400]:


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

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
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
59
60
61
-

+
+
+
+
+
+




+
+
+
+
+
+
+
+
+
+
+
+
+
+







+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+



-
+







use anyhow::{bail, Context, Result};
use crate::core::Core;

use anyhow::{
	bail,
	Context,
	Result
};
use lazy_static::lazy_static;
use regex::Regex;
use sedregex::ReplaceCommand;
use std::borrow::Cow;
use teloxide::{
	Bot,
	dispatching::dialogue::GetChatId,
	payloads::GetChatAdministrators,
	requests::{
		Requester,
		ResponseResult
	},
	types::{
		Message,
		UserId,
	},
	utils::command::BotCommands,
};

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();
}

#[derive(BotCommands, Clone)]
#[command(rename_rule = "lowercase", description = "Supported commands:")]
enum Command {
	#[command(description = "display this help.")]
	Help,
	#[command(description = "Does nothing.")]
	Start,
	#[commant(description = "List active subscriptions.")]
	List,
}
pub async fn start(core: &Core, sender: telegram_bot::UserId) -> Result<()> {
	core.send("We are open. Probably. Visit [channel](https://t.me/rsstg_bot_help/3) for details.", Some(sender), None).await?;

pub async fn cmd_handler(bot: Bot, msg: Message, cmd: Command) -> ResponseResult<()> {
	match cmd {
		Command::Help => bot.send_message(msg.chat.id, Command::descriptions().to_string()).await?,
		Command::Start => bot.send_message(msg.chat.id,
			"We are open. Probably. Visit [channel](https://t.me/rsstg_bot_help/3) for details.").await?,
		Command::List => bot.send_message(msg.chat.id, core.list(msg.from).await?).await?,
	};
	Ok(())
}

pub async fn list(core: &Core, sender: telegram_bot::UserId) -> Result<()> {
pub async fn list(core: &Core, sender: UserId) -> Result<()> {
	core.send(core.list(sender).await?, Some(sender), Some(telegram_bot::types::ParseMode::MarkdownV2)).await?;
	Ok(())
}

pub async fn command(core: &Core, sender: telegram_bot::UserId, command: Vec<&str>) -> Result<()> {
	if command.len() >= 2 {
		let msg: Cow<str> = match &command[1].parse::<i32>() {