Skip to content

Commit

Permalink
refactor(log): 改善日志
Browse files Browse the repository at this point in the history
  • Loading branch information
itsusinn committed Feb 6, 2022
1 parent 60eb430 commit e752d5d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ pub async fn start(bot: &AutoSend<Bot>) {
dptree::filter(|msg: Message| msg.chat.is_group() || msg.chat.is_supergroup())
.endpoint(handlers::send::answer_common),
);
info!("Mesagisto-Bot启动成功");
info!("Mesagisto信使启动成功");
Dispatcher::builder(bot.clone(), handler)
.default_handler(|upd| async move {
log::warn!("Unhandled update: {:?}", upd);
})
// If the dispatcher fails for some reason, execute this handler.
.error_handler(LoggingErrorHandler::with_custom_text(
"An error has occurred in the dispatcher",
"调度器中发生了一个错误",
))
.build()
.setup_ctrlc_handler()
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use mesagisto_client::MesagistoConfig;
use teloxide::{prelude2::*, Bot};

use bot::TG_BOT;
use config::CONFIG;
use crate::config::CONFIG;

#[macro_use]
extern crate educe;
Expand Down Expand Up @@ -64,14 +64,14 @@ async fn run() -> Result<(), anyhow::Error> {
.apply()
.await;

log::info!("Mesagisto-Bot正在启动");
log::info!("Mesagisto信使正在启动");

let bot = Bot::with_client(CONFIG.telegram.token.clone(), net::client_from_config()).auto_send();

TG_BOT.init(bot);
dispatch::start(&TG_BOT).await;

CONFIG.save();
log::info!("Mesagisto Bot is going to shut down");
log::info!("Mesagisto信使即将关闭");
Ok(())
}
2 changes: 1 addition & 1 deletion src/message/handlers/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use mesagisto_client::server::SERVER;
use mesagisto_client::EitherExt;
use teloxide::prelude2::*;

pub async fn answer_common(msg: Message, bot: AutoSend<Bot>) -> anyhow::Result<()> {
pub async fn answer_common(msg: Message, _bot: AutoSend<Bot>) -> anyhow::Result<()> {
let target = msg.chat_id();
if !CONFIG.target_address_mapper.contains_key(&target) {
return Ok(());
Expand Down

0 comments on commit e752d5d

Please sign in to comment.