| 1 |
/** |
| 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 |
* Copyright © 2005 William Pitcock, et al. |
| 10 |
* Rights to this code are as documented in doc/pod/license.pod. |
| 11 |
* |
| 12 |
* $Id: status.C,v 1.9 2007-09-16 18:54:43 pippijn Exp $ |
| 13 |
*/ |
| 14 |
|
| 15 |
#include "atheme.h" |
| 16 |
#include <ermyth/module.h> |
| 17 |
#include <account/mychan.h> |
| 18 |
#include <account/mynick.h> |
| 19 |
#include <account/myuser.h> |
| 20 |
#include <account/chanacs.h> |
| 21 |
|
| 22 |
static char const rcsid[] = "$Id: status.C,v 1.9 2007-09-16 18:54:43 pippijn Exp $"; |
| 23 |
|
| 24 |
REGISTER_MODULE ("chanserv/status", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
| 25 |
|
| 26 |
static void cs_cmd_status (sourceinfo_t *si, int parc, char *parv[]); |
| 27 |
|
| 28 |
command_t const cs_status = { "STATUS", N_("Displays your status in services."), AC_NONE, 1, cs_cmd_status }; |
| 29 |
|
| 30 |
E cmdvec cs_cmdtree; |
| 31 |
E helpvec cs_helptree; |
| 32 |
|
| 33 |
bool |
| 34 |
_modinit (module *m) |
| 35 |
{ |
| 36 |
cs_cmdtree << cs_status; |
| 37 |
help_addentry (cs_helptree, "STATUS", "help/chanserv/status", NULL); |
| 38 |
|
| 39 |
return true; |
| 40 |
} |
| 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 |
mychan_t *mc = mychan_t::find (chan); |
| 57 |
unsigned int flags; |
| 58 |
|
| 59 |
if (*chan != '#') |
| 60 |
{ |
| 61 |
command_fail (si, fault::badparams, STR_INVALID_PARAMS, "STATUS"); |
| 62 |
return; |
| 63 |
} |
| 64 |
|
| 65 |
if (!mc) |
| 66 |
{ |
| 67 |
command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), chan); |
| 68 |
return; |
| 69 |
} |
| 70 |
|
| 71 |
logcommand (si, CMDLOG_GET, "%s STATUS", mc->name); |
| 72 |
|
| 73 |
if (mc->find_metadata ("private:close:closer")) |
| 74 |
{ |
| 75 |
command_fail (si, fault::noprivs, _("\2%s\2 is closed."), chan); |
| 76 |
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 |
mn = mynick_t::find (si->su->nick); |
| 112 |
if (mn != NULL && mn->owner != si->smu && mn->owner->access_verify (si->su)) |
| 113 |
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 |
} |