ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/chanserv/status.C
Revision: 1.1
Committed: Thu Jul 19 08:24:53 2007 UTC (19 years, 3 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Log Message:
initial import. the most important changes since Atheme are:
- fixed many memory leaks
- fixed many bugs
- converted to C++ and use more STL containers
- added a (not very enhanced yet) perl module
- greatly improved XML-RPC speed
- added a JSON-RPC module with code from json-cpp
- added a valgrind memcheck module to operserv
- added a more object oriented base64 implementation
- added a specialised unit test framework
- improved stability
- use gettimeofday() if available
- reworked adding/removing commands
- MemoServ IGNORE DEL can now remove indices

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * Copyright © 2005 William Pitcock, et al.
3     * Rights to this code are as documented in doc/LICENSE.
4     *
5     * This file contains code for the CService STATUS function.
6     *
7     * $Id: status.c 8027 2007-04-02 10:47:18Z nenolod $
8     */
9    
10     #include "atheme.h"
11     #include <account/mychan.h>
12     #include <account/mynick.h>
13     #include <account/myuser.h>
14     #include <account/chanacs.h>
15    
16     static char const rcsid[] = "$Id";
17    
18     struct cs_status_listeners : callback::has_listeners
19     {
20     };
21    
22     cs_status_listeners listeners;
23    
24     DECLARE_MODULE_V1 ("chanserv/status", false, _modinit, _moddeinit, rcsid, "The Ermyth Team <http://ermyth.schmorp.de>");
25    
26     static void cs_cmd_status (sourceinfo_t *si, int parc, char *parv[]);
27    
28     command_t cs_status = { "STATUS", N_("Displays your status in services."),
29     AC_NONE, 1, cs_cmd_status
30     };
31    
32     cmdvec *cs_cmdtree;
33     helpvec *cs_helptree;
34    
35     void
36     _modinit (module_t *m)
37     {
38     MODULE_USE_SYMBOL_T (cs_cmdtree, cmdvec, "chanserv/main", "cs_cmdtree");
39     MODULE_USE_SYMBOL_T (cs_helptree, helpvec, "chanserv/main", "cs_helptree");
40    
41     cs_cmdtree << cs_status;
42     help_addentry (cs_helptree, "STATUS", "help/cservice/status", NULL);
43     }
44    
45     void
46     _moddeinit ()
47     {
48     cs_cmdtree >> cs_status;
49     help_delentry (cs_helptree, "STATUS");
50     }
51    
52     static void
53     cs_cmd_status (sourceinfo_t *si, int parc, char *parv[])
54     {
55     char *chan = parv[0];
56    
57     if (chan)
58     {
59     mychan_t *mc = mychan_find (chan);
60     unsigned int flags;
61    
62     if (*chan != '#')
63     {
64     command_fail (si, fault_badparams, STR_INVALID_PARAMS, "STATUS");
65     return;
66     }
67    
68     if (!mc)
69     {
70     command_fail (si, fault_nosuch_target, _("\2%s\2 is not registered."), chan);
71     return;
72     }
73    
74     logcommand (si, CMDLOG_GET, "%s STATUS", mc->name);
75    
76     if (mc->find_metadata ("private:close:closer"))
77     {
78     command_fail (si, fault_noprivs, _("\2%s\2 is closed."), chan);
79     return;
80     }
81    
82     if (is_founder (mc, si->smu))
83     command_success_nodata (si, _("You are founder on \2%s\2."), mc->name);
84    
85     flags = chanacs_source_flags (mc, si);
86     if (flags & CA_AKICK && !(flags & CA_REMOVE))
87     command_success_nodata (si, _("You are banned from \2%s\2."), mc->name);
88     else if (flags != 0)
89     {
90     command_success_nodata (si, _("You have access flags \2%s\2 on \2%s\2."), bitmask_to_flags (flags, chanacs_flags), mc->name);
91     }
92     else
93     command_success_nodata (si, _("You have no special access to \2%s\2."), mc->name);
94    
95     return;
96     }
97    
98     logcommand (si, CMDLOG_GET, "STATUS");
99     if (!si->smu)
100     command_success_nodata (si, _("You are not logged in."));
101     else
102     {
103     command_success_nodata (si, _("You are logged in as \2%s\2."), si->smu->name);
104    
105     if (is_soper (si->smu))
106     {
107     soper_t *soper = si->smu->soper;
108    
109     command_success_nodata (si, _("You are a services operator of class %s."), soper->operclass ? soper->operclass->name : soper->classname);
110     }
111     }
112    
113     if (si->su != NULL)
114     {
115     mynick_t *mn;
116    
117     mn = mynick_find (si->su->nick);
118     if (mn != NULL && mn->owner != si->smu && myuser_access_verify (si->su, mn->owner))
119     command_success_nodata (si, _("You are recognized as \2%s\2."), mn->owner->name);
120     }
121    
122     if (si->su != NULL && is_admin (si->su))
123     command_success_nodata (si, _("You are a server administrator."));
124    
125     if (si->su != NULL && is_ircop (si->su))
126     command_success_nodata (si, _("You are an IRC operator."));
127     }
128    
129     /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
130     * vim:ts=8
131     * vim:sw=8
132     * vim:noexpandtab
133     */