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