Debian Codegraph @

modules/chanserv/hold.c

raw
1 /*
2 * Copyright (c) 2005 Atheme Development Group
3 * Rights to this code are as documented in doc/LICENSE.
4 *
5 * Controls noexpire options for channels.
6 *
7 */
8
9 #include "atheme.h"
10
11 DECLARE_MODULE_V1
12 (
13 "chanserv/hold", false, _modinit, _moddeinit,
14 PACKAGE_STRING,
15 VENDOR_STRING
16 );
17
18 static void cs_cmd_hold(sourceinfo_t *si, int parc, char *parv[]);
19
20 command_t cs_hold = { "HOLD", N_("Prevents a channel from expiring."),
21 PRIV_HOLD, 2, cs_cmd_hold, { .path = "cservice/hold" } };
22
23 void _modinit(module_t *m)
24 {
25 service_named_bind_command("chanserv", &cs_hold);
26 }
27
28 void _moddeinit(module_unload_intent_t intent)
29 {
30 service_named_unbind_command("chanserv", &cs_hold);
31 }
32
33 static void cs_cmd_hold(sourceinfo_t *si, int parc, char *parv[])
34 {
35 char *target = parv[0];
36 char *action = parv[1];
37 mychan_t *mc;
38
39 if (!target || !action)
40 {
41 command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "HOLD");
42 command_fail(si, fault_needmoreparams, _("Usage: HOLD <#channel> <ON|OFF>"));
43 return;
44 }
45
46 if (*target != '#')
47 {
48 command_fail(si, fault_badparams, STR_INVALID_PARAMS, "HOLD");
49 return;
50 }
51
52 if (!(mc = mychan_find(target)))
53 {
54 command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), target);
55 return;
56 }
57
58 if (!strcasecmp(action, "ON"))
59 {
60 if (mc->flags & MC_HOLD)
61 {
62 command_fail(si, fault_nochange, _("\2%s\2 is already held."), target);
63 return;
64 }
65
66 mc->flags |= MC_HOLD;
67
68 wallops("%s set the HOLD option for the channel \2%s\2.", get_oper_name(si), target);
69 logcommand(si, CMDLOG_ADMIN, "HOLD:ON: \2%s\2", mc->name);
70 command_success_nodata(si, _("\2%s\2 is now held."), target);
71 }
72 else if (!strcasecmp(action, "OFF"))
73 {
74 if (!(mc->flags & MC_HOLD))
75 {
76 command_fail(si, fault_nochange, _("\2%s\2 is not held."), target);
77 return;
78 }
79
80 mc->flags &= ~MC_HOLD;
81
82 wallops("%s removed the HOLD option on the channel \2%s\2.", get_oper_name(si), target);
83 logcommand(si, CMDLOG_ADMIN, "HOLD:OFF: \2%s\2", mc->name);
84 command_success_nodata(si, _("\2%s\2 is no longer held."), target);
85 }
86 else
87 {
88 command_fail(si, fault_badparams, STR_INVALID_PARAMS, "HOLD");
89 command_fail(si, fault_badparams, _("Usage: HOLD <#channel> <ON|OFF>"));
90 }
91 }
92
93 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
94 * vim:ts=8
95 * vim:sw=8
96 * vim:noexpandtab
97 */