Overview
| Comment: | update workflow, get rid of TEXT MardownV2, rewrite handle, add more callbacks |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
3fd8c40aa8d86f47c2d227490ecc7fb4 |
| User & Date: | arcade on 2026-03-30 14:20:11.771 |
| Other Links: | manifest | tags |
Context
|
2026-04-18
| ||
| 18:31 | bump, update workflow, add update reaction code, change paging logic leaf check-in: be0b8602d1 user: arcade tags: trunk | |
|
2026-03-30
| ||
| 14:20 | update workflow, get rid of TEXT MardownV2, rewrite handle, add more callbacks check-in: 3fd8c40aa8 user: arcade tags: trunk | |
|
2026-03-28
| ||
| 13:24 | comments, reordering, better paging check-in: 374eadef45 user: arcade tags: trunk | |
Changes
Modified .github/workflows/rust-clippy.yml
from [fc0335ac73]
to [150927a414].
1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | + - + + + + + + - + | name: rust-ci on: [ pull_request ] |
Modified src/command.rs
from [46db96910f]
to [7df81b2fde].
| ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 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 62 63 64 65 66 | + - - + + - + - - + + |
use sedregex::ReplaceCommand;
use stacked_errors::{
Result,
StackableErr,
bail,
};
use tgbot::types::{
CallbackQuery,
ChatMember,
ChatUsername,
GetChat,
GetChatAdministrators,
Message,
};
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();
}
/// Sends an informational message to the message's chat linking to the bot help channel.
pub async fn start (core: &Core, msg: &Message) -> Result<()> {
|
| ︙ |
Modified src/core.rs
from [1e3d90a7dd]
to [c0605e985c].
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | + |
use crate::{
Arc,
command,
Mutex,
sql::Db,
tg_bot::{
Callback,
MyMessage,
Tg,
},
};
use std::{
borrow::Cow,
|
| ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 34 35 36 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 | + - - - - - - - - |
StackableErr,
anyhow,
bail,
};
use tgbot::{
handler::UpdateHandler,
types::{
CallbackQuery,
ChatPeerId,
Command,
Update,
UpdateType,
UserPeerId,
},
};
use ttl_cache::TtlCache;
lazy_static!{
pub static ref RE_SPECIAL: Regex = Regex::new(r"([\-_*\[\]()~`>#+|{}\.!])").unwrap();
}
|
| ︙ | |||
105 106 107 108 109 110 111 | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | - + |
smol::block_on(async {
let mut set = self.running.lock_arc().await;
set.remove(&self.my_id);
})
}
}
|
| ︙ | |||
332 333 334 335 336 337 338 | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | - + |
Ok(Some(source)) => source.to_string(),
Ok(None) => "Source not found in database?".to_string(),
Err(err) => format!("Failed to fetch source data:\n{err}"),
}
};
smol::spawn(Compat::new(async move {
if let Err(err) = clone.check(source_id, true, Some(last_scrape)).await
|
| ︙ | |||
358 359 360 361 362 363 364 | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | - + |
for row in conn.get_list(owner).await.stack()? {
reply.push(row.to_string());
};
Ok(reply.join("\n\n"))
}
/// Returns current cached list of feed for requested user, or loads data from database
|
| ︙ | |||
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | + + + + + + - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + |
}
// in case we failed to found feed we need to remove - just reload everything from database
if !dropped {
self.get_feeds(owner).await.stack()?;
}
Ok(())
}
pub async fn cb (&self, query: &CallbackQuery, cb: &str) -> Result<()> {
let cb: Callback = toml::from_str(cb).stack()?;
todo!();
Ok(())
}
}
impl UpdateHandler for Core {
/// Dispatches an incoming Telegram update to a matching command handler and reports handler errors to the originating chat.
///
/// This method inspects the update; if it contains a message that can be parsed as a bot command,
/// it executes the corresponding command handler. If the handler returns an error, the error text
/// is sent back to the message's chat using MarkdownV2 formatting. Unknown commands produce an error
/// which is also reported to the chat.
|
Modified src/sql.rs
from [adaf777be6]
to [3451dbd25d].
| ︙ | |||
33 34 35 36 37 38 39 | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | - + - + - + |
pub url: String,
pub iv_hash: Option<String>,
pub url_re: Option<String>,
}
impl fmt::Display for List {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::result::Result<(), fmt::Error> {
|
| ︙ |
Modified src/tg_bot.rs
from [90448b5782]
to [8222e20590].
1 2 3 4 5 6 7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 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 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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | + - + + + + + + + + + + - - + + + + + + + + + - + + + + + - + - - + - + + |
use crate::{
Arc,
Mutex,
core::FeedList,
};
use std::{
borrow::Cow,
|
| ︙ | |||
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | + + + + + + + + + + + + + + + - - |
Callback::list("", if *page == 0 { *page } else { page - 1 } ).to_string()),
InlineKeyboardButton::for_callback_data(">>",
Callback::list("", page + 1).to_string()),
]);
}
InlineKeyboardMarkup::from(kb)
},
Callback::Menu(_) => {
let kb = vec![
vec![
InlineKeyboardButton::for_callback_data(
"Add new channel",
Callback::menu().to_string()), // new XXX
],
vec![
InlineKeyboardButton::for_callback_data(
"List channels",
Callback::list("", 0).to_string()),
],
];
InlineKeyboardMarkup::from(kb)
},
};
Ok(mark)
}
pub enum MyMessage <'a> {
Html { text: Cow<'a, str> },
HtmlTo { text: Cow<'a, str>, to: ChatPeerId },
HtmlToKb { text: Cow<'a, str>, to: ChatPeerId, kb: InlineKeyboardMarkup },
|
| ︙ | |||
154 155 156 157 158 159 160 | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | - - - - - - - - - - - - - - - - - - |
pub fn html_to_kb <'a, S> (text: S, to: ChatPeerId, kb: InlineKeyboardMarkup) -> MyMessage<'a>
where S: Into<Cow<'a, str>> {
let text = text.into();
MyMessage::HtmlToKb { text, to, kb }
}
|
| ︙ | |||
227 228 229 230 231 232 233 234 235 236 237 238 239 240 | 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | + + + + + + + |
/// Send a text message to a chat, using an optional target and parse mode.
///
/// # Returns
/// The sent `Message` on success.
pub async fn send (&self, msg: MyMessage<'_>) -> Result<Message> {
self.client.execute(msg.req(self)?).await.stack()
}
pub async fn answer_cb (&self, id: String, text: String) -> Result<bool> {
self.client.execute(
AnswerCallbackQuery::new(id)
.with_text(text)
).await.stack()
}
/// Create a copy of this `Tg` with the owner replaced by the given chat ID.
///
/// # Parameters
/// - `owner`: The Telegram chat identifier to set as the new owner (expressed as an `i64`).
///
/// # Returns
|
| ︙ |