]> jfr.im git - irc/rqf/shadowircd.git/blame - extensions/m_ojoin.c
Allow /ojoin !#channel/%#channel, if admin/halfop are enabled.
[irc/rqf/shadowircd.git] / extensions / m_ojoin.c
CommitLineData
212380e3 1/* contrib/m_ojoin.c
2 * Copyright (C) 2002 Hybrid Development Team
3 * Copyright (C) 2004 ircd-ratbox Development Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 1, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
8e8f4ffc 19 * $Id: m_ojoin.c 3554 2007-08-10 22:31:14Z jilles $
212380e3 20 */
21
22#include "stdinc.h"
212380e3 23#include "channel.h"
71f6ebfa 24#include "client.h"
212380e3 25#include "ircd.h"
26#include "numeric.h"
d3455e2c 27#include "logger.h"
212380e3 28#include "s_serv.h"
29#include "s_conf.h"
71f6ebfa 30#include "s_newconf.h"
212380e3 31#include "send.h"
32#include "whowas.h"
13ae2f4b 33#include "match.h"
71f6ebfa 34#include "hash.h"
212380e3 35#include "msg.h"
36#include "parse.h"
37#include "modules.h"
38
212380e3 39static int mo_ojoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
40
41
42struct Message ojoin_msgtab = {
43 "OJOIN", 0, 0, 0, MFLG_SLOW,
44 {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_ojoin, 2}}
45};
46
47mapi_clist_av1 ojoin_clist[] = { &ojoin_msgtab, NULL };
48
8e8f4ffc 49DECLARE_MODULE_AV1(ojoin, NULL, NULL, ojoin_clist, NULL, NULL, "$Revision: 3554 $");
212380e3 50
51/*
52** mo_ojoin
212380e3 53** parv[1] = channel
54*/
55static int
56mo_ojoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
57{
58 struct Channel *chptr;
59 int move_me = 0;
60
61 /* admins only */
62 if(!IsOperAdmin(source_p))
63 {
a5ea0e0d 64 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
212380e3 65 return 0;
66 }
67
8097430a 68 if(*parv[1] == '@' || *parv[1] == '%' || *parv[1] == '+' || *parv[1] == '!')
212380e3 69 {
70 parv[1]++;
71 move_me = 1;
72 }
73
74 if((chptr = find_channel(parv[1])) == NULL)
75 {
76 sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
77 form_str(ERR_NOSUCHCHANNEL), parv[1]);
78 return 0;
79 }
80
81 if(IsMember(source_p, chptr))
82 {
5366977b 83 sendto_one_notice(source_p, ":Please part %s before using OJOIN", parv[1]);
212380e3 84 return 0;
85 }
86
87 if(move_me == 1)
88 parv[1]--;
89
90 sendto_wallops_flags(UMODE_WALLOP, &me,
91 "OJOIN called for %s by %s!%s@%s",
92 parv[1], source_p->name, source_p->username, source_p->host);
93 ilog(L_MAIN, "OJOIN called for %s by %s",
94 parv[1], get_oper_name(source_p));
95 /* only sends stuff for #channels remotely */
96 sendto_server(NULL, chptr, NOCAPS, NOCAPS,
97 ":%s WALLOPS :OJOIN called for %s by %s!%s@%s",
98 me.name, parv[1],
99 source_p->name, source_p->username, source_p->host);
100
8097430a
G
101 if(*parv[1] == '!' && ConfigChannel.use_admin)
102 {
103 add_user_to_channel(chptr, source_p, CHFL_ADMIN);
104 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
105 ":%s SJOIN %ld %s + :!%s",
106 me.id, (long) chptr->channelts, chptr->chname, source_p->id);
107 sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
108 source_p->name,
109 source_p->username, source_p->host, chptr->chname);
110 sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
111 me.name, chptr->chname, source_p->name);
112
113 }
114 else if(*parv[1] == '@')
212380e3 115 {
116 add_user_to_channel(chptr, source_p, CHFL_CHANOP);
8e8f4ffc 117 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
118 ":%s SJOIN %ld %s + :@%s",
119 me.id, (long) chptr->channelts, chptr->chname, source_p->id);
212380e3 120 sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
121 source_p->name,
122 source_p->username, source_p->host, chptr->chname);
123 sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
124 me.name, chptr->chname, source_p->name);
125
126 }
8097430a
G
127 else if(*parv[1] == '%' && ConfigChannel.use_halfop)
128 {
129 add_user_to_channel(chptr, source_p, CHFL_HALFOP);
130 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
131 ":%s SJOIN %ld %s + :%s%s",
132 me.id, (long) chptr->channelts, chptr->chname, "%", source_p->id);
133 sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
134 source_p->name,
135 source_p->username, source_p->host, chptr->chname);
136 sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s",
137 me.name, chptr->chname, source_p->name);
138 }
212380e3 139 else if(*parv[1] == '+')
140 {
141 add_user_to_channel(chptr, source_p, CHFL_VOICE);
8e8f4ffc 142 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
143 ":%s SJOIN %ld %s + :+%s",
144 me.id, (long) chptr->channelts, chptr->chname, source_p->id);
212380e3 145 sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
146 source_p->name,
147 source_p->username, source_p->host, chptr->chname);
148 sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +v %s",
149 me.name, chptr->chname, source_p->name);
150 }
151 else
152 {
153 add_user_to_channel(chptr, source_p, CHFL_PEON);
8e8f4ffc 154 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
155 ":%s JOIN %ld %s +",
156 source_p->id, (long) chptr->channelts, chptr->chname);
212380e3 157 sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
158 source_p->name,
159 source_p->username, source_p->host, chptr->chname);
160 }
161
162 /* send the topic... */
163 if(chptr->topic != NULL)
164 {
165 sendto_one(source_p, form_str(RPL_TOPIC), me.name,
166 source_p->name, chptr->chname, chptr->topic);
167 sendto_one(source_p, form_str(RPL_TOPICWHOTIME), me.name,
168 source_p->name, chptr->chname, chptr->topic_info, chptr->topic_time);
169 }
170
c51d32ba 171 source_p->localClient->last_join_time = rb_current_time();
212380e3 172 channel_member_names(chptr, source_p, 1);
173
174 return 0;
175}