Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Commit dd1c60f

Browse files
committed
modules: Add SAJOIN command for an oper to force join target lists.
1 parent 7106638 commit dd1c60f

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed

modules/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ auto_load_mod_LTLIBRARIES = \
5353
m_rehash.la \
5454
m_restart.la \
5555
m_resv.la \
56+
m_sajoin.la \
5657
m_sasl.la \
5758
m_scan.la \
5859
m_services.la \

modules/m_sajoin.c

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*
2+
* charybdis: porto vintage '88.
3+
* m_sajoin.c: Force join a user to a channel.
4+
*
5+
* Copyright (c) 2016 Charybdis Development Team
6+
* Copyright (c) 2016 Jason Volk <[email protected]>
7+
*
8+
* Permission to use, copy, modify, and/or distribute this software for
9+
any
10+
* purpose with or without fee is hereby granted, provided that the
11+
above
12+
* copyright notice and this permission notice is present in all copies.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
ARE
18+
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24+
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
* POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
#include "stdinc.h"
29+
#include "client.h"
30+
#include "ircd.h"
31+
#include "msg.h"
32+
#include "numeric.h"
33+
#include "send.h"
34+
#include "s_conf.h"
35+
#include "logger.h"
36+
#include "parse.h"
37+
#include "modules.h"
38+
#include "hash.h"
39+
#include "cache.h"
40+
#include "rb_dictionary.h"
41+
42+
const char sajoin_desc[] =
43+
"Allows operators to force a user to join a channel.";
44+
45+
static void mo_sajoin(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
46+
47+
struct Message sajoin_msgtab =
48+
{
49+
"SAJOIN", 0, 0, 0, 0,
50+
{
51+
mg_unreg,
52+
mg_ignore,
53+
mg_ignore,
54+
mg_ignore,
55+
mg_ignore,
56+
{ mo_sajoin, 3 }
57+
}
58+
};
59+
60+
mapi_clist_av1 sajoin_clist[] =
61+
{
62+
&sajoin_msgtab,
63+
NULL
64+
};
65+
66+
DECLARE_MODULE_AV2
67+
(
68+
sajoin,
69+
NULL,
70+
NULL,
71+
sajoin_clist,
72+
NULL,
73+
NULL,
74+
NULL,
75+
NULL,
76+
sajoin_desc
77+
);
78+
79+
/* Soft join is where SAJOIN peruses as the user itself attempting
80+
* to join the channel and is susceptible to bans etc.
81+
*
82+
* parv[1] = user to join to channel
83+
* parv[2] = name of channel
84+
*/
85+
static void
86+
join_soft(struct Client *const client,
87+
const char *const chname)
88+
{
89+
static char buf[BUFSIZE];
90+
const size_t len = snprintf(buf, sizeof(buf), ":%s JOIN %s",
91+
use_id(client),
92+
chname);
93+
94+
parse(client, buf, buf + len);
95+
}
96+
97+
/* Hard join forces the target user into the channel manually,
98+
* with as few checks as possible to bypass any bans etc.
99+
*
100+
* parv[1] = user to join to channel
101+
* parv[2] = name of channel
102+
*
103+
* !! NOT YET IMPLEMENTED !!
104+
*/
105+
static void
106+
join_hard(struct Client *const client,
107+
const char *const chname)
108+
{
109+
}
110+
111+
/*
112+
* parv[1] = channel list (chan,chan,chan,...)
113+
* parv[2] = nick list (nick,nick,nick,...)
114+
* (future) parv[3] = options
115+
*/
116+
static void
117+
mo_sajoin(struct MsgBuf *const msgbuf,
118+
struct Client *const client_p,
119+
struct Client *const source_p,
120+
int parc,
121+
const char **const parv)
122+
{
123+
static const char *const SEP = ",";
124+
static char vec[BUFSIZE];
125+
char *ctx, *target;
126+
127+
int clients = 0;
128+
static struct Client *client[BUFSIZE];
129+
rb_strlcpy(vec, parv[2], sizeof(vec));
130+
target = rb_strtok_r(vec, SEP, &ctx); do
131+
{
132+
if(!(client[clients] = find_person(target)))
133+
continue;
134+
135+
clients++;
136+
}
137+
while((target = rb_strtok_r(NULL, SEP, &ctx)));
138+
139+
rb_strlcpy(vec, parv[1], sizeof(vec));
140+
target = rb_strtok_r(vec, SEP, &ctx); do
141+
{
142+
if(!check_channel_name(target))
143+
continue;
144+
145+
for(size_t i = 0; i < clients; i++)
146+
join_soft(client[i], target);
147+
}
148+
while((target = rb_strtok_r(NULL, SEP, &ctx)));
149+
}

0 commit comments

Comments
 (0)