Diff
Logged in as anonymous

Differences From Artifact [11c299d7be]:

To Artifact [bdc185bc57]:


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
62
63
64
65
66
67
68
69
70
71

pub async fn start(core: &Core, chat_id: i64) -> Result<()> {
	core.send("We are open\\. Probably\\. Visit [channel](https://t.me/rsstg_bot_help/3) for details\\.",
		Some(chat_id), Some(ParseMode::MarkdownV2)).await?;
	Ok(())
}

pub async fn list(core: &Core, sender: i64) -> Result<()> {

	core.send(core.list(sender).await?, Some(sender), Some(ParseMode::MarkdownV2)).await?;
	Ok(())
}

pub async fn command(core: &Core, sender: i64, command: Vec<&str>) -> Result<()> {

	if command.len() >= 2 {
		let msg: Cow<str> = match &command[1].parse::<i32>() {
			Err(err) => format!("I need a number.\n{}", &err).into(),
			Ok(number) => match command[0] {
				"/check" => core.check(number, sender, false).await
					.context("Channel check failed.")?,
				"/clean" => core.clean(number, sender).await?,
				"/enable" => core.enable(number, sender).await?.into(),
				"/delete" => core.delete(number, sender).await?,
				"/disable" => core.disable(number, sender).await?.into(),
				_ => bail!("Command {} not handled.", &command[0]),
			},
		};
		core.send(msg, Some(sender), None).await?;
	} else {
		core.send("This command needs a number.", Some(sender), None).await?;
	}
	Ok(())
}

pub async fn update(core: &Core, sender: i64, command: Vec<&str>) -> Result<()> {
	let mut source_id: Option<i32> = None;
	let at_least = "Requires at least 3 parameters.";
	let mut i_command = command.iter();
	let first_word = i_command.next().context(at_least)?;
	match *first_word {
		"/update" => {
			let next_word = i_command.next().context(at_least)?;







|
>
|



|
>





|
|
|
|
|










|







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
62
63
64
65
66
67
68
69
70
71
72
73

pub async fn start(core: &Core, chat_id: i64) -> Result<()> {
	core.send("We are open\\. Probably\\. Visit [channel](https://t.me/rsstg_bot_help/3) for details\\.",
		Some(chat_id), Some(ParseMode::MarkdownV2)).await?;
	Ok(())
}

pub async fn list(core: &mut Core, sender: i64) -> Result<()> {
	let msg = core.list(sender).await?;
	core.send(msg, Some(sender), Some(ParseMode::MarkdownV2)).await?;
	Ok(())
}

pub async fn command(core: &mut Core, sender: i64, command: Vec<&str>) -> Result<()> {
	let mut conn = core.db.begin().await?;
	if command.len() >= 2 {
		let msg: Cow<str> = match &command[1].parse::<i32>() {
			Err(err) => format!("I need a number.\n{}", &err).into(),
			Ok(number) => match command[0] {
				"/check" => core.check(number, sender, false).await
					.context("Channel check failed.")?.into(),
				"/clean" => conn.clean(*number, sender).await?,
				"/enable" => conn.enable(*number, sender).await?.into(),
				"/delete" => conn.delete(*number, sender).await?,
				"/disable" => conn.disable(*number, sender).await?.into(),
				_ => bail!("Command {} not handled.", &command[0]),
			},
		};
		core.send(msg, Some(sender), None).await?;
	} else {
		core.send("This command needs a number.", Some(sender), None).await?;
	}
	Ok(())
}

pub async fn update(core: &mut Core, sender: i64, command: Vec<&str>) -> Result<()> {
	let mut source_id: Option<i32> = None;
	let at_least = "Requires at least 3 parameters.";
	let mut i_command = command.iter();
	let first_word = i_command.next().context(at_least)?;
	match *first_word {
		"/update" => {
			let next_word = i_command.next().context(at_least)?;
131
132
133
134
135
136
137

138
139
140
		};
		if member_id == sender {
			user = true;
		};
	};
	if ! me   { bail!("I need to be admin on that channel."); };
	if ! user { bail!("You should be admin on that channel."); };

	core.send(core.update(source_id, channel, channel_id, url, iv_hash, url_re, sender).await?, Some(sender), None).await?;
	Ok(())
}







>
|


133
134
135
136
137
138
139
140
141
142
143
		};
		if member_id == sender {
			user = true;
		};
	};
	if ! me   { bail!("I need to be admin on that channel."); };
	if ! user { bail!("You should be admin on that channel."); };
	let mut conn = core.db.begin().await?;
	core.send(conn.update(source_id, channel, channel_id, url, iv_hash, url_re, sender).await?, Some(sender), None).await?;
	Ok(())
}