Debian Codegraph @

modules/groupserv/register.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/register", false, _modinit, _moddeinit,
15 PACKAGE_STRING,
16 VENDOR_STRING
17 );
18
19 static void gs_cmd_register(sourceinfo_t *si, int parc, char *parv[]);
20
21 command_t gs_register = { "REGISTER", N_("Registers a group."), AC_AUTHENTICATED, 2, gs_cmd_register, { .path = "groupserv/register" } };
22
23 static void gs_cmd_register(sourceinfo_t *si, int parc, char *parv[])
24 {
25 mygroup_t *mg;
26
27 if (!parv[0])
28 {
29 command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "REGISTER");
30 command_fail(si, fault_needmoreparams, _("To register a group: REGISTER <!groupname>"));
31 return;
32 }
33
34 if (*parv[0] != '!')
35 {
36 command_fail(si, fault_needmoreparams, STR_INVALID_PARAMS, "REGISTER");
37 command_fail(si, fault_needmoreparams, _("To register a group: REGISTER <!groupname>"));
38 return;
39 }
40
41 if (si->smu->flags & MU_WAITAUTH)
42 {
43 command_fail(si, fault_notverified, _("You need to verify your email address before you may register groups."));
44 return;
45 }
46
47 if (mygroup_find(parv[0]))
48 {
49 command_fail(si, fault_alreadyexists, _("The group \2%s\2 already exists."), parv[0]);
50 return;
51 }
52
53 if (strlen(parv[0]) >= NICKLEN)
54 {
55 command_fail(si, fault_badparams, _("The group name \2%s\2 is invalid."), parv[0]);
56 return;
57 }
58
59 if (myentity_count_group_flag(entity(si->smu), GA_FOUNDER) > gs_config->maxgroups &&
60 !has_priv(si, PRIV_REG_NOLIMIT))
61 {
62 command_fail(si, fault_toomany, _("You have too many groups registered."));
63 return;
64 }
65
66 if (metadata_find(si->smu, "private:restrict:setter"))
67 {
68 command_fail(si, fault_noprivs, _("You have been restricted from registering groups by network staff."));
69 return;
70 }
71
72 mg = mygroup_add(parv[0]);
73 groupacs_add(mg, entity(si->smu), GA_ALL | GA_FOUNDER);
74 hook_call_group_register(mg);
75
76 logcommand(si, CMDLOG_REGISTER, "REGISTER: \2%s\2", entity(mg)->name);
77 command_success_nodata(si, _("The group \2%s\2 has been registered to \2%s\2."), entity(mg)->name, entity(si->smu)->name);
78 }
79
80
81 void _modinit(module_t *m)
82 {
83 use_groupserv_main_symbols(m);
84
85 service_named_bind_command("groupserv", &gs_register);
86 }
87
88 void _moddeinit(module_unload_intent_t intent)
89 {
90 service_named_unbind_command("groupserv", &gs_register);
91 }
92