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

File Contents

# Content
1 /**
2 * taxonomy.C: Lists object properties via their metadata table.
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: taxonomy.C,v 1.8 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
19 static char const rcsid[] = "$Id: taxonomy.C,v 1.8 2007-09-16 18:54:43 pippijn Exp $";
20
21 REGISTER_MODULE ("chanserv/taxonomy", false, "The Ermyth Team <http://ermyth.xinutec.org>");
22
23 static void cs_cmd_taxonomy (sourceinfo_t *si, int parc, char *parv[]);
24
25 command_t const cs_taxonomy = { "TAXONOMY", N_("Displays a channel's metadata."), AC_NONE, 1, cs_cmd_taxonomy };
26
27 E cmdvec cs_cmdtree;
28 E helpvec cs_helptree;
29
30 bool
31 _modinit (module *m)
32 {
33 cs_cmdtree << cs_taxonomy;
34 help_addentry (cs_helptree, "TAXONOMY", "help/chanserv/taxonomy", NULL);
35
36 return true;
37 }
38
39 void
40 _moddeinit ()
41 {
42 cs_cmdtree >> cs_taxonomy;
43 help_delentry (cs_helptree, "TAXONOMY");
44 }
45
46 void
47 cs_cmd_taxonomy (sourceinfo_t *si, int parc, char *parv[])
48 {
49 char *target = parv[0];
50 mychan_t *mc;
51 bool isoper;
52
53 if (!target || *target != '#')
54 {
55 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "TAXONOMY");
56 command_fail (si, fault::needmoreparams, _("Syntax: TAXONOMY <#channel>"));
57 return;
58 }
59
60 if (!(mc = mychan_t::find (target)))
61 {
62 command_fail (si, fault::nosuch_target, _("\2%s\2 is not a registered channel."), target);
63 return;
64 }
65
66 isoper = has_priv (si, PRIV_CHAN_AUSPEX);
67 if (isoper)
68 logcommand (si, CMDLOG_ADMIN, "%s TAXONOMY (oper)", mc->name);
69 else
70 logcommand (si, CMDLOG_GET, "%s TAXONOMY", mc->name);
71 command_success_nodata (si, _("Taxonomy for \2%s\2:"), target);
72
73 metadata::map_type::iterator mcmdit = mc->mdmap.begin ();
74 metadata::map_type::iterator mcmdet = mc->mdmap.end ();
75 while (mcmdit != mcmdet)
76 {
77 metadata *md = mcmdit->second;
78 ++mcmdit;
79
80 if (md->is_private && !isoper)
81 continue;
82
83 command_success_nodata (si, "%-32s: %s", md->key, md->value);
84 }
85
86 command_success_nodata (si, _("End of \2%s\2 taxonomy."), target);
87 }