ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/status.C
Revision: 1.10
Committed: Sat Sep 22 14:27:27 2007 UTC (19 years ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +3 -3 lines
Log Message:
split up ermyth into ermyth-modules, libermyth (currently just ermyth-util) and ermyth-core

File Contents

# User Rev Content
1 pippijn 1.9 /**
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.5 * 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.10 * $Id: status.C,v 1.9 2007-09-16 18:54:43 pippijn Exp $
13 pippijn 1.1 */
14    
15     #include "atheme.h"
16 pippijn 1.5 #include <ermyth/module.h>
17 pippijn 1.1 #include <account/mychan.h>
18     #include <account/mynick.h>
19     #include <account/myuser.h>
20     #include <account/chanacs.h>
21    
22 pippijn 1.10 static char const rcsid[] = "$Id: status.C,v 1.9 2007-09-16 18:54:43 pippijn Exp $";
23 pippijn 1.1
24 pippijn 1.10 REGISTER_MODULE ("chanserv/status", false, "The Ermyth Team <http://ermyth.xinutec.org>");
25 pippijn 1.1
26     static void cs_cmd_status (sourceinfo_t *si, int parc, char *parv[]);
27    
28 pippijn 1.5 command_t const cs_status = { "STATUS", N_("Displays your status in services."), AC_NONE, 1, cs_cmd_status };
29 pippijn 1.1
30 pippijn 1.5 E cmdvec cs_cmdtree;
31     E helpvec cs_helptree;
32 pippijn 1.1
33 pippijn 1.5 bool
34     _modinit (module *m)
35 pippijn 1.1 {
36     cs_cmdtree << cs_status;
37 pippijn 1.4 help_addentry (cs_helptree, "STATUS", "help/chanserv/status", NULL);
38 pippijn 1.5
39     return true;
40 pippijn 1.1 }
41    
42     void
43     _moddeinit ()
44     {
45     cs_cmdtree >> cs_status;
46     help_delentry (cs_helptree, "STATUS");
47     }
48    
49     static void
50     cs_cmd_status (sourceinfo_t *si, int parc, char *parv[])
51     {
52     char *chan = parv[0];
53    
54     if (chan)
55     {
56 pippijn 1.7 mychan_t *mc = mychan_t::find (chan);
57 pippijn 1.1 unsigned int flags;
58    
59     if (*chan != '#')
60     {
61 pippijn 1.7 command_fail (si, fault::badparams, STR_INVALID_PARAMS, "STATUS");
62 pippijn 1.1 return;
63     }
64    
65     if (!mc)
66     {
67 pippijn 1.7 command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), chan);
68 pippijn 1.1 return;
69     }
70    
71     logcommand (si, CMDLOG_GET, "%s STATUS", mc->name);
72    
73     if (mc->find_metadata ("private:close:closer"))
74     {
75 pippijn 1.7 command_fail (si, fault::noprivs, _("\2%s\2 is closed."), chan);
76 pippijn 1.1 return;
77     }
78    
79     flags = chanacs_source_flags (mc, si);
80     if (flags & CA_AKICK && !(flags & CA_REMOVE))
81     command_success_nodata (si, _("You are banned from \2%s\2."), mc->name);
82     else if (flags != 0)
83     {
84     command_success_nodata (si, _("You have access flags \2%s\2 on \2%s\2."), bitmask_to_flags (flags, chanacs_flags), mc->name);
85     }
86     else
87     command_success_nodata (si, _("You have no special access to \2%s\2."), mc->name);
88    
89     return;
90     }
91    
92     logcommand (si, CMDLOG_GET, "STATUS");
93     if (!si->smu)
94     command_success_nodata (si, _("You are not logged in."));
95     else
96     {
97     command_success_nodata (si, _("You are logged in as \2%s\2."), si->smu->name);
98    
99     if (is_soper (si->smu))
100     {
101     soper_t *soper = si->smu->soper;
102    
103     command_success_nodata (si, _("You are a services operator of class %s."), soper->operclass ? soper->operclass->name : soper->classname);
104     }
105     }
106    
107     if (si->su != NULL)
108     {
109     mynick_t *mn;
110    
111 pippijn 1.8 mn = mynick_t::find (si->su->nick);
112 pippijn 1.6 if (mn != NULL && mn->owner != si->smu && mn->owner->access_verify (si->su))
113 pippijn 1.1 command_success_nodata (si, _("You are recognized as \2%s\2."), mn->owner->name);
114     }
115    
116     if (si->su != NULL && is_admin (si->su))
117     command_success_nodata (si, _("You are a server administrator."));
118    
119     if (si->su != NULL && is_ircop (si->su))
120     command_success_nodata (si, _("You are an IRC operator."));
121     }