diff --git a/src/commands.rs b/src/commands.rs index ce15286..b4b5b91 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -16,8 +16,9 @@ use crate::{ config::Args, db_controller::Controller, messages::{ - BOT_ABOUT, BOT_TEXT_HANGED, BOT_TEXT_IS_CHANNEL, BOT_TEXT_NO_TARGET, BOT_TEXT_TOP_GLOBAL, - BOT_TEXT_TOP_GROUP, BOT_TEXT_TOP_NONE, BOT_TEXT_TOP_TEMPLATE, BOT_TEXT_TOP_TITLE, + BOT_ABOUT, BOT_TEXT_HANGED, BOT_TEXT_HANGED_SELF, BOT_TEXT_IS_CHANNEL, BOT_TEXT_NO_TARGET, + BOT_TEXT_TOP_GLOBAL, BOT_TEXT_TOP_GROUP, BOT_TEXT_TOP_NONE, BOT_TEXT_TOP_TEMPLATE, + BOT_TEXT_TOP_TITLE, }, }; @@ -106,9 +107,24 @@ impl CommandHandler { match reply.from() { Some(user) => { + let is_self = match message.from() { + Some(f) => f.first_name == user.first_name, + None => false, + }; + let mut vars = HashMap::new(); - let index = OsRng.gen::() % BOT_TEXT_HANGED.len(); - let text = BOT_TEXT_HANGED[index]; + + let index = if is_self { + OsRng.gen::() % BOT_TEXT_HANGED_SELF.len() + } else { + OsRng.gen::() % BOT_TEXT_HANGED.len() + }; + + let text = if is_self { + BOT_TEXT_HANGED_SELF[index] + } else { + BOT_TEXT_HANGED[index] + }; vars.insert("name".to_string(), user.first_name.as_str()); diff --git a/src/messages.rs b/src/messages.rs index d791e57..e1118c0 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -14,8 +14,7 @@ const BOT_TEXT_HANGED_2: &'static str = "因为 {name} 太过逆天,我们把 const BOT_TEXT_HANGED_3: &'static str = "{name} 吊在了路灯上,TA 兴风作浪的时代结束了……"; const BOT_TEXT_HANGED_4: &'static str = "吊在路灯上的 {name} 正在接受大家的鄙视……"; const BOT_TEXT_HANGED_5: &'static str = "对 {name} 来说,绳命来得快去得也快,只有路灯是永恒的……"; -const BOT_TEXT_HANGED_6: &'static str = - "被套上麻袋的 {name} 在经历了一顿胖揍之后,最后还是成了路灯的挂件……"; +const BOT_TEXT_HANGED_6: &'static str = "被套上麻袋的 {name} 在经历了一顿胖揍之后,最后还是成了路灯的挂件……"; pub const BOT_TEXT_HANGED: [&str; 6] = [ BOT_TEXT_HANGED_1, @@ -25,3 +24,13 @@ pub const BOT_TEXT_HANGED: [&str; 6] = [ BOT_TEXT_HANGED_5, BOT_TEXT_HANGED_6, ]; + +const BOT_TEXT_HANGED_SELF_1: &'static str = "{name} 承受不了自己所做的一切,选择了自行了断……"; +const BOT_TEXT_HANGED_SELF_2: &'static str = "对于 {name} 来说,把自己吊在路灯上可能是最好的选择了……"; +const BOT_TEXT_HANGED_SELF_3: &'static str = "{name} 最终还是选择了逃避……"; + +pub const BOT_TEXT_HANGED_SELF: [&str; 3] = [ + BOT_TEXT_HANGED_SELF_1, + BOT_TEXT_HANGED_SELF_2, + BOT_TEXT_HANGED_SELF_3, +]; \ No newline at end of file