Diff
Logged in as anonymous

Differences From Artifact [1edeb585ee]:

To Artifact [4583236e80]:


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
	core.send(msg, Some(sender), None).await?;
	Ok(())
}

pub async fn update(core: &Core, sender: telegram_bot::UserId, command: Vec<&str>) -> Result<()> {
	let mut source_id: Option<i32> = None;
	let at_least = "Requires at least 3 parameters.";

	let first_word = command[0];
	let command = match first_word {
		"/update" => {

			source_id = Some(command[1].parse::<i32>()
				.context(format!("I need a number, but got {}.", command[1]))?);
			&command[2..]
		},
		"/add" => &command[1..],
		_ => bail!("Passing {} is not possible here.", command[1]),
	};
	let mut i_command = command.iter();
	let (channel, url, iv_hash, url_re) = (
		i_command.next().context(at_least)?,
		i_command.next().context(at_least)?,
		i_command.next(),
		i_command.next());
	if ! RE_USERNAME.is_match(channel) {
		bail!("Usernames should be something like \"@\\[a\\-zA\\-Z]\\[a\\-zA\\-Z0\\-9\\_]+\", aren't they?\nNot {:?}", &channel);







>
|
|

>
|
|
<

|
|

<







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
	core.send(msg, Some(sender), None).await?;
	Ok(())
}

pub async fn update(core: &Core, sender: telegram_bot::UserId, 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)?;
			source_id = Some(next_word.parse::<i32>()
				.context(format!("I need a number, but got {}.", next_word))?);

		},
		"/add" => {},
		_ => bail!("Passing {} is not possible here.", first_word),
	};

	let (channel, url, iv_hash, url_re) = (
		i_command.next().context(at_least)?,
		i_command.next().context(at_least)?,
		i_command.next(),
		i_command.next());
	if ! RE_USERNAME.is_match(channel) {
		bail!("Usernames should be something like \"@\\[a\\-zA\\-Z]\\[a\\-zA\\-Z0\\-9\\_]+\", aren't they?\nNot {:?}", &channel);