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

Contents of /botnetop.mod/botbinds.c

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


Revision 1.6 - (show annotations) (download) (as text)
Tue Feb 13 18:23:24 2001 UTC (18 years, 4 months ago) by sup
Branch: MAIN
Changes since 1.5: +2 -2 lines
File MIME type: text/x-chdr
Updated to 1.0.1

1 /*
2 * botbinds.c -- part of botnetop.mod
3 *
4 * $Id: botbinds.c,v 1.5 2000/10/13 20:22:48 sup Exp $
5 */
6 /*
7 * Copyright (C) 2000, 2001 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 int bnop_linkop(char *bot, char *via)
25 {
26 struct chanset_t *chan = NULL;
27
28 if ((bop_linkop) && ((!egg_strcasecmp(bot, botnetnick)) || (!egg_strcasecmp(via, botnetnick)))) {
29 for (chan = chanset; chan; chan = chan->next) {
30 if ((ismember(chan, botname)) && (!isop(botname, chan)))
31 bnop_reqop(chan->dname);
32 }
33 }
34 return 0;
35 }
36
37 static int bnop_doiwantops(char *bot, char *code, char *par)
38 {
39 int i;
40 char *chname, *fromnick, data[256];
41 struct chanset_t *chan = NULL;
42 struct delay_t *d = NULL;
43 struct userrec *u;
44 memberlist *m;
45
46 chname = newsplit(&par);
47 fromnick = newsplit(&par);
48 if ((!chname[0]) || (!fromnick[0]))
49 return 0;
50 if ((chan = findchan_by_dname(chname)) && (ismember(chan, botname)) && (!isop(botname, chan))) {
51 u = get_user_by_handle(userlist, bot);
52 if ((m = ismember(chan, fromnick)) && (!chan_issplit(m)) && (isop(fromnick, chan)) && (matchattr(u, "o|o", chan->dname))) {
53 i = nextbot(bot);
54 if (i >= 0) {
55 if (bop_maxreq) {
56 if (!(d = find_delay(chname)))
57 d = add_delay(chname, bot);
58 d->reqs++;
59 if (d->reqs >= bop_maxreq + 1) {
60 if (d->reqs == bop_maxreq + 1)
61 d->resptime = now + 30;
62 return 0;
63 }
64 d->resptime = now + 30;
65 }
66 egg_snprintf(data, sizeof data, "yesiwantops %s %s %s", chan->dname, botname, strchr("~+-^=", botuserhost[0]) ? botuserhost + 1 : botuserhost);
67 botnet_send_zapf(i, botnetnick, bot, data);
68 if (bop_log >= 2)
69 putlog(LOG_MISC, "*", "botnetop.mod: requested ops from %s on %s", bot, chan->dname);
70 }
71 }
72 }
73 return 0;
74 }
75
76 static int bnop_botwantsops(char *bot, char *code, char *par)
77 {
78 char *chname, *fromnick, *fromhost, s[UHOSTLEN];
79 struct chanset_t *chan = NULL;
80 struct userrec *u;
81 memberlist *m;
82
83 chname = newsplit(&par);
84 fromnick = newsplit(&par);
85 fromhost = newsplit(&par);
86 if ((!chname[0]) || (!fromnick[0]))
87 return 0;
88 if ((!(chan = findchan_by_dname(chname))) || (!ismember(chan, botname)) || (!isop(botname, chan)))
89 return 0;
90 u = get_user_by_handle(userlist, bot);
91 if ((m = ismember(chan, fromnick)) && (!chan_issplit(m)) && (matchattr(u, "b|-", chan->dname)) &&
92 (matchattr(u, "o|o", chan->dname)) && (!matchattr(u, "d|d", chan->dname))) {
93 egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
94 u = get_user_by_host(s);
95 if (!matchattr(u, "o|o", chan->dname)) {
96 if ((!fromhost[0]) || (!bop_addhost))
97 return 0;
98 if (strchr("~^+=-", m->userhost[0]))
99 egg_snprintf(s, sizeof s, "*!%s%s", strict_host ? "?" : "", m->userhost + 1);
100 else
101 egg_snprintf(s, sizeof s, "*!%s", m->userhost);
102 addhost_by_handle(bot, s);
103 putlog(LOG_MISC, "*", "botnetop.mod: added host %s to %s", s, bot);
104 }
105 if (!isop(fromnick, chan))
106 add_mode(chan, '+', 'o', fromnick);
107 else if ((bop_osync) && (isop(fromnick, chan)))
108 dprintf(DP_MODE, "MODE %s +o %s\n", chan->dname, fromnick);
109 if (bop_log >= 2) {
110 if (egg_strcasecmp(fromnick, bot))
111 putlog(LOG_MISC, "*", "botnetop.mod: gave ops to %s (using nick %s) on %s", bot, fromnick, chan->dname);
112 else
113 putlog(LOG_MISC, "*", "botnetop.mod: gave ops to %s on %s", bot, chan->dname);
114 }
115 }
116 return 0;
117 }
118
119 static int bnop_botwantsin(char *bot, char *code, char *par)
120 {
121 int i, bans = 0;
122 char *chname, *fromnick, *fromhost, data[256];
123 struct chanset_t *chan = NULL;
124 struct who_t *w = NULL;
125 struct userrec *u;
126 masklist *b;
127
128 chname = newsplit(&par);
129 fromnick = newsplit(&par);
130 fromhost = newsplit(&par);
131 if ((!chname[0]) || (!(chan = findchan_by_dname(chname))) || (!isop(botname, chan)))
132 return 0;
133 u = get_user_by_handle(userlist, bot);
134 if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "fo|fo", chan->dname))) {
135 i = nextbot(bot);
136 if (i < 0)
137 return 0;
138 if (!egg_strcasecmp(code, "wantkey")) {
139 if (chan->channel.mode & CHANKEY) {
140 egg_snprintf(data, sizeof data, "thekey %s %s", chan->dname, chan->channel.key);
141 botnet_send_zapf(i, botnetnick, bot, data);
142 if (bop_log >= 1)
143 putlog(LOG_MISC, "*", "botnetop.mod: gave key for %s to %s", chan->dname, bot);
144 }
145 } else if (!egg_strcasecmp(code, "wantinvite")) {
146 if (chan->channel.mode & CHANINV) {
147 if (!fromnick[0])
148 return 0;
149 if ((bop_icheck) && (fromhost[0])) {
150 if (!(w = find_who(fromnick)))
151 w = add_who(fromnick, chname, bot, fromhost);
152 dprintf(DP_SERVER, "USERHOST %s\n", fromnick);
153 } else {
154 dprintf(DP_SERVER, "INVITE %s %s\n", fromnick, chan->dname);
155 if (bop_log >= 1) {
156 if (egg_strcasecmp(fromnick, bot))
157 putlog(LOG_MISC, "*", "botnetop.mod: invited %s (using nick %s) to %s", bot, fromnick, chan->dname);
158 else
159 putlog(LOG_MISC, "*", "botnetop.mod: invited %s to %s", bot, chan->dname);
160 }
161 }
162 }
163 } else if (!egg_strcasecmp(code, "wantlimit")) {
164 if (chan->channel.maxmembers > -1) {
165 add_mode(chan, '+', 'l', int_to_base10(chan->channel.members + 1));
166 if (bop_log >= 1)
167 putlog(LOG_MISC, "*", "botnetop.mod: raised limit on %s as requested by %s", chan->dname, bot);
168 }
169 } else if (!egg_strcasecmp(code, "wantunban")) {
170 if (!fromhost[0])
171 return 0;
172 for (b = chan->channel.ban; b->mask[0]; b = b->next) {
173 if (wild_match(b->mask, fromhost)) {
174 add_mode(chan, '-', 'b', b->mask);
175 bans++;
176 }
177 }
178 if ((bop_log >= 1) && (bans > 0))
179 putlog(LOG_MISC, "*", "botnetop.mod: unbanned %s on %s", bot, chan->dname);
180 }
181 }
182 return 0;
183 }
184
185 static int bnop_reqtmr(char *bot, char *code, char *par)
186 {
187 char *chname;
188 struct chanset_t *chan = NULL;
189 struct delay_t *d = NULL;
190 struct userrec *u;
191
192 chname = newsplit(&par);
193 if ((chname[0]) && (chan = findchan_by_dname(chname))) {
194 u = get_user_by_handle(userlist, bot);
195 if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname)) && (!matchattr(u, "d|d", chan->dname))) {
196 if ((bop_delay) && (!lowbots(chan))) {
197 if (!(d = find_delay(chname)))
198 d = add_delay(chname, bot);
199 d->reqtime = now + (random() % bop_delay) + 2;
200 strncpyz(d->bot, bot, sizeof d->bot);
201 } else
202 bnop_askbot(bot, chan->dname);
203 }
204 }
205 return 0;
206 }
207
208 static int bnop_joinkey(char *bot, char *code, char *par)
209 {
210 char *chname, *key;
211 struct chanset_t *chan = NULL;
212 struct needs_t *n = NULL;
213
214 chname = newsplit(&par);
215 key = newsplit(&par);
216 if ((chname[0]) && (key[0]) && (chan = findchan_by_dname(chname)) && (!ismember(chan, botname))) {
217 if (!(n = find_needs(chname)))
218 n = add_needs(chname);
219 if (n->kjoin)
220 return 0;
221 dprintf(DP_SERVER, "JOIN %s %s\n", chan->dname, key);
222 n->kjoin = 1;
223 n->kjoin_time = now;
224 }
225 return 0;
226 }
227
228 static cmd_t botnetop_bot[] =
229 {
230 {"doyawantops", "", (Function) bnop_doiwantops, "bop_doiwantops"},
231 {"yesiwantops", "", (Function) bnop_botwantsops, "bop_botwantsops"},
232 {"reqops", "", (Function) bnop_reqtmr, "bop_reqtmr"},
233 {"wantkey", "", (Function) bnop_botwantsin, "bop_botwantsin"},
234 {"wantinvite", "", (Function) bnop_botwantsin, "bop_botwantsin"},
235 {"wantlimit", "", (Function) bnop_botwantsin, "bop_botwantsin"},
236 {"wantunban", "", (Function) bnop_botwantsin, "bop_botwantsin"},
237 {"thekey", "", (Function) bnop_joinkey, "bop_joinkey"},
238 {0, 0, 0, 0}
239 };
240
241 static cmd_t botnetop_link[] =
242 {
243 {"*", "", (Function) bnop_linkop, "bop_linkop"},
244 {0, 0, 0, 0}
245 };

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23