/[cvs]/botnetop.mod/botcmds.c
ViewVC logotype

Contents of /botnetop.mod/botcmds.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Fri Oct 13 20:22:48 2000 UTC (18 years, 7 months ago) by sup
Branch: MAIN
Changes since 1.4: +68 -44 lines
File MIME type: text/x-chdr
Updated to 1.0.0pre5

1 /*
2 * botcmds.c -- part of botnetop.mod
3 *
4 * $Id: botcmds.c,v 1.3 2000/08/25 20:19:17 sup Exp $
5 */
6 /*
7 * Copyright (C) 2000 Teemu Hjelt <temex@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24 static void bnop_setneed(char *chname)
25 {
26 struct chanset_t *chan = NULL;
27
28 if ((chan = findchan_by_dname(chname))) {
29 egg_snprintf(chan->need_op, 120, "bop_reqop %s", chan->dname);
30 egg_snprintf(chan->need_key, 120, "bop_letmein needkey %s", chan->dname);
31 egg_snprintf(chan->need_invite, 120, "bop_letmein needinvite %s", chan->dname);
32 egg_snprintf(chan->need_limit, 120, "bop_letmein needlimit %s", chan->dname);
33 egg_snprintf(chan->need_unban, 120, "bop_letmein needunban %s", chan->dname);
34 }
35 }
36
37 static void bnop_askbot(char *hand, char *chname)
38 {
39 int i;
40 char data[256];
41 struct chanset_t *chan = NULL;
42 struct userrec *u;
43
44 if ((chan = findchan_by_dname(chname)) && (ismember(chan, botname)) && (isop(botname, chan))) {
45 u = get_user_by_handle(userlist, hand);
46 if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname)) && (!matchattr(u, "d|d", chan->dname))) {
47 i = nextbot(hand);
48 if (i >= 0) {
49 egg_snprintf(data, sizeof data, "doyawantops %s %s", chan->dname, botname);
50 botnet_send_zapf(i, botnetnick, hand, data);
51 }
52 }
53 }
54 }
55
56 static void bnop_reqop(char *chname)
57 {
58 int i;
59 char data[256];
60 tand_t *bot;
61 struct chanset_t *chan = NULL;
62 struct userrec *u;
63
64 if ((chan = findchan_by_dname(chname))) {
65 for (bot = tandbot; bot; bot = bot->next) {
66 u = get_user_by_handle(userlist, bot->bot);
67 if ((handisop(bot->bot, chan)) && (matchattr(u, "o|o", chan->dname))) {
68 i = nextbot(bot->bot);
69 if (i >= 0) {
70 egg_snprintf(data, sizeof data, "reqops %s", chan->dname);
71 botnet_send_zapf(i, botnetnick, bot->bot, data);
72 }
73 }
74 }
75 }
76 }
77
78 static void bnop_letmein(char *needthis, char *chname)
79 {
80 int i;
81 int bots = 0;
82 char data[256];
83 tand_t *bot;
84 struct chanset_t *chan = NULL;
85 struct needs_t *n = NULL;
86 struct userrec *u;
87
88 if ((!(chan = findchan_by_dname(chname))) || (ismember(chan, botname)))
89 return;
90 if (!(n = find_needs(chname)))
91 n = add_needs(chname);
92 if (!egg_strcasecmp(needthis, "needkey")) {
93 if (n->key)
94 return;
95 for (bot = tandbot; bot; bot = bot->next) {
96 u = get_user_by_handle(userlist, bot->bot);
97 if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname))) {
98 i = nextbot(bot->bot);
99 if (i >= 0) {
100 egg_snprintf(data, sizeof data, "wantkey %s %s", chan->dname, botname);
101 botnet_send_zapf(i, botnetnick, bot->bot, data);
102 bots++;
103 }
104 }
105 }
106 n->key = 1;
107 n->k_time = now;
108 if ((bop_log >= 1) && (bots > 0))
109 putlog(LOG_MISC, "*", "botnetop.mod: requested key for %s from %d bot%s", chan->dname, bots, bots == 1 ? "" : "s");
110 } else if (!egg_strcasecmp(needthis, "needinvite")) {
111 if (n->invite)
112 return;
113 for (bot = tandbot; bot; bot = bot->next) {
114 u = get_user_by_handle(userlist, bot->bot);
115 if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname))) {
116 i = nextbot(bot->bot);
117 if (i >= 0) {
118 if (botuserhost[0])
119 egg_snprintf(data, sizeof data, "wantinvite %s %s %s", chan->dname, botname, strchr("~+-^=", botuserhost[0]) ? botuserhost + 1 : botuserhost);
120 else
121 egg_snprintf(data, sizeof data, "wantinvite %s %s", chan->dname, botname);
122 botnet_send_zapf(i, botnetnick, bot->bot, data);
123 bots++;
124 }
125 }
126 }
127 n->invite = 1;
128 n->i_time = now;
129 if ((bop_log >= 1) && (bots > 0))
130 putlog(LOG_MISC, "*", "botnetop.mod: requested invite to %s from %d bot%s", chan->dname, bots, bots == 1 ? "" : "s");
131 } else if (!egg_strcasecmp(needthis, "needlimit")) {
132 if (n->limit)
133 return;
134 for (bot = tandbot; bot; bot = bot->next) {
135 u = get_user_by_handle(userlist, bot->bot);
136 if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname))) {
137 i = nextbot(bot->bot);
138 if (i >= 0) {
139 egg_snprintf(data, sizeof data, "wantlimit %s %s", chan->dname, botname);
140 botnet_send_zapf(i, botnetnick, bot->bot, data);
141 bots++;
142 }
143 }
144 }
145 n->limit = 1;
146 n->l_time = now;
147 if ((bop_log >= 1) && (bots > 0))
148 putlog(LOG_MISC, "*", "botnetop.mod: requested limit raise on %s %d bot%s", chan->dname, bots, bots == 1 ? "" : "s");
149 } else if (!egg_strcasecmp(needthis, "needunban")) {
150 if (n->unban)
151 return;
152 for (bot = tandbot; bot; bot = bot->next) {
153 u = get_user_by_handle(userlist, bot->bot);
154 if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname))) {
155 i = nextbot(bot->bot);
156 if (i >= 0) {
157 egg_snprintf(data, sizeof data, "wantunban %s %s %s!%s", chan->dname, botname, botname, botuserhost);
158 botnet_send_zapf(i, botnetnick, bot->bot, data);
159 bots++;
160 }
161 }
162 }
163 n->unban = 1;
164 n->u_time = now;
165 if ((bop_log >= 1) && (bots > 0))
166 putlog(LOG_MISC, "*", "botnetop.mod: requested unban on %s from %d bot%s", chan->dname, bots, bots == 1 ? "" : "s");
167 }
168 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23