/[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.2 - (show annotations) (download) (as text)
Mon Aug 14 01:47:33 2000 UTC (18 years, 9 months ago) by guppy
Branch: MAIN
Changes since 1.1: +2 -0 lines
File MIME type: text/x-chdr
added Id tags

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23