ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/nickserv/status.C
Revision: 1.8
Committed: Sun Sep 16 18:54:43 2007 UTC (19 years ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.7: +10 -5 lines
Log Message:
#defines to enum

File Contents

# User Rev Content
1 pippijn 1.8 /**
2     * status.C: This file contains code for the ChanServ STATUS function.
3     *
4     * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
5     * Rights to this code are as documented in COPYING.
6     *
7     *
8     * Portions of this file were derived from sources bearing the following license:
9 pippijn 1.4 * Copyright © 2005 William Pitcock, et al.
10 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
11 pippijn 1.1 *
12 pippijn 1.8 * $Id: status.C,v 1.7 2007-09-09 20:05:52 pippijn Exp $
13 pippijn 1.1 */
14    
15     #include "atheme.h"
16 pippijn 1.4 #include <ermyth/module.h>
17 pippijn 1.1 #include <account/mynick.h>
18     #include <account/myuser.h>
19    
20 pippijn 1.8 static char const rcsid[] = "$Id: status.C,v 1.7 2007-09-09 20:05:52 pippijn Exp $";
21 pippijn 1.1
22 pippijn 1.4 REGISTER_MODULE ("nickserv/status", false, "The Ermyth Team <http://ermyth.schmorp.de>");
23 pippijn 1.1
24     static void ns_cmd_acc (sourceinfo_t *si, int parc, char *parv[]);
25     static void ns_cmd_status (sourceinfo_t *si, int parc, char *parv[]);
26    
27 pippijn 1.4 command_t const ns_status = { "STATUS", N_("Displays session information."), AC_NONE, 0, ns_cmd_status };
28     command_t const ns_acc = { "ACC", N_("Displays parsable session information"), AC_NONE, 2, ns_cmd_acc };
29 pippijn 1.1
30 pippijn 1.4 E cmdvec ns_cmdtree;
31     E helpvec ns_helptree;
32 pippijn 1.1
33 pippijn 1.4 bool
34     _modinit (module *m)
35 pippijn 1.1 {
36     ns_cmdtree << ns_acc;
37     help_addentry (ns_helptree, "ACC", "help/nickserv/acc", NULL);
38     ns_cmdtree << ns_status;
39     help_addentry (ns_helptree, "STATUS", "help/nickserv/status", NULL);
40 pippijn 1.4
41     return true;
42 pippijn 1.1 }
43    
44     void
45     _moddeinit ()
46     {
47     ns_cmdtree >> ns_acc;
48     help_delentry (ns_helptree, "ACC");
49     ns_cmdtree >> ns_status;
50     help_delentry (ns_helptree, "STATUS");
51     }
52    
53     static void
54     ns_cmd_acc (sourceinfo_t *si, int parc, char *parv[])
55     {
56 pippijn 1.4 char const *targuser = parv[0];
57 pippijn 1.1 char *targaccount = parv[1];
58     user_t *u;
59     myuser_t *mu;
60     mynick_t *mn;
61    
62     if (!targuser)
63     {
64     u = si->su;
65     targuser = u != NULL ? u->nick : "?";
66     }
67     else
68     u = user_find_named (targuser);
69    
70     if (!u)
71     {
72 pippijn 1.6 command_fail (si, fault::nosuch_target, _("%s%s%s ACC 0 (offline)"), targuser, parc >= 2 ? " -> " : "", parc >= 2 ? targaccount : "");
73 pippijn 1.1 return;
74     }
75    
76     if (!targaccount)
77     targaccount = u->nick;
78     if (!strcmp (targaccount, "*"))
79     mu = u->myuser;
80     else
81 pippijn 1.5 mu = myuser_t::find_ext (targaccount);
82 pippijn 1.1
83     if (!mu)
84     {
85 pippijn 1.6 command_fail (si, fault::nosuch_target, _("%s%s%s ACC 0 (not registered)"), u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? targaccount : "");
86 pippijn 1.1 return;
87     }
88    
89     if (u->myuser == mu)
90     command_success_nodata (si, "%s%s%s ACC 3", u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? mu->name : "");
91 pippijn 1.7 else if ((mn = mynick_t::find (u->nick)) != NULL && mn->owner == mu && mu->access_verify (u))
92 pippijn 1.1 command_success_nodata (si, "%s%s%s ACC 2", u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? mu->name : "");
93     else
94     command_success_nodata (si, "%s%s%s ACC 1", u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? mu->name : "");
95     }
96    
97     static void
98     ns_cmd_status (sourceinfo_t *si, int parc, char *parv[])
99     {
100     logcommand (si, CMDLOG_GET, "STATUS");
101    
102     if (!si->smu)
103     command_success_nodata (si, _("You are not logged in."));
104     else
105     {
106     command_success_nodata (si, _("You are logged in as \2%s\2."), si->smu->name);
107    
108     if (is_soper (si->smu))
109     {
110     soper_t *soper = si->smu->soper;
111    
112     command_success_nodata (si, _("You are a services operator of class %s."), soper->operclass ? soper->operclass->name : soper->classname);
113     }
114     }
115    
116     if (si->su != NULL)
117     {
118     mynick_t *mn;
119    
120 pippijn 1.7 mn = mynick_t::find (si->su->nick);
121 pippijn 1.5 if (mn != NULL && mn->owner != si->smu && mn->owner->access_verify (si->su))
122 pippijn 1.1 command_success_nodata (si, _("You are recognized as \2%s\2."), mn->owner->name);
123     }
124    
125     if (si->su != NULL && is_admin (si->su))
126     command_success_nodata (si, _("You are a server administrator."));
127    
128     if (si->su != NULL && is_ircop (si->su))
129     command_success_nodata (si, _("You are an IRC operator."));
130     }
131    
132     /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
133     * vim:ts=8
134     * vim:sw=8
135     * vim:noexpandtab
136     */