Debian Codegraph @

modules/groupserv/info.c

raw
1 /*
2 * Copyright (c) 2005 Atheme Development Group
3 * Rights to this code are documented in doc/LICENSE.
4 *
5 * This file contains routines to handle the GroupServ HELP command.
6 *
7 */
8
9 #include "atheme.h"
10 #include "groupserv.h"
11
12 DECLARE_MODULE_V1
13 (
14 "groupserv/info", false, _modinit, _moddeinit,
15 PACKAGE_STRING,
16 VENDOR_STRING
17 );
18
19 static void gs_cmd_info(sourceinfo_t *si, int parc, char *parv[]);
20
21 command_t gs_info = { "INFO", N_("Displays information about registered groups."), AC_NONE, 2, gs_cmd_info, { .path = "groupserv/info" } };
22
23 static void gs_cmd_info(sourceinfo_t *si, int parc, char *parv[])
24 {
25 mygroup_t *mg;
26 struct tm tm;
27 char buf[BUFSIZE], strfbuf[BUFSIZE];
28 metadata_t *md;
29
30 if (!parv[0])
31 {
32 command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "INFO");
33 command_fail(si, fault_needmoreparams, _("Syntax: INFO <!groupname>"));
34 return;
35 }
36
37 if (!(mg = mygroup_find(parv[0])))
38 {
39 command_fail(si, fault_alreadyexists, _("Group \2%s\2 does not exist."), parv[0]);
40 return;
41 }
42
43 tm = *localtime(&mg->regtime);
44 strftime(strfbuf, sizeof strfbuf, TIME_FORMAT, &tm);
45
46 command_success_nodata(si, _("Information for \2%s\2:"), parv[0]);
47 command_success_nodata(si, _("Registered : %s (%s ago)"), strfbuf, time_ago(mg->regtime));
48
49 if (config_options.show_entity_id || has_priv(si, PRIV_GROUP_AUSPEX))
50 command_success_nodata(si, _("Entity ID : %s"), entity(mg)->id);
51
52 if (mg->flags & MG_PUBLIC || (si->smu != NULL && groupacs_sourceinfo_has_flag(mg, si, 0) && !groupacs_sourceinfo_has_flag(mg, si, GA_BAN)) || has_priv(si, PRIV_GROUP_AUSPEX))
53 command_success_nodata(si, _("Founder : %s"), mygroup_founder_names(mg));
54
55 if ((md = metadata_find(mg, "description")))
56 command_success_nodata(si, _("Description : %s"), md->value);
57 if ((md = metadata_find(mg, "channel")))
58 command_success_nodata(si, _("Channel : %s"), md->value);
59 if ((md = metadata_find(mg, "url")))
60 command_success_nodata(si, _("URL : %s"), md->value);
61 if ((md = metadata_find(mg, "email")))
62 command_success_nodata(si, _("Email : %s"), md->value);
63
64 *buf = '\0';
65
66 if (mg->flags & MG_REGNOLIMIT)
67 mowgli_strlcat(buf, "REGNOLIMIT", BUFSIZE);
68
69 if (mg->flags & MG_ACSNOLIMIT)
70 {
71 if (*buf)
72 mowgli_strlcat(buf, " ", BUFSIZE);
73
74 mowgli_strlcat(buf, "ACSNOLIMIT", BUFSIZE);
75 }
76
77 if (mg->flags & MG_OPEN)
78 {
79 if (*buf)
80 mowgli_strlcat(buf, " ", BUFSIZE);
81
82 mowgli_strlcat(buf, "OPEN", BUFSIZE);
83 }
84
85 if (mg->flags & MG_PUBLIC)
86 {
87 if (*buf)
88 mowgli_strlcat(buf, " ", BUFSIZE);
89
90 mowgli_strlcat(buf, "PUBLIC", BUFSIZE);
91 }
92
93 if (*buf)
94 command_success_nodata(si, _("Flags : %s"), buf);
95
96 command_success_nodata(si, _("\2*** End of Info ***\2"));
97
98 logcommand(si, CMDLOG_GET, "INFO: \2%s\2", parv[0]);
99 }
100
101
102 void _modinit(module_t *m)
103 {
104 use_groupserv_main_symbols(m);
105
106 service_named_bind_command("groupserv", &gs_info);
107 }
108
109 void _moddeinit(module_unload_intent_t intent)
110 {
111 service_named_unbind_command("groupserv", &gs_info);
112 }
113