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