no list message when no record

This commit is contained in:
senset 2022-07-05 08:51:34 +08:00
parent 74f04c3ce0
commit 1fd4fb91f4
2 changed files with 14 additions and 8 deletions

View File

@ -13,8 +13,8 @@ use crate::{
db_controller::PaginatedRecordData,
messages::{
BOT_ABOUT, BOT_BUTTON_END, BOT_BUTTON_HEAD, BOT_BUTTON_NEXT, BOT_BUTTON_PREV, BOT_HELP,
BOT_TEXT_DELETED, BOT_TEXT_LOADING, BOT_TEXT_MUTE_STATUS, BOT_TEXT_STATUS_OFF,
BOT_TEXT_STATUS_ON, BOT_TEXT_WELCOME,
BOT_TEXT_DELETED, BOT_TEXT_LOADING, BOT_TEXT_MUTE_STATUS, BOT_TEXT_NO_LIST,
BOT_TEXT_STATUS_OFF, BOT_TEXT_STATUS_ON, BOT_TEXT_WELCOME,
},
telegram_bot::BotServer,
};
@ -315,15 +315,20 @@ impl CommandHandler {
page: usize,
) -> String {
let mut msg = String::from("```");
for (message, _) in paginated_record_data.current_data.iter() {
msg = format!("{}\n{}\t\t\t\t{}", msg, message.id, message.message);
}
if paginated_record_data.items_count == 0 {
msg = BOT_TEXT_NO_LIST.to_string();
} else {
msg = format!(
"{}\n```\n{}/{}",
msg,
page + 1,
paginated_record_data.pages_count
);
}
msg
}

View File

@ -20,3 +20,4 @@ pub const BOT_BUTTON_END: &'static str = "末页 ⏭";
pub const BOT_BUTTON_PREV: &'static str = "⏪ 上一页";
pub const BOT_BUTTON_NEXT: &'static str = "下一页 ⏩";
pub const BOT_TEXT_LOADING: &'static str = "⌛️ 载入中……";
pub const BOT_TEXT_NO_LIST: &'static str = "没有记录";