]> jfr.im git - irc/rqf/shadowircd.git/blame - extensions/m_ojoin.c
Prevent cork usage as charybdis doesn't have its support
[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"
23#include "tools.h"
212380e3 24#include "channel.h"
71f6ebfa 25#include "client.h"
212380e3 26#include "ircd.h"
27#include "numeric.h"
28#include "s_log.h"
29#include "s_serv.h"
30#include "s_conf.h"
71f6ebfa 31#include "s_newconf.h"
212380e3 32#include "send.h"
33#include "whowas.h"
34#include "irc_string.h"
71f6ebfa 35#include "hash.h"
212380e3 36#include "msg.h"
37#include "parse.h"
38#include "modules.h"
39
212380e3 40static int mo_ojoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
41
42
43struct Message ojoin_msgtab = {
44 "OJOIN", 0, 0, 0, MFLG_SLOW,
45 {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_ojoin, 2}}
46};
47
48mapi_clist_av1 ojoin_clist[] = { &ojoin_msgtab, NULL };
49
8e8f4ffc 50DECLARE_MODULE_AV1(ojoin, NULL, NULL, ojoin_clist, NULL, NULL, "$Revision: 3554 $");
212380e3 51
52/*
53** mo_ojoin
54** parv[0] = sender prefix
55** parv[1] = channel
56*/
57static int
58mo_ojoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
59{
60 struct Channel *chptr;
61 int move_me = 0;
62
63 /* admins only */
64 if(!IsOperAdmin(source_p))
65 {
a5ea0e0d 66 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
212380e3 67 return 0;
68 }
69
70 if(*parv[1] == '@' || *parv[1] == '%' || *parv[1] == '+')
71 {
72 parv[1]++;
73 move_me = 1;
74 }
75
76 if((chptr = find_channel(parv[1])) == NULL)
77 {
78 sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
79 form_str(ERR_NOSUCHCHANNEL), parv[1]);
80 return 0;
81 }
82
83 if(IsMember(source_p, chptr))
84 {
5366977b 85 sendto_one_notice(source_p, ":Please part %s before using OJOIN", parv[1]);
212380e3 86 return 0;
87 }
88
89 if(move_me == 1)
90 parv[1]--;
91
92 sendto_wallops_flags(UMODE_WALLOP, &me,
93 "OJOIN called for %s by %s!%s@%s",
94 parv[1], source_p->name, source_p->username, source_p->host);
95 ilog(L_MAIN, "OJOIN called for %s by %s",
96 parv[1], get_oper_name(source_p));
97 /* only sends stuff for #channels remotely */
98 sendto_server(NULL, chptr, NOCAPS, NOCAPS,
99 ":%s WALLOPS :OJOIN called for %s by %s!%s@%s",
100 me.name, parv[1],
101 source_p->name, source_p->username, source_p->host);
102
103 if(*parv[1] == '@')
104 {
105 add_user_to_channel(chptr, source_p, CHFL_CHANOP);
8e8f4ffc 106 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
107 ":%s SJOIN %ld %s + :@%s",
108 me.id, (long) chptr->channelts, chptr->chname, source_p->id);
109 sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
212380e3 110 ":%s SJOIN %ld %s + :@%s",
111 me.name, (long) chptr->channelts, chptr->chname, source_p->name);
112 sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
113 source_p->name,
114 source_p->username, source_p->host, chptr->chname);
115 sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
116 me.name, chptr->chname, source_p->name);
117
118 }
119 else if(*parv[1] == '+')
120 {
121 add_user_to_channel(chptr, source_p, CHFL_VOICE);
8e8f4ffc 122 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
123 ":%s SJOIN %ld %s + :+%s",
124 me.id, (long) chptr->channelts, chptr->chname, source_p->id);
125 sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
212380e3 126 ":%s SJOIN %ld %s + :+%s",
127 me.name, (long) chptr->channelts, chptr->chname, source_p->name);
128 sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
129 source_p->name,
130 source_p->username, source_p->host, chptr->chname);
131 sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +v %s",
132 me.name, chptr->chname, source_p->name);
133 }
134 else
135 {
136 add_user_to_channel(chptr, source_p, CHFL_PEON);
8e8f4ffc 137 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
138 ":%s JOIN %ld %s +",
139 source_p->id, (long) chptr->channelts, chptr->chname);
140 sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
212380e3 141 ":%s SJOIN %ld %s + :%s",
142 me.name, (long) chptr->channelts, chptr->chname, source_p->name);
143 sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
144 source_p->name,
145 source_p->username, source_p->host, chptr->chname);
146 }
147
148 /* send the topic... */
149 if(chptr->topic != NULL)
150 {
151 sendto_one(source_p, form_str(RPL_TOPIC), me.name,
152 source_p->name, chptr->chname, chptr->topic);
153 sendto_one(source_p, form_str(RPL_TOPICWHOTIME), me.name,
154 source_p->name, chptr->chname, chptr->topic_info, chptr->topic_time);
155 }
156
157 source_p->localClient->last_join_time = CurrentTime;
158 channel_member_names(chptr, source_p, 1);
159
160 return 0;
161}