/** * status.C: This file contains code for the ChanServ STATUS function. * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Copyright © 2005 William Pitcock, et al. * Rights to this code are as documented in doc/pod/license.pod. * * $Id: status.C,v 1.9 2007/09/22 14:27:28 pippijn Exp $ */ #include "atheme.h" #include #include #include static char const rcsid[] = "$Id: status.C,v 1.9 2007/09/22 14:27:28 pippijn Exp $"; REGISTER_MODULE ("nickserv/status", false, "The Ermyth Team "); static void ns_cmd_acc (sourceinfo_t *si, int parc, char *parv[]); static void ns_cmd_status (sourceinfo_t *si, int parc, char *parv[]); command_t const ns_status = { "STATUS", N_("Displays session information."), AC_NONE, 0, ns_cmd_status }; command_t const ns_acc = { "ACC", N_("Displays parsable session information"), AC_NONE, 2, ns_cmd_acc }; E cmdvec ns_cmdtree; E helpvec ns_helptree; bool _modinit (module *m) { ns_cmdtree << ns_acc; help_addentry (ns_helptree, "ACC", "help/nickserv/acc", NULL); ns_cmdtree << ns_status; help_addentry (ns_helptree, "STATUS", "help/nickserv/status", NULL); return true; } void _moddeinit () { ns_cmdtree >> ns_acc; help_delentry (ns_helptree, "ACC"); ns_cmdtree >> ns_status; help_delentry (ns_helptree, "STATUS"); } static void ns_cmd_acc (sourceinfo_t *si, int parc, char *parv[]) { char const *targuser = parv[0]; char *targaccount = parv[1]; user_t *u; myuser_t *mu; mynick_t *mn; if (!targuser) { u = si->su; targuser = u != NULL ? u->nick : "?"; } else u = user_find_named (targuser); if (!u) { command_fail (si, fault::nosuch_target, _("%s%s%s ACC 0 (offline)"), targuser, parc >= 2 ? " -> " : "", parc >= 2 ? targaccount : ""); return; } if (!targaccount) targaccount = u->nick; if (!strcmp (targaccount, "*")) mu = u->myuser; else mu = myuser_t::find_ext (targaccount); if (!mu) { command_fail (si, fault::nosuch_target, _("%s%s%s ACC 0 (not registered)"), u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? targaccount : ""); return; } if (u->myuser == mu) command_success_nodata (si, "%s%s%s ACC 3", u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? mu->name : ""); else if ((mn = mynick_t::find (u->nick)) != NULL && mn->owner == mu && mu->access_verify (u)) command_success_nodata (si, "%s%s%s ACC 2", u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? mu->name : ""); else command_success_nodata (si, "%s%s%s ACC 1", u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? mu->name : ""); } static void ns_cmd_status (sourceinfo_t *si, int parc, char *parv[]) { logcommand (si, CMDLOG_GET, "STATUS"); if (!si->smu) command_success_nodata (si, _("You are not logged in.")); else { command_success_nodata (si, _("You are logged in as \2%s\2."), si->smu->name); if (is_soper (si->smu)) { soper_t *soper = si->smu->soper; command_success_nodata (si, _("You are a services operator of class %s."), soper->operclass ? soper->operclass->name : soper->classname); } } if (si->su != NULL) { mynick_t *mn; mn = mynick_t::find (si->su->nick); if (mn != NULL && mn->owner != si->smu && mn->owner->access_verify (si->su)) command_success_nodata (si, _("You are recognized as \2%s\2."), mn->owner->name); } if (si->su != NULL && is_admin (si->su)) command_success_nodata (si, _("You are a server administrator.")); if (si->su != NULL && is_ircop (si->su)) command_success_nodata (si, _("You are an IRC operator.")); } /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs * vim:ts=8 * vim:sw=8 * vim:noexpandtab */