]> jfr.im git - solanum.git/blame - extensions/m_ojoin.c
add help for `chm_regmsg`
[solanum.git] / extensions / m_ojoin.c
CommitLineData
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.
212380e3
AC
18 */
19
20#include "stdinc.h"
212380e3 21#include "channel.h"
55abcbb2 22#include "client.h"
212380e3
AC
23#include "ircd.h"
24#include "numeric.h"
4016731b 25#include "logger.h"
212380e3
AC
26#include "s_serv.h"
27#include "s_conf.h"
55abcbb2 28#include "s_newconf.h"
212380e3
AC
29#include "send.h"
30#include "whowas.h"
4562c604 31#include "match.h"
55abcbb2 32#include "hash.h"
212380e3
AC
33#include "msg.h"
34#include "parse.h"
35#include "modules.h"
bd0d352f 36#include "messages.h"
212380e3 37
eeabf33a
EM
38static const char ojoin_desc[] = "Allow admins to forcibly join channels with the OJOIN command";
39
3c7d6fcc 40static void mo_ojoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
212380e3 41
212380e3 42struct Message ojoin_msgtab = {
7baa37a9 43 "OJOIN", 0, 0, 0, 0,
212380e3
AC
44 {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_ojoin, 2}}
45};
46
47mapi_clist_av1 ojoin_clist[] = { &ojoin_msgtab, NULL };
48
02369fa7 49DECLARE_MODULE_AV2(ojoin, NULL, NULL, ojoin_clist, NULL, NULL, NULL, NULL, ojoin_desc);
212380e3
AC
50
51/*
52** mo_ojoin
212380e3
AC
53** parv[1] = channel
54*/
3c7d6fcc 55static void
760bafda 56mo_ojoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
212380e3
AC
57{
58 struct Channel *chptr;
59 int move_me = 0;
60
61 /* admins only */
62 if(!IsOperAdmin(source_p))
63 {
a5ea0e0d 64 sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
3c7d6fcc 65 return;
212380e3
AC
66 }
67
be8f7789 68 if(*parv[1] == '@' || *parv[1] == '+')
212380e3
AC
69 {
70 parv[1]++;
71 move_me = 1;
72 }
73
74 if((chptr = find_channel(parv[1])) == NULL)
75 {
76 sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
77 form_str(ERR_NOSUCHCHANNEL), parv[1]);
3c7d6fcc 78 return;
212380e3
AC
79 }
80
81 if(IsMember(source_p, chptr))
82 {
5366977b 83 sendto_one_notice(source_p, ":Please part %s before using OJOIN", parv[1]);
3c7d6fcc 84 return;
212380e3
AC
85 }
86
87 if(move_me == 1)
88 parv[1]--;
89
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",
98 me.name, parv[1],
99 source_p->name, source_p->username, source_p->host);
100
101 if(*parv[1] == '@')
102 {
103 add_user_to_channel(chptr, source_p, CHFL_CHANOP);
8e8f4ffc
JT
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);
805cfa5a 107 send_channel_join(chptr, source_p);
4b1cce65 108 sendto_channel_local(&me, ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
212380e3
AC
109 me.name, chptr->chname, source_p->name);
110
111 }
112 else if(*parv[1] == '+')
113 {
114 add_user_to_channel(chptr, source_p, CHFL_VOICE);
8e8f4ffc
JT
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);
805cfa5a 118 send_channel_join(chptr, source_p);
4b1cce65 119 sendto_channel_local(&me, ALL_MEMBERS, chptr, ":%s MODE %s +v %s",
212380e3
AC
120 me.name, chptr->chname, source_p->name);
121 }
122 else
123 {
124 add_user_to_channel(chptr, source_p, CHFL_PEON);
8e8f4ffc
JT
125 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
126 ":%s JOIN %ld %s +",
127 source_p->id, (long) chptr->channelts, chptr->chname);
805cfa5a 128 send_channel_join(chptr, source_p);
212380e3
AC
129 }
130
131 /* send the topic... */
132 if(chptr->topic != NULL)
133 {
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,
5c01fc8b 137 source_p->name, chptr->chname, chptr->topic_info, (long long)chptr->topic_time);
212380e3
AC
138 }
139
954012d3 140 source_p->localClient->last_join_time = rb_current_time();
212380e3 141 channel_member_names(chptr, source_p, 1);
212380e3 142}