]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * charybdis | |
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 int mo_extendchans(struct MsgBuf *, struct Client *, struct Client *, int, const char **); | |
35 | static int me_extendchans(struct MsgBuf *, struct Client *, struct Client *, int, const char **); | |
36 | ||
37 | struct Message extendchans_msgtab = { | |
38 | "EXTENDCHANS", 0, 0, 0, 0, | |
39 | { mg_unreg, mg_ignore, mg_ignore, mg_ignore, {me_extendchans, 2}, {mo_extendchans, 2}} | |
40 | }; | |
41 | ||
42 | mapi_clist_av1 extendchans_clist[] = { &extendchans_msgtab, NULL }; | |
43 | ||
44 | static const char extendchans_desc[] = | |
45 | "Allow an oper or service to let a given user join more channels"; | |
46 | ||
47 | DECLARE_MODULE_AV2(extendchans, NULL, NULL, extendchans_clist, NULL, NULL, NULL, NULL, extendchans_desc); | |
48 | ||
49 | static int | |
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 0; | |
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 0; | |
64 | } | |
65 | ||
66 | if((target_p = find_chasing(source_p, parv[1], NULL)) == NULL) | |
67 | return 0; | |
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 | return 0; | |
87 | } | |
88 | ||
89 | static int | |
90 | me_extendchans(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
91 | { | |
92 | struct Client *target_p; | |
93 | ||
94 | target_p = find_person(parv[1]); | |
95 | if(target_p == NULL) | |
96 | { | |
97 | sendto_one_numeric(source_p, ERR_NOSUCHNICK, form_str(ERR_NOSUCHNICK), parv[1]); | |
98 | return 0; | |
99 | } | |
100 | ||
101 | /* Is the target user local? If not, pass it on. */ | |
102 | if(!MyClient(target_p)) | |
103 | { | |
104 | struct Client *cptr = target_p->servptr; | |
105 | sendto_one(cptr, ":%s ENCAP %s EXTENDCHANS %s", | |
106 | get_id(source_p, cptr), cptr->name, get_id(target_p, cptr)); | |
107 | return 0; | |
108 | } | |
109 | ||
110 | sendto_one_notice(target_p, ":*** %s (%s@%s) is extending your channel limit", | |
111 | source_p->name, source_p->username, source_p->host); | |
112 | SetExtendChans(target_p); | |
113 | ||
114 | return 0; | |
115 | } |