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