]>
Commit | Line | Data |
---|---|---|
85305853 JH |
1 | /* |
2 | * m_cycle.c: server-side CYCLE | |
3 | * | |
4 | * Copyright (c) 2010 The ShadowIRCd team | |
5 | */ | |
6 | #include "stdinc.h" | |
7 | #include "common.h" | |
8 | #include "channel.h" | |
9 | #include "client.h" | |
10 | #include "hash.h" | |
11 | #include "match.h" | |
12 | #include "ircd.h" | |
13 | #include "numeric.h" | |
14 | #include "send.h" | |
15 | #include "s_conf.h" | |
16 | #include "s_serv.h" | |
17 | #include "msg.h" | |
18 | #include "parse.h" | |
19 | #include "modules.h" | |
20 | #include "packet.h" | |
21 | #include "hook.h" | |
22 | ||
23 | extern struct module **modlist; | |
24 | ||
25 | static int m_cycle(struct Client *, struct Client *, int, const char **); | |
26 | ||
27 | struct Message cycle_msgtab = { | |
28 | "CYCLE", 0, 0, 0, MFLG_SLOW, | |
29 | {mg_unreg, {m_cycle, 2}, {m_cycle, 2}, mg_ignore, mg_ignore, {m_cycle, 2}} | |
30 | }; | |
31 | mapi_clist_av1 cycle_clist[] = { &cycle_msgtab, NULL }; | |
32 | ||
33 | DECLARE_MODULE_AV1(cycle, NULL, NULL, cycle_clist, NULL, NULL, "$Revision$"); | |
34 | ||
35 | static int | |
36 | m_cycle(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
37 | { | |
38 | char *p, *name; | |
39 | char *s = LOCAL_COPY(parv[1]); | |
40 | struct Channel *chptr; | |
41 | struct membership *msptr; | |
42 | ||
43 | name = rb_strtok_r(s, ",", &p); | |
44 | ||
45 | /* Finish the flood grace period... */ | |
46 | if(MyClient(source_p) && !IsFloodDone(source_p)) | |
47 | flood_endgrace(source_p); | |
48 | ||
49 | while(name) | |
50 | { | |
51 | if((chptr = find_channel(name)) == NULL) | |
52 | { | |
53 | sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name); | |
54 | return 0; | |
55 | } | |
56 | ||
57 | msptr = find_channel_membership(chptr, source_p); | |
58 | if(msptr == NULL) | |
59 | { | |
60 | sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name); | |
61 | return 0; | |
62 | } | |
63 | ||
64 | if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p)) | |
65 | check_spambot_warning(source_p, NULL); | |
66 | ||
67 | if((is_any_op(msptr) || !MyConnect(source_p) || | |
68 | ((can_send(chptr, source_p, msptr) > 0 && | |
69 | (source_p->localClient->firsttime + | |
70 | ConfigFileEntry.anti_spam_exit_message_time) < rb_current_time())))) | |
71 | { | |
72 | sendto_server(client_p, chptr, CAP_TS6, NOCAPS, | |
73 | ":%s PART %s :Cycling", use_id(source_p), chptr->chname); | |
74 | sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :Cycling", | |
75 | source_p->name, source_p->username, | |
76 | source_p->host, chptr->chname); | |
77 | } | |
78 | else | |
79 | { | |
80 | sendto_server(client_p, chptr, CAP_TS6, NOCAPS, | |
81 | ":%s PART %s", use_id(source_p), chptr->chname); | |
82 | sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s", | |
83 | source_p->name, source_p->username, | |
84 | source_p->host, chptr->chname); | |
85 | } | |
86 | ||
87 | remove_user_from_channel(msptr); | |
88 | ||
89 | chptr = NULL; | |
90 | msptr = NULL; | |
91 | ||
92 | name = rb_strtok_r(NULL, ",", &p); | |
93 | } | |
94 | ||
95 | user_join(client_p, source_p, parv[1], parc > 2 ? parv[2] : NULL); | |
96 | ||
97 | return 0; | |
98 | } |