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

Annotation of /botnetop.mod/botcmds.c

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


Revision 1.5 - (hide annotations) (download) (as text)
Fri Oct 13 20:22:48 2000 UTC (19 years ago) by sup
Branch: MAIN
Changes since 1.4: +68 -44 lines
File MIME type: text/x-chdr
Updated to 1.0.0pre5

1 sup 1.3 /*
2     * botcmds.c -- part of botnetop.mod
3     *
4 sup 1.4 * $Id: botcmds.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 sup 1.3 static void bnop_setneed(char *chname)
25 guppy 1.1 {
26     struct chanset_t *chan = NULL;
27    
28 sup 1.5 if ((chan = findchan_by_dname(chname))) {
29     egg_snprintf(chan->need_op, 120, "bop_reqop %s", chan->dname);
30     egg_snprintf(chan->need_key, 120, "bop_letmein needkey %s", chan->dname);
31     egg_snprintf(chan->need_invite, 120, "bop_letmein needinvite %s", chan->dname);
32     egg_snprintf(chan->need_limit, 120, "bop_letmein needlimit %s", chan->dname);
33     egg_snprintf(chan->need_unban, 120, "bop_letmein needunban %s", chan->dname);
34     }
35 guppy 1.1 }
36    
37 sup 1.3 static void bnop_askbot(char *hand, char *chname)
38 guppy 1.1 {
39 sup 1.5 int i;
40 guppy 1.1 char data[256];
41     struct chanset_t *chan = NULL;
42     struct userrec *u;
43    
44 sup 1.5 if ((chan = findchan_by_dname(chname)) && (ismember(chan, botname)) && (isop(botname, chan))) {
45     u = get_user_by_handle(userlist, hand);
46     if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname)) && (!matchattr(u, "d|d", chan->dname))) {
47     i = nextbot(hand);
48     if (i >= 0) {
49     egg_snprintf(data, sizeof data, "doyawantops %s %s", chan->dname, botname);
50     botnet_send_zapf(i, botnetnick, hand, data);
51     }
52 guppy 1.1 }
53     }
54     }
55    
56 sup 1.3 static void bnop_reqop(char *chname)
57 guppy 1.1 {
58 sup 1.5 int i;
59 guppy 1.1 char data[256];
60     tand_t *bot;
61     struct chanset_t *chan = NULL;
62     struct userrec *u;
63    
64 sup 1.5 if ((chan = findchan_by_dname(chname))) {
65     for (bot = tandbot; bot; bot = bot->next) {
66     u = get_user_by_handle(userlist, bot->bot);
67     if ((handisop(bot->bot, chan)) && (matchattr(u, "o|o", chan->dname))) {
68     i = nextbot(bot->bot);
69     if (i >= 0) {
70     egg_snprintf(data, sizeof data, "reqops %s", chan->dname);
71     botnet_send_zapf(i, botnetnick, bot->bot, data);
72     }
73 guppy 1.1 }
74     }
75     }
76     }
77    
78 sup 1.3 static void bnop_letmein(char *needthis, char *chname)
79 guppy 1.1 {
80 sup 1.5 int i;
81     int bots = 0;
82 guppy 1.1 char data[256];
83     tand_t *bot;
84     struct chanset_t *chan = NULL;
85 sup 1.5 struct needs_t *n = NULL;
86 guppy 1.1 struct userrec *u;
87    
88     if ((!(chan = findchan_by_dname(chname))) || (ismember(chan, botname)))
89     return;
90 sup 1.5 if (!(n = find_needs(chname)))
91     n = add_needs(chname);
92 guppy 1.1 if (!egg_strcasecmp(needthis, "needkey")) {
93 sup 1.5 if (n->key)
94     return;
95     for (bot = tandbot; bot; bot = bot->next) {
96 guppy 1.1 u = get_user_by_handle(userlist, bot->bot);
97     if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname))) {
98     i = nextbot(bot->bot);
99     if (i >= 0) {
100 sup 1.5 egg_snprintf(data, sizeof data, "wantkey %s %s", chan->dname, botname);
101 guppy 1.1 botnet_send_zapf(i, botnetnick, bot->bot, data);
102 sup 1.5 bots++;
103 guppy 1.1 }
104     }
105     }
106 sup 1.5 n->key = 1;
107     n->k_time = now;
108     if ((bop_log >= 1) && (bots > 0))
109     putlog(LOG_MISC, "*", "botnetop.mod: requested key for %s from %d bot%s", chan->dname, bots, bots == 1 ? "" : "s");
110 guppy 1.1 } else if (!egg_strcasecmp(needthis, "needinvite")) {
111 sup 1.5 if (n->invite)
112     return;
113     for (bot = tandbot; bot; bot = bot->next) {
114 guppy 1.1 u = get_user_by_handle(userlist, bot->bot);
115     if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname))) {
116     i = nextbot(bot->bot);
117     if (i >= 0) {
118     if (botuserhost[0])
119 sup 1.5 egg_snprintf(data, sizeof data, "wantinvite %s %s %s", chan->dname, botname, strchr("~+-^=", botuserhost[0]) ? botuserhost + 1 : botuserhost);
120 guppy 1.1 else
121 sup 1.5 egg_snprintf(data, sizeof data, "wantinvite %s %s", chan->dname, botname);
122 guppy 1.1 botnet_send_zapf(i, botnetnick, bot->bot, data);
123 sup 1.5 bots++;
124 guppy 1.1 }
125     }
126     }
127 sup 1.5 n->invite = 1;
128     n->i_time = now;
129     if ((bop_log >= 1) && (bots > 0))
130     putlog(LOG_MISC, "*", "botnetop.mod: requested invite to %s from %d bot%s", chan->dname, bots, bots == 1 ? "" : "s");
131 guppy 1.1 } else if (!egg_strcasecmp(needthis, "needlimit")) {
132 sup 1.5 if (n->limit)
133     return;
134     for (bot = tandbot; bot; bot = bot->next) {
135 guppy 1.1 u = get_user_by_handle(userlist, bot->bot);
136     if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname))) {
137     i = nextbot(bot->bot);
138     if (i >= 0) {
139 sup 1.5 egg_snprintf(data, sizeof data, "wantlimit %s %s", chan->dname, botname);
140 guppy 1.1 botnet_send_zapf(i, botnetnick, bot->bot, data);
141 sup 1.5 bots++;
142 guppy 1.1 }
143     }
144     }
145 sup 1.5 n->limit = 1;
146     n->l_time = now;
147     if ((bop_log >= 1) && (bots > 0))
148     putlog(LOG_MISC, "*", "botnetop.mod: requested limit raise on %s %d bot%s", chan->dname, bots, bots == 1 ? "" : "s");
149 guppy 1.1 } else if (!egg_strcasecmp(needthis, "needunban")) {
150 sup 1.5 if (n->unban)
151     return;
152     for (bot = tandbot; bot; bot = bot->next) {
153 guppy 1.1 u = get_user_by_handle(userlist, bot->bot);
154     if ((matchattr(u, "b|-", chan->dname)) && (matchattr(u, "o|o", chan->dname))) {
155     i = nextbot(bot->bot);
156     if (i >= 0) {
157 sup 1.5 egg_snprintf(data, sizeof data, "wantunban %s %s %s!%s", chan->dname, botname, botname, botuserhost);
158 guppy 1.1 botnet_send_zapf(i, botnetnick, bot->bot, data);
159 sup 1.5 bots++;
160 guppy 1.1 }
161     }
162     }
163 sup 1.5 n->unban = 1;
164     n->u_time = now;
165     if ((bop_log >= 1) && (bots > 0))
166     putlog(LOG_MISC, "*", "botnetop.mod: requested unban on %s from %d bot%s", chan->dname, bots, bots == 1 ? "" : "s");
167 guppy 1.1 }
168     }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23