12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
ChatMember,
ChatUsername,
GetChat,
GetChatAdministrators,
Message,
ParseMode::MarkdownV2,
};
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();
}
pub async fn start (core: &Core, msg: &Message) -> Result<()> {
core.send("We are open\\. Probably\\. Visit [channel](https://t.me/rsstg_bot_help/3) for details\\.",
Some(msg.chat.get_id()), Some(MarkdownV2)).await.stack()?;
Ok(())
|
>
<
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
ChatMember,
ChatUsername,
GetChat,
GetChatAdministrators,
Message,
ParseMode::MarkdownV2,
};
use url::Url;
lazy_static! {
static ref RE_USERNAME: Regex = Regex::new(r"^@([a-zA-Z][a-zA-Z0-9_]+)$").unwrap();
static ref RE_IV_HASH: Regex = Regex::new(r"^[a-f0-9]{14}$").unwrap();
}
pub async fn start (core: &Core, msg: &Message) -> Result<()> {
core.send("We are open\\. Probably\\. Visit [channel](https://t.me/rsstg_bot_help/3) for details\\.",
Some(msg.chat.get_id()), Some(MarkdownV2)).await.stack()?;
Ok(())
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
bail!("Usernames should be something like \"@\\[a\\-zA\\-Z]\\[a\\-zA\\-Z0\\-9\\_]+\", aren't they?\nNot {channel:?}");
},
};
*/
if ! RE_USERNAME.is_match(channel) {
bail!("Usernames should be something like \"@\\[a\\-zA\\-Z]\\[a\\-zA\\-Z0\\-9\\_]+\", aren't they?\nNot {channel:?}");
};
if ! RE_LINK.is_match(url) {
bail!("Link should be a link to atom/rss feed, something like \"https://domain/path\".\nNot {url:?}");
}
let iv_hash = match iv_hash {
Some(hash) => {
match hash.as_ref() {
"-" => None,
thing => {
if ! RE_IV_HASH.is_match(thing) {
|
>
>
>
|
>
>
|
>
>
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
bail!("Usernames should be something like \"@\\[a\\-zA\\-Z]\\[a\\-zA\\-Z0\\-9\\_]+\", aren't they?\nNot {channel:?}");
},
};
*/
if ! RE_USERNAME.is_match(channel) {
bail!("Usernames should be something like \"@\\[a\\-zA\\-Z]\\[a\\-zA\\-Z0\\-9\\_]+\", aren't they?\nNot {channel:?}");
};
{
let parsed_url = Url::parse(url)
.stack_err("Expecting a valid link to ATOM/RSS feed.")?;
match parsed_url.scheme() {
"http" | "https" => {},
scheme => {
bail!("Unsupported URL scheme: {scheme}");
},
};
}
let iv_hash = match iv_hash {
Some(hash) => {
match hash.as_ref() {
"-" => None,
thing => {
if ! RE_IV_HASH.is_match(thing) {
|