2 * Copyright (C) 2002 Hybrid Development Team
3 * Copyright (C) 2004 ircd-ratbox Development Team
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)
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.
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.
19 * $Id: m_ojoin.c 3554 2007-08-10 22:31:14Z jilles $
32 #include "s_newconf.h"
35 #include "irc_string.h"
42 static int mo_ojoin(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[]);
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}}
50 mapi_clist_av1 ojoin_clist
[] = { &ojoin_msgtab
, NULL
};
52 DECLARE_MODULE_AV1(ojoin
, NULL
, NULL
, ojoin_clist
, NULL
, NULL
, "$Revision: 3554 $");
56 ** parv[0] = sender prefix
60 mo_ojoin(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
62 struct Channel
*chptr
;
66 if(!IsOperAdmin(source_p
))
68 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
, source_p
->name
, "admin");
72 if(*parv
[1] == '@' || *parv
[1] == '%' || *parv
[1] == '+')
78 if((chptr
= find_channel(parv
[1])) == NULL
)
80 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
81 form_str(ERR_NOSUCHCHANNEL
), parv
[1]);
85 if(IsMember(source_p
, chptr
))
87 sendto_one_notice(source_p
, ":Please part %s before using OJOIN", parv
[1]);
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",
103 source_p
->name
, source_p
->username
, source_p
->host
);
107 add_user_to_channel(chptr
, source_p
, CHFL_CHANOP
);
108 sendto_server(client_p
, chptr
, CAP_TS6
, NOCAPS
,
109 ":%s SJOIN %ld %s + :@%s",
110 me
.id
, (long) chptr
->channelts
, chptr
->chname
, source_p
->id
);
111 sendto_server(client_p
, chptr
, NOCAPS
, CAP_TS6
,
112 ":%s SJOIN %ld %s + :@%s",
113 me
.name
, (long) chptr
->channelts
, chptr
->chname
, source_p
->name
);
114 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s!%s@%s JOIN %s",
116 source_p
->username
, source_p
->host
, chptr
->chname
);
117 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s MODE %s +o %s",
118 me
.name
, chptr
->chname
, source_p
->name
);
121 else if(*parv
[1] == '+')
123 add_user_to_channel(chptr
, source_p
, CHFL_VOICE
);
124 sendto_server(client_p
, chptr
, CAP_TS6
, NOCAPS
,
125 ":%s SJOIN %ld %s + :+%s",
126 me
.id
, (long) chptr
->channelts
, chptr
->chname
, source_p
->id
);
127 sendto_server(client_p
, chptr
, NOCAPS
, CAP_TS6
,
128 ":%s SJOIN %ld %s + :+%s",
129 me
.name
, (long) chptr
->channelts
, chptr
->chname
, source_p
->name
);
130 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s!%s@%s JOIN %s",
132 source_p
->username
, source_p
->host
, chptr
->chname
);
133 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s MODE %s +v %s",
134 me
.name
, chptr
->chname
, source_p
->name
);
138 add_user_to_channel(chptr
, source_p
, CHFL_PEON
);
139 sendto_server(client_p
, chptr
, CAP_TS6
, NOCAPS
,
141 source_p
->id
, (long) chptr
->channelts
, chptr
->chname
);
142 sendto_server(client_p
, chptr
, NOCAPS
, CAP_TS6
,
143 ":%s SJOIN %ld %s + :%s",
144 me
.name
, (long) chptr
->channelts
, chptr
->chname
, source_p
->name
);
145 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s!%s@%s JOIN %s",
147 source_p
->username
, source_p
->host
, chptr
->chname
);
150 /* send the topic... */
151 if(chptr
->topic
!= NULL
)
153 sendto_one(source_p
, form_str(RPL_TOPIC
), me
.name
,
154 source_p
->name
, chptr
->chname
, chptr
->topic
);
155 sendto_one(source_p
, form_str(RPL_TOPICWHOTIME
), me
.name
,
156 source_p
->name
, chptr
->chname
, chptr
->topic_info
, chptr
->topic_time
);
159 source_p
->localClient
->last_join_time
= CurrentTime
;
160 channel_member_names(chptr
, source_p
, 1);