Check-in [cab82b7ff4]
Logged in as anonymous
Overview
Comment:fix parameter parsing
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cab82b7ff4131a780ac03155618eb9f60afccbd73b341b025c7dc207adc80c60
User & Date: arcade on 2022-03-23 16:26:50.356
Other Links: manifest | tags
Context
2022-04-19
07:00
0.2.11: command parsing fix and bump check-in: 6e8d042b97 user: arcade tags: trunk
2022-03-23
16:26
fix parameter parsing check-in: cab82b7ff4 user: arcade tags: trunk
2022-03-15
14:00
move to async, cut deps a little check-in: cb86e770f9 user: arcade tags: trunk
Changes
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
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 = command[0];
	let command = match first_word {
	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(command[1].parse::<i32>()
				.context(format!("I need a number, but got {}.", command[1]))?);
			source_id = Some(next_word.parse::<i32>()
				.context(format!("I need a number, but got {}.", next_word))?);
			&command[2..]
		},
		"/add" => &command[1..],
		_ => bail!("Passing {} is not possible here.", command[1]),
		"/add" => {},
		_ => bail!("Passing {} is not possible here.", first_word),
	};
	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);