/* vim:set ts=4 sw=4 sts=4 et cindent: */ /* * nanodc - The ncurses DC++ client * Copyright © 2005-2006 Markus Lindqvist * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Contributor(s): * */ #include #include #include #include #include #include #include #include namespace modules { class Away: public modules::Module, public dcpp::ClientListener { public: Away(): m_isAway(false) { events::add_listener("command away", std::tr1::bind(&Away::away_callback, this)); } virtual void init() { // TODO: find a sensible way to listen all hubs } virtual void on(dcpp::ClientListener::PrivateMessage, dcpp::Client *client, const dcpp::OnlineUser &from, const dcpp::OnlineUser &to, const dcpp::OnlineUser &replyTo, const std::string &msg) throw() { if(m_isAway) { std::string reply = "Nanodc automated awaymsg: " + m_awayMessage; client->privateMessage(replyTo, reply, false); } } /** /search string */ void away_callback() { core::ArgParser parser(events::args() > 0 ? events::arg(0) : ""); parser.parse(); if(parser.args() < 1) { if(m_isAway) print_awaylog(); m_isAway = false; return; } m_isAway = true; m_awayMessage = parser.get_text(0); core::Log::get()->log("%21Away:%21 " + m_awayMessage); } void print_awaylog() { // TODO implement awaylog core::Log::get()->log("%21Note:%21 Awaylog not implemented"); } private: bool m_isAway; std::string m_awayMessage; }; } // namespace modules static modules::Away initialize;