From f5651bc452096c8cd84d7c801228d64af3a165d2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 24 Aug 2014 17:14:07 +0300 Subject: Move chat command /unignore into actions. --- src/actions/commands.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/actions/commands.cpp') diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 7afc7efed..7e3d46446 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -136,4 +136,52 @@ impHandler(chatIgnore) return true; } +impHandler(chatUnignore) +{ + std::string args = event.args; + if (args.empty()) + { + WhisperTab *const whisper = dynamic_cast(event.tab); + if (!whisper || whisper->getNick().empty()) + { + // TRANSLATORS: change relation + event.tab->chatLog(_("Please specify a name."), ChatMsgType::BY_SERVER); + return false; + } + args = whisper->getNick(); + } + + const PlayerRelation::Relation rel = player_relations.getRelation(args); + if (rel != PlayerRelation::NEUTRAL && rel != PlayerRelation::FRIEND) + { + player_relations.setRelation(args, PlayerRelation::NEUTRAL); + } + else + { + if (event.tab) + { + // TRANSLATORS: unignore command + event.tab->chatLog(_("Player wasn't ignored!"), ChatMsgType::BY_SERVER); + } + return true; + } + + if (event.tab) + { + if (player_relations.getRelation(args) == PlayerRelation::NEUTRAL) + { + // TRANSLATORS: unignore command + event.tab->chatLog(_("Player no longer ignored!"), + ChatMsgType::BY_SERVER); + } + else + { + // TRANSLATORS: unignore command + event.tab->chatLog(_("Player could not be unignored!"), + ChatMsgType::BY_SERVER); + } + } + return true; +} + } // namespace Actions -- cgit v1.2.3-60-g2f50