]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * IRC - Internet Relay Chat, contrib/m_findforwards.c | |
3 | * Copyright (C) 2002 Hybrid Development Team | |
4 | * Copyright (C) 2004 ircd-ratbox Development Team | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 1, or (at your option) | |
9 | * any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
212380e3 AC |
19 | */ |
20 | #include "stdinc.h" | |
212380e3 AC |
21 | #include "channel.h" |
22 | #include "client.h" | |
23 | #include "hash.h" | |
4562c604 | 24 | #include "match.h" |
212380e3 AC |
25 | #include "ircd.h" |
26 | #include "numeric.h" | |
27 | #include "s_user.h" | |
28 | #include "s_conf.h" | |
29 | #include "s_newconf.h" | |
30 | #include "send.h" | |
31 | #include "msg.h" | |
32 | #include "parse.h" | |
33 | #include "modules.h" | |
34 | #include "packet.h" | |
bd0d352f | 35 | #include "messages.h" |
212380e3 | 36 | |
eeabf33a EM |
37 | static const char findfowards_desc[] = "Allows operators to find forwards to a given channel"; |
38 | ||
3c7d6fcc | 39 | static void m_findforwards(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, |
212380e3 AC |
40 | int parc, const char *parv[]); |
41 | ||
42 | struct Message findforwards_msgtab = { | |
7baa37a9 | 43 | "FINDFORWARDS", 0, 0, 0, 0, |
212380e3 AC |
44 | {mg_unreg, {m_findforwards, 2}, mg_ignore, mg_ignore, mg_ignore, {m_findforwards, 2}} |
45 | }; | |
46 | ||
47 | mapi_clist_av1 findforwards_clist[] = { &findforwards_msgtab, NULL }; | |
48 | ||
02369fa7 | 49 | DECLARE_MODULE_AV2(findforwards, NULL, NULL, findforwards_clist, NULL, NULL, NULL, NULL, findfowards_desc); |
212380e3 AC |
50 | |
51 | /* | |
52 | ** mo_findforwards | |
212380e3 AC |
53 | ** parv[1] = channel |
54 | */ | |
3c7d6fcc | 55 | static void |
760bafda | 56 | m_findforwards(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
57 | { |
58 | static time_t last_used = 0; | |
59 | struct Channel *chptr; | |
60 | struct membership *msptr; | |
036a10a9 | 61 | rb_dlink_node *ptr; |
212380e3 AC |
62 | |
63 | /* Allow ircops to search for forwards to nonexistent channels */ | |
d4f7eb4c | 64 | if(!IsOperGeneral(source_p)) |
212380e3 AC |
65 | { |
66 | if((chptr = find_channel(parv[1])) == NULL || (msptr = find_channel_membership(chptr, source_p)) == NULL) | |
67 | { | |
68 | sendto_one_numeric(source_p, ERR_NOTONCHANNEL, | |
69 | form_str(ERR_NOTONCHANNEL), parv[1]); | |
3c7d6fcc | 70 | return; |
212380e3 AC |
71 | } |
72 | ||
73 | if(!is_chanop(msptr)) | |
74 | { | |
75 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
76 | me.name, source_p->name, parv[1]); | |
3c7d6fcc | 77 | return; |
212380e3 AC |
78 | } |
79 | ||
954012d3 | 80 | if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) |
212380e3 AC |
81 | { |
82 | sendto_one(source_p, form_str(RPL_LOAD2HI), | |
83 | me.name, source_p->name, "FINDFORWARDS"); | |
3c7d6fcc | 84 | return; |
212380e3 AC |
85 | } |
86 | else | |
954012d3 | 87 | last_used = rb_current_time(); |
212380e3 | 88 | } |
55abcbb2 | 89 | |
87835443 DF |
90 | send_multiline_init(source_p, " ", ":%s NOTICE %s :Forwards for %s: ", |
91 | me.name, | |
92 | source_p->name, | |
93 | parv[1]); | |
94 | ||
036a10a9 | 95 | RB_DLINK_FOREACH(ptr, global_channel_list.head) |
212380e3 AC |
96 | { |
97 | chptr = ptr->data; | |
b222b6a0 | 98 | if(!irccmp(chptr->mode.forward, parv[1])) |
212380e3 | 99 | { |
87835443 | 100 | send_multiline_item(source_p, "%s", chptr->chname); |
212380e3 AC |
101 | } |
102 | } | |
103 | ||
87835443 | 104 | send_multiline_fini(source_p, NULL); |
212380e3 | 105 | } |