Diff
Logged in as anonymous

Differences From Artifact [86f4f1e85f]:

To Artifact [1ce7bd4b1f]:


65
66
67
68
69
70
71
72
73
74

75
76



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
	}
	let iv_hash = match iv_hash {
		Some(hash) => {
			if ! RE_IV_HASH.is_match(hash) {
				bail!("IV hash should be 14 hex digits.\nNot {:?}", hash);
			};
			Some(*hash)
		}
		None => None,
	};

	if let Some(rex) = url_re {
		let _url_rex = ReplaceCommand::new(rex).context("Regexp parsing error:")?;



	};
	let channel_id = i64::from(core.tg.send(telegram_bot::GetChat::new(telegram_bot::types::ChatRef::ChannelUsername(channel.to_string()))).await?.id());
	let chan_adm = core.tg.send(telegram_bot::GetChatAdministrators::new(telegram_bot::types::ChatRef::ChannelUsername(channel.to_string()))).await
		.context("Sorry, I have no access to that chat.")?;
	let (mut me, mut user) = (false, false);
	for admin in chan_adm {
		if admin.user.id == core.my.id {
			me = true;
		};
		if admin.user.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, None, sender).await?, Some(sender), None)?;
	Ok(())
}







|


>
|
|
>
>
>















|


65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
	}
	let iv_hash = match iv_hash {
		Some(hash) => {
			if ! RE_IV_HASH.is_match(hash) {
				bail!("IV hash should be 14 hex digits.\nNot {:?}", hash);
			};
			Some(*hash)
		},
		None => None,
	};
	let url_re = match url_re {
		Some(re) => {
			let _url_rex = ReplaceCommand::new(re).context("Regexp parsing error:")?;
			Some(*re)
		},
		None => None,
	};
	let channel_id = i64::from(core.tg.send(telegram_bot::GetChat::new(telegram_bot::types::ChatRef::ChannelUsername(channel.to_string()))).await?.id());
	let chan_adm = core.tg.send(telegram_bot::GetChatAdministrators::new(telegram_bot::types::ChatRef::ChannelUsername(channel.to_string()))).await
		.context("Sorry, I have no access to that chat.")?;
	let (mut me, mut user) = (false, false);
	for admin in chan_adm {
		if admin.user.id == core.my.id {
			me = true;
		};
		if admin.user.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)?;
	Ok(())
}