/[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.1.1.1 - (hide annotations) (download) (as text) (vendor branch)
Mon Aug 14 01:41:03 2000 UTC (18 years, 10 months ago) by guppy
Branch: botnetop
CVS Tags: botnetop1
Changes since 1.1: +0 -0 lines
File MIME type: text/x-chdr
first checkin

1 guppy 1.1 /*
2     * Copyright (C) 2000 Teemu Hjelt <temex@iki.fi>
3     *
4     * This program is free software; you can redistribute it and/or
5     * modify it under the terms of the GNU General Public License
6     * as published by the Free Software Foundation; either version 2
7     * of the License, or (at your option) any later version.
8     *
9     * This program is distributed in the hope that it will be useful,
10     * but WITHOUT ANY WARRANTY; without even the implied warranty of
11     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12     * GNU General Public License for more details.
13     *
14     * You should have received a copy of the GNU General Public License
15     * along with this program; if not, write to the Free Software
16     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17     */
18    
19     static int bnop_linkop(char *bot, char *via)
20     {
21     struct chanset_t *chan = NULL;
22    
23     if (bop_linkop)
24     if ((!egg_strcasecmp(bot, botnetnick)) || (!egg_strcasecmp(via, botnetnick)))
25     for (chan = chanset; chan != NULL; chan = chan->next)
26     if ((ismember(chan, botname)) && (!isop(botname, chan->dname)))
27     bnop_reqop(chan->dname);
28     return 0;
29     }
30    
31     static int bnop_doiwantops(char *bot, char *code, char *par)
32     {
33     char *chname, *fromnick, data[256];
34     int i;
35     struct chanset_t *chan = NULL;
36     struct userrec *u;
37     memberlist *m;
38    
39     chname = newsplit(&par);
40     fromnick = newsplit(&par);
41     u = get_user_by_handle(userlist, bot);
42     if ((chan = findchan_by_dname(chname)) && (ismember(chan, botname)) && (!isop(botname, chan->dname)) && (m = ismember(chan, fromnick)) && (m && !chan_issplit(m)) && (isop(fromnick, chan->dname)) && (matchattr(u, "o|o", chan->dname))) {
43     i = nextbot(bot);
44     if (i >= 0) {
45     sprintf(data, "yesiwantops %s %s %s", chan->dname, botname, strchr("~+-^=", botuserhost[0]) ? (botuserhost + 1) : botuserhost);
46     botnet_send_zapf(i, botnetnick, bot, data);
47     if (bop_log >= 2)
48     putlog(LOG_MISC, "*", "botnetop.mod: requested ops from %s on %s", bot, chan->dname);
49     }
50     }
51     return 0;
52     }
53    
54     static int bnop_botwantsops(char *bot, char *code, char *par)
55     {
56     char *chname, *fromnick, *fromhost, s[UHOSTLEN];
57     struct chanset_t *chan = NULL;
58     struct userrec *u;
59     memberlist *m;
60    
61     chname = newsplit(&par);
62     fromnick = newsplit(&par);
63     fromhost = newsplit(&par);
64     u = get_user_by_handle(userlist, bot);
65     if ((chan = findchan_by_dname(chname)) && (ismember(chan, botname)) && (isop(botname, chan->dname)) && (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))) {
66     egg_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
67     u = get_user_by_host(s);
68     if (!matchattr(u, "o|o", chan->dname)) {
69     if ((!fromhost[0]) || (!bop_addhost))
70     return 0;
71     sprintf(s, "*!%s", (!strict_host) && (strchr("~+-^=", m->userhost[0])) ? (m->userhost + 1) : m->userhost);
72     addhost_by_handle(bot, s);
73     putlog(LOG_MISC, "*", "botnetop.mod: added host %s to %s", s, bot);
74     }
75     if (!bop_osync && isop(fromnick, chan->dname))
76     return 0;
77     else if (bop_osync && isop(fromnick, chan->dname))
78     dprintf(DP_SERVER, "MODE %s +o %s", chan->dname, fromnick);
79     else
80     add_mode(chan, '+', 'o', fromnick);
81     if (bop_log >= 2) {
82     if (egg_strcasecmp(fromnick, bot))
83     putlog(LOG_MISC, "*", "botnetop.mod: gave ops to %s (using nick %s) on %s", bot, fromnick, chan->dname);
84     else
85     putlog(LOG_MISC, "*", "botnetop.mod: gave ops to %s on %s", bot, chan->dname);
86     }
87     }
88     return 0;
89     }
90    
91     static int bnop_botwantsin(char *bot, char *code, char *par)
92     {
93     char *chname, *fromnick, *fromhost, data[256];
94     int i;
95     struct chanset_t *chan = NULL;
96     struct userrec *u;
97     masklist *b;
98    
99     chname = newsplit(&par);
100     fromnick = newsplit(&par);
101     fromhost = newsplit(&par);
102     u = get_user_by_handle(userlist, bot);
103     if ((chan = findchan_by_dname(chname)) && (isop(botname, chan->dname)) && (matchattr(u, "b|-", chan->dname)) && (matchattr(u, "fo|fo", chan->dname))) {
104     i = nextbot(bot);
105     if (i < 0)
106     return 0;
107     if (!egg_strcasecmp(code, "wantkey")) {
108     if (chan->channel.mode & CHANKEY) {
109     sprintf(data, "thekey %s %s", chan->dname, chan->channel.key);
110     botnet_send_zapf(i, botnetnick, bot, data);
111     if (bop_log >= 1)
112     putlog(LOG_MISC, "*", "botnetop.mod: gave key for %s to %s", chan->dname, bot);
113     }
114     } else if (!egg_strcasecmp(code, "wantinvite")) {
115     if (chan->channel.mode & CHANINV) {
116     dprintf(DP_SERVER, "INVITE %s %s", fromnick, chan->dname);
117     if (bop_log >= 1) {
118     if (egg_strcasecmp(fromnick, bot))
119     putlog(LOG_MISC, "*", "botnetop.mod: invited %s (using nick %s) to %s", bot, fromnick, chan->dname);
120     else
121     putlog(LOG_MISC, "*", "botnetop.mod: invited %s to %s", bot, chan->dname);
122     }
123     }
124     } else if (!egg_strcasecmp(code, "wantlimit")) {
125     if (chan->channel.maxmembers > -1) {
126     add_mode(chan, '+', 'l', int_to_base10(chan->channel.members+1));
127     if (bop_log >= 1)
128     putlog(LOG_MISC, "*", "botnetop.mod: raised limit on %s as requested by %s", chan->dname, bot);
129     }
130     } else if (!egg_strcasecmp(code, "wantunban")) {
131     for (b = chan->channel.ban; b->mask[0]; b = b->next)
132     if (wild_match(b->mask, fromhost))
133     add_mode(chan, '-', 'b', b->mask);
134     if (bop_log >= 1)
135     putlog(LOG_MISC, "*", "botnetop.mod: unbanned %s on %s", bot, chan->dname);
136     }
137     }
138     return 0;
139     }
140    
141     static int bnop_reqtmr(char *bot, char *code, char *par)
142     {
143     char *chname;
144     struct chanset_t *chan = NULL;
145     struct userrec *u;
146    
147     chname = newsplit(&par);
148     u = get_user_by_handle(userlist, bot);
149     if ((chan = findchan_by_dname(chname)) && (matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname)) && (!matchattr(u, "d|d", chan->dname)))
150     bnop_askbot(bot, chan->dname);
151     return 0;
152     }
153    
154     static int bnop_joinkey(char *bot, char *code, char *par)
155     {
156     char *chname, *key;
157     struct chanset_t *chan = NULL;
158    
159     chname = newsplit(&par);
160     key = newsplit(&par);
161     if ((chan = findchan_by_dname(chname)) && (!ismember(chan, botname)))
162     dprintf(DP_MODE, "JOIN %s %s\n", chan->dname, key);
163     return 0;
164     }
165    
166     static cmd_t botnetop_bot[] =
167     {
168     {"doyawantops", "", (Function) bnop_doiwantops, 0},
169     {"yesiwantops", "", (Function) bnop_botwantsops, 0},
170     {"reqops", "", (Function) bnop_reqtmr, 0},
171     {"wantkey", "", (Function) bnop_botwantsin, 0},
172     {"wantinvite", "", (Function) bnop_botwantsin, 0},
173     {"wantlimit", "", (Function) bnop_botwantsin, 0},
174     {"wantunban", "", (Function) bnop_botwantsin, 0},
175     {"thekey", "", (Function) bnop_joinkey, 0},
176     {0, 0, 0, 0}
177     };
178    
179     static cmd_t botnetop_link[] =
180     {
181     {"*", "", (Function) bnop_linkop, "botnetop"},
182     {0, 0, 0, 0}
183     };

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23