Overview
Comment: | 0.2.1: even more errors now can reach users |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
4632d20d395a21ce985efe1d7f937c3c |
User & Date: | arcade on 2021-11-13 10:50:25.848 |
Other Links: | manifest | tags |
Context
2021-11-13
| ||
20:37 | fix messages, store edit string check-in: 10c25017bb user: arcade tags: trunk | |
10:50 | 0.2.1: even more errors now can reach users check-in: 4632d20d39 user: arcade tags: trunk | |
10:32 | make /list work again, more fixes check-in: a7f91033c0 user: arcade tags: trunk | |
Changes
Modified Cargo.toml
from [6c479080fa]
to [1da50d0627].
1 2 | [package] name = "rsstg" | | | 1 2 3 4 5 6 7 8 9 10 | [package] name = "rsstg" version = "0.2.1" authors = ["arcade"] edition = "2018" [dependencies] anyhow = "*" atom_syndication = { version = "*", features = [ "with-serde" ] } chrono = "*" |
︙ | ︙ |
Modified src/command.rs
from [8e69210742]
to [86f4f1e85f].
︙ | ︙ | |||
54 55 56 57 58 59 60 | let mut i_command = command.into_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) { | | < | | < | < | | | | 54 55 56 57 58 59 60 61 62 63 64 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 mut i_command = command.into_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); }; 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) => { 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(()) } |
Modified src/main.rs
from [2eed746c52]
to [5b73371063].
︙ | ︙ | |||
42 43 44 45 46 47 48 | async fn handle(update: telegram_bot::Update, core: &core::Core, mut _reply_to: &Option<telegram_bot::UserId>) -> Result<()> { match update.kind { telegram_bot::UpdateKind::Message(message) => { match message.kind { telegram_bot::MessageKind::Text { ref data, .. } => { let sender = message.from.id; let words: Vec<&str> = data.split_whitespace().collect(); | | | | | | | | > > | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | async fn handle(update: telegram_bot::Update, core: &core::Core, mut _reply_to: &Option<telegram_bot::UserId>) -> Result<()> { match update.kind { telegram_bot::UpdateKind::Message(message) => { match message.kind { telegram_bot::MessageKind::Text { ref data, .. } => { let sender = message.from.id; let words: Vec<&str> = data.split_whitespace().collect(); match match words[0] { "/check" | "/clean" | "/enable" | "/delete" | "/disable" => command::command(core, sender, words).await, "/start" => command::start(core, sender).await, "/list" => command::list(core, sender).await, "/add" | "/update" => command::update(core, sender, words).await, _ => Ok(()), } { Err(err) => core.send(&format!("🛑 {:?}", err), Some(sender), None)?, Ok(()) => {}, }; }, _ => { }, }; }, _ => {}, |
︙ | ︙ |