Debian Codegraph @

modules/chanserv/status.c

raw
1 /*
2 * Copyright (c) 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 */
8
9 #include "atheme.h"
10
11 DECLARE_MODULE_V1
12 (
13 "chanserv/status", false, _modinit, _moddeinit,
14 PACKAGE_STRING,
15 VENDOR_STRING
16 );
17
18 static void cs_cmd_status(sourceinfo_t *si, int parc, char *parv[]);
19
20 command_t cs_status = { "STATUS", N_("Displays your status in services."),
21 AC_NONE, 1, cs_cmd_status, { .path = "cservice/status" } };
22
23 void _modinit(module_t *m)
24 {
25 service_named_bind_command("chanserv", &cs_status);
26 }
27
28 void _moddeinit(module_unload_intent_t intent)
29 {
30 service_named_unbind_command("chanserv", &cs_status);
31 }
32
33 static void cs_cmd_status(sourceinfo_t *si, int parc, char *parv[])
34 {
35 char *chan = parv[0];
36
37 if (chan)
38 {
39 mychan_t *mc = mychan_find(chan);
40 unsigned int flags;
41
42 if (*chan != '#')
43 {
44 command_fail(si, fault_badparams, STR_INVALID_PARAMS, "STATUS");
45 return;
46 }
47
48 if (!mc)
49 {
50 command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), chan);
51 return;
52 }
53
54 logcommand(si, CMDLOG_GET, "STATUS: \2%s\2", mc->name);
55
56 if (metadata_find(mc, "private:close:closer"))
57 {
58 command_fail(si, fault_noprivs, _("\2%s\2 is closed."), chan);
59 return;
60 }
61
62 flags = chanacs_source_flags(mc, si);
63 if (flags & CA_AKICK && !(flags & CA_EXEMPT))
64 command_success_nodata(si, _("You are banned from \2%s\2."), mc->name);
65 else if (flags != 0)
66 {
67 command_success_nodata(si, _("You have access flags \2%s\2 on \2%s\2."), bitmask_to_flags(flags), mc->name);
68 }
69 else
70 command_success_nodata(si, _("You have no special access to \2%s\2."), mc->name);
71
72 return;
73 }
74
75 logcommand(si, CMDLOG_GET, "STATUS");
76 if (!si->smu)
77 command_success_nodata(si, _("You are not logged in."));
78 else
79 {
80 command_success_nodata(si, _("You are logged in as \2%s\2."), entity(si->smu)->name);
81
82 if (is_soper(si->smu))
83 {
84 soper_t *soper = si->smu->soper;
85
86 command_success_nodata(si, _("You are a services operator of class %s."), soper->operclass ? soper->operclass->name : soper->classname);
87 }
88 }
89
90 if (si->su != NULL)
91 {
92 mynick_t *mn;
93
94 mn = mynick_find(si->su->nick);
95 if (mn != NULL && mn->owner != si->smu &&
96 myuser_access_verify(si->su, mn->owner))
97 command_success_nodata(si, _("You are recognized as \2%s\2."), entity(mn->owner)->name);
98 }
99
100 if (si->su != NULL && is_admin(si->su))
101 command_success_nodata(si, _("You are a server administrator."));
102
103 if (si->su != NULL && is_ircop(si->su))
104 command_success_nodata(si, _("You are an IRC operator."));
105 }
106
107 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
108 * vim:ts=8
109 * vim:sw=8
110 * vim:noexpandtab
111 */