ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/status.C
Revision: 1.7
Committed: Thu Aug 30 19:56:22 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.6: +6 -6 lines
Log Message:
- put faultcodes into their own namespace
- removed old files
- limited header garbage in atheme.h
- macros to inline bools for connection_t::is_*
- put some connection_t functions into the connection_t class

File Contents

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