/[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.3 - (show annotations) (download) (as text)
Fri Aug 25 20:19:17 2000 UTC (19 years, 1 month ago) by sup
Branch: MAIN
Changes since 1.2: +7 -4 lines
File MIME type: text/x-chdr
Updated to 0.4.0

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23