/* * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Copyright © 2005-2006 Atheme Development Group * Rights to this code are documented in doc/pod/license.pod. * * CTCP command handling. */ static char const rcsid[] = "$Id: ctcp-common.C,v 1.4 2007/08/28 17:08:12 pippijn Exp $"; #include #include "atheme.h" #include "users.h" #include "datastream.h" #include "privs.h" #include typedef std::map ctcp_map; ctcp_map handlers; static void ctcp_ping_handler (char *cmd, char *args, char *origin, char *svsnick) { char *s; char const *m = 0; s = strtok (args, "\001"); if (s != NULL) strip (s); else m = "pong!"; notice (svsnick, origin, "\001PING %.100s\001", s ? s : m); } static void ctcp_version_handler (char *cmd, char *args, char *origin, char *svsnick) { notice (svsnick, origin, "\001VERSION " PACKAGE_NAME "-%s. %s %s%s%s%s%s%s%s%s%s%s [%s]\001", version, me.name, match_mapping ? "A" : "", log_debug_enabled () ? "d" : "", me.auth ? "e" : "", config_options.flood_msgs ? "F" : "", config_options.leave_chans ? "l" : "", config_options.join_chans ? "j" : "", chansvs.changets ? "t" : "", !match_mapping ? "R" : "", config_options.raw ? "r" : "", runflags & RF_LIVE ? "n" : "", ircd->ircdname); } static void ctcp_clientinfo_handler (char *cmd, char *args, char *origin, char *svsnick) { /* easter egg :X */ notice (svsnick, origin, "\001CLIENTINFO 114 97 107 97 117 114\001"); } void common_ctcp_init (void) { handlers["\001PING"] = ctcp_ping_handler; handlers["\001VERSION\001"] = ctcp_version_handler; handlers["\001CLIENTINFO\001"] = ctcp_clientinfo_handler; } unsigned int handle_ctcp_common (sourceinfo_t *si, char *cmd, char *args) { ctcp_map::iterator handler = handlers.find (cmd); if (handler != handlers.end ()) { handler->second (cmd, args, si->su->nick, si->service->name); return 1; } return 0; }