2 # UserDCC.pl: User Commands, DCC CHAT.
4 # Version: v0.1 (20000707)
5 # Created: 20000707 (from UserExtra.pl)
8 if (&IsParam("useStrict")) { use strict; }
16 if ($message =~ /^(exit|quit)$/i) {
17 # do ircII clients support remote close? if so, cool!
18 &status("userDCC: quit called. FIXME");
19 ### $irc->removeconn($dcc{'CHAT'}{lc $who});
25 if ($message =~ /^who$/i) {
26 my $count = scalar(keys %{$dcc{'CHAT'}});
27 &performStrictReply("Start of who ($count users).");
28 foreach (keys %{$dcc{'CHAT'}}) {
29 &performStrictReply("=> $_");
31 &performStrictReply("End of who.");
36 ### for those users with enough flags.
39 if ($message =~ /^4op(\s+($mask{chan}))?$/i) {
40 return $noreply unless (&hasFlag("o"));
49 if (!$channels{$chan}{'o'}{$ident}) {
50 &msg($who, "i don't have ops on $chan to do that.");
54 # on non-4mode(<4) servers, this may be exploited.
55 if ($channels{$chan}{'o'}{$who}) {
56 rawout("MODE $chan -o+o-o+o". (" $who" x 4));
58 rawout("MODE $chan +o-o+o-o". (" $who" x 4));
65 if ($message =~ /^backlog(\s+(.*))?$/i) {
66 return $noreply unless (&hasFlag("o"));
67 return $noreply unless (&hasParam("backlog"));
69 my $max = $param{'backlog'};
74 } elsif ($num !~ /^\d+/) {
75 &msg($who, "error: argument is not positive integer.");
77 } elsif ($num > $max or $num < 0) {
78 &msg($who, "error: argument is out of range (max $max).");
82 &msg($who, "Start of backlog...");
84 sleep 1 if ($_ % 4 == 0 and $_ != 0);
85 $conn->privmsg($who, "[".($_+1)."]: $backlog[$max-$num+$_]");
87 &msg($who, "End of backlog.");
93 if ($message =~ /^dumpvars$/i) {
94 return $noreply unless (&hasFlag("o"));
95 return '' unless (&IsParam("dumpvars"));
97 &status("Dumping all variables...");
104 if ($message =~ /^kick(\s+(\S+)(\s+(\S+))?)?/) {
105 return $noreply unless (&hasFlag("o"));
106 my ($nick,$chan) = (lc $2,lc $4);
113 if (&validChan($chan) == 0) {
114 &msg($who,"error: invalid channel \002$chan\002");
118 if (&IsNickInChan($nick,$chan) == 0) {
119 &msg($who,"$nick is not in $chan.");
129 if ($message =~ /^ignore(\s+(\S+))?$/i) {
130 return $noreply unless (&hasFlag("o"));
138 my $expire = $param{'ignoreTempExpire'} || 60;
139 $ignoreList{$what} = time() + ($expire * 60);
140 &status("ignoring $what at $who's request");
141 &msg($who, "added $what to the ignore list");
147 if ($message =~ /^unignore(\s+(\S+))?$/i) {
148 return $noreply unless (&hasFlag("o"));
156 if ($ignoreList{$what}) {
157 &status("unignoring $what at $userHandle's request");
158 delete $ignoreList{$what};
159 &msg($who, "removed $what from the ignore list");
161 &status("unignore FAILED for $1 at $who's request");
162 &msg($who, "no entry for $1 on the ignore list");
167 # clear unignore list.
168 if ($message =~ /^clear ignorelist$/i) {
169 return $noreply unless (&hasFlag("o"));
171 &status("unignoring all ($who said the word)");
176 # lobotomy. sometimes we want the bot to be _QUIET_.
177 if ($message =~ /^(lobotomy|bequiet)$/i) {
178 return $noreply unless (&hasFlag("o"));
181 &performReply("i'm already lobotomized");
183 &performReply("i have been lobotomized");
191 if ($message =~ /^(unlobotomy|benoisy)$/i) {
192 return $noreply unless (&hasFlag("o"));
194 &performReply("i have been unlobotomized, woohoo");
197 &performReply("i'm not lobotomized");
203 if ($message =~ /^op(\s+(.*))?$/i) {
204 return $noreply unless (&hasFlag("o"));
209 if ($opee =~ /^(\S+)\s+(\S+)$/) {
212 if (!&validChan($2)) {
213 &msg($who,"error: invalid chan ($2).");
217 &msg($who,"error: invalid params.");
221 @chans = keys %channels;
227 next unless (&IsNickInChan($opee,$_));
229 if ($channels{$_}{'o'}{$opee}) {
230 &status("op: $opee already has ops on $_");
235 &status("opping $opee on $_ at ${who}'s request");
236 &performStrictReply("opping $opee on $_");
241 &status("op: opped on all possible channels.");
243 &DEBUG("found => '$found'.");
244 &DEBUG("op => '$op'.");
251 if ($message =~ /^deop(\s+(.*))?$/i) {
252 return $noreply unless (&hasFlag("o"));
257 if ($opee =~ /^(\S+)\s+(\S+)$/) {
260 if (!&validChan($2)) {
261 &msg($who,"error: invalid chan ($2).");
265 &msg($who,"error: invalid params.");
269 @chans = keys %channels;
275 next unless (&IsNickInChan($opee,$_));
277 if (!exists $channels{$_}{'o'}{$opee}) {
278 &status("deop: $opee already has no ops on $_");
283 &status("deopping $opee on $_ at ${who}'s request");
288 &status("deop: deopped on all possible channels.");
290 &DEBUG("deop: found => '$found'.");
291 &DEBUG("deop: op => '$op'.");
298 if ($message =~ s/^say\s+(\S+)\s+(.*)//) {
299 return $noreply unless (&hasFlag("o"));
300 my ($chan,$msg) = (lc $1, $2);
301 &DEBUG("chan => '$1', msg => '$msg'.");
303 if (&validChan($chan)) {
306 &msg($who,"i'm not on \002$1\002, sorry.");
312 if ($message =~ /^die$/) {
313 return $noreply unless (&hasFlag("n"));
317 status("Dying by $who\'s request");
322 if ($message =~ /^jump(\s+(\S+))?$/i) {
323 return $noreply unless (&hasFlag("n"));
331 if ($2 =~ /^(\S+)(:(\d+))?$/) {
335 &msg($who,"invalid format.");
339 &status("jumping servers... $server...");
340 &rawout("QUIT :jumping to $server");
342 if (&irc($server,$port) == 0) {
348 if ($message =~ /^reload$/i) {
349 return $noreply unless (&hasFlag("n"));
351 &status("USER reload $who");
352 &msg($who,"reloading...");
354 &msg($who,"reloaded.");
360 if ($message =~ /^rehash$/) {
361 return $noreply unless (&hasFlag("n"));
363 &msg($who,"rehashing...");
365 &status("USER rehash $who");
366 &msg($who,"rehashed");
372 if ($message =~ /^set(\s+(\S+)?(\s+(.*))?)?$/i) {
373 return $noreply unless (&hasFlag("n"));
374 my ($param,$what) = ($2,$4);
376 if ($param eq "" and $what eq "") {
377 &msg($who,"\002Usage\002: set <param> [what]");
381 if (!exists $param{$param}) {
382 &msg($who,"error: param{$param} cannot be set");
387 if ($param{$param} eq "") {
388 &msg($who,"param{$param} has \002no value\002.");
390 &msg($who,"param{$param} has value of '\002$param{$param}\002'.");
395 if ($param{$param} eq $what) {
396 &msg($who,"param{$param} already has value of '\002$what\002'.");
400 $param{$param} = $what;
401 &msg($who,"setting param{$param} to '\002$what\002'.");
407 if ($message =~ /^unset(\s+(\S+))?$/i) {
408 return $noreply unless (&hasFlag("n"));
412 &msg($who,"\002Usage\002: unset <param>");
416 if (!exists $param{$param}) {
417 &msg($who,"error: \002$param\002 cannot be unset");
421 if ($param{$param} == 0) {
422 &msg($who,"\002param{$param}\002 has already been unset.");
427 &msg($who,"unsetting \002param{$param}\002.");