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

Annotation of /botnetop.mod/botbinds.c

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


Revision 1.4 - (hide annotations) (download) (as text)
Mon Aug 28 18:23:31 2000 UTC (18 years, 9 months ago) by sup
Branch: MAIN
Changes since 1.3: +35 -18 lines
File MIME type: text/x-chdr
Updated to 0.5.0

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23