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 $
30 #include "s_newconf.h"
39 static int mo_ojoin(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[]);
42 struct Message ojoin_msgtab
= {
43 "OJOIN", 0, 0, 0, MFLG_SLOW
,
44 {mg_unreg
, mg_not_oper
, mg_ignore
, mg_ignore
, mg_ignore
, {mo_ojoin
, 2}}
47 mapi_clist_av1 ojoin_clist
[] = { &ojoin_msgtab
, NULL
};
49 DECLARE_MODULE_AV1(ojoin
, NULL
, NULL
, ojoin_clist
, NULL
, NULL
, "$Revision: 3554 $");
56 mo_ojoin(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
58 struct Channel
*chptr
;
62 if(!IsOperAdmin(source_p
))
64 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
, source_p
->name
, "admin");
68 if(*parv
[1] == '@' || *parv
[1] == '%' || *parv
[1] == '+')
74 if((chptr
= find_channel(parv
[1])) == NULL
)
76 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
77 form_str(ERR_NOSUCHCHANNEL
), parv
[1]);
81 if(IsMember(source_p
, chptr
))
83 sendto_one_notice(source_p
, ":Please part %s before using OJOIN", parv
[1]);
90 sendto_wallops_flags(UMODE_WALLOP
, &me
,
91 "OJOIN called for %s by %s!%s@%s",
92 parv
[1], source_p
->name
, source_p
->username
, source_p
->host
);
93 ilog(L_MAIN
, "OJOIN called for %s by %s",
94 parv
[1], get_oper_name(source_p
));
95 /* only sends stuff for #channels remotely */
96 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
97 ":%s WALLOPS :OJOIN called for %s by %s!%s@%s",
99 source_p
->name
, source_p
->username
, source_p
->host
);
103 add_user_to_channel(chptr
, source_p
, CHFL_CHANOP
);
104 sendto_server(client_p
, chptr
, CAP_TS6
, NOCAPS
,
105 ":%s SJOIN %ld %s + :@%s",
106 me
.id
, (long) chptr
->channelts
, chptr
->chname
, source_p
->id
);
107 send_channel_join(chptr
, source_p
);
108 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s MODE %s +o %s",
109 me
.name
, chptr
->chname
, source_p
->name
);
112 else if(*parv
[1] == '+')
114 add_user_to_channel(chptr
, source_p
, CHFL_VOICE
);
115 sendto_server(client_p
, chptr
, CAP_TS6
, NOCAPS
,
116 ":%s SJOIN %ld %s + :+%s",
117 me
.id
, (long) chptr
->channelts
, chptr
->chname
, source_p
->id
);
118 send_channel_join(chptr
, source_p
);
119 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s MODE %s +v %s",
120 me
.name
, chptr
->chname
, source_p
->name
);
124 add_user_to_channel(chptr
, source_p
, CHFL_PEON
);
125 sendto_server(client_p
, chptr
, CAP_TS6
, NOCAPS
,
127 source_p
->id
, (long) chptr
->channelts
, chptr
->chname
);
128 send_channel_join(chptr
, source_p
);
131 /* send the topic... */
132 if(chptr
->topic
!= NULL
)
134 sendto_one(source_p
, form_str(RPL_TOPIC
), me
.name
,
135 source_p
->name
, chptr
->chname
, chptr
->topic
);
136 sendto_one(source_p
, form_str(RPL_TOPICWHOTIME
), me
.name
,
137 source_p
->name
, chptr
->chname
, chptr
->topic_info
, chptr
->topic_time
);
140 source_p
->localClient
->last_join_time
= rb_current_time();
141 channel_member_names(chptr
, source_p
, 1);