]> jfr.im git - solanum.git/blob - extensions/m_extendchans.c
Note that messages caught in +g/+G are discarded
[solanum.git] / extensions / m_extendchans.c
1 /*
2 * solanum
3 * m_extendchans.c: Allow an oper or service to let a given user join more channels.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2006 ircd-ratbox development team
8 * Copyright (C) 2006-2016 ircd-seven development team
9 * Copyright (C) 2015-2016 ChatLounge IRC Network Development Team
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 * USA
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "modules.h"
30 #include "s_newconf.h"
31 #include "send.h"
32 #include "numeric.h"
33
34 static const char extendchans_desc[] =
35 "Allow an oper or service to let a given user join more channels";
36
37 static void mo_extendchans(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
38 static void me_extendchans(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
39
40 struct Message extendchans_msgtab = {
41 "EXTENDCHANS", 0, 0, 0, 0,
42 { mg_unreg, mg_ignore, mg_ignore, mg_ignore, {me_extendchans, 2}, {mo_extendchans, 2}}
43 };
44
45 mapi_clist_av1 extendchans_clist[] = { &extendchans_msgtab, NULL };
46
47 DECLARE_MODULE_AV2(extendchans, NULL, NULL, extendchans_clist, NULL, NULL, NULL, NULL, extendchans_desc);
48
49 static void
50 mo_extendchans(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
51 {
52 struct Client *target_p;
53
54 if(!HasPrivilege(source_p, "oper:extendchans"))
55 {
56 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "extendchans");
57 return;
58 }
59
60 if(EmptyString(parv[1]))
61 {
62 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "EXTENDCHANS");
63 return;
64 }
65
66 if((target_p = find_chasing(source_p, parv[1], NULL)) == NULL)
67 return;
68
69 /* Is the target user local? */
70 if(MyClient(target_p))
71 {
72 sendto_one_notice(target_p, ":*** %s (%s@%s) is extending your channel limit",
73 source_p->name, source_p->username, source_p->host);
74 SetExtendChans(target_p);
75 }
76 else /* Target user isn't local, so pass it on. */
77 {
78 struct Client *cptr = target_p->servptr;
79 sendto_one(cptr, ":%s ENCAP %s EXTENDCHANS %s",
80 get_id(source_p, cptr), cptr->name, get_id(target_p, cptr));
81 }
82
83 sendto_one_notice(source_p, ":You have extended the channel limit on: %s (%s@%s)",
84 target_p->name, target_p->username, target_p->orighost);
85 }
86
87 static void
88 me_extendchans(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
89 {
90 struct Client *target_p;
91
92 target_p = find_person(parv[1]);
93 if(target_p == NULL)
94 {
95 sendto_one_numeric(source_p, ERR_NOSUCHNICK, form_str(ERR_NOSUCHNICK), parv[1]);
96 return;
97 }
98
99 /* Is the target user local? If not, pass it on. */
100 if(!MyClient(target_p))
101 {
102 struct Client *cptr = target_p->servptr;
103 sendto_one(cptr, ":%s ENCAP %s EXTENDCHANS %s",
104 get_id(source_p, cptr), cptr->name, get_id(target_p, cptr));
105 return;
106 }
107
108 sendto_one_notice(target_p, ":*** %s (%s@%s) is extending your channel limit",
109 source_p->name, source_p->username, source_p->host);
110 SetExtendChans(target_p);
111 }