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 =~ /^part(\s+(\S+))?$/i) {
130 return $noreply unless (&hasFlag("o"));
133 if ($jchan !~ /^$mask{chan}$/) {
134 &msg($who, "error, invalid chan.");
139 if (!&validChan($jchan)) {
140 &msg($who, "error, I'm not on that chan.");
144 &msg($jchan, "Leaving. (courtesy of $who).");
150 if ($message =~ /^ignore(\s+(\S+))?$/i) {
151 return $noreply unless (&hasFlag("o"));
159 my $expire = $param{'ignoreTempExpire'} || 60;
160 $ignoreList{$what} = time() + ($expire * 60);
161 &status("ignoring $what at $who's request");
162 &msg($who, "added $what to the ignore list");
168 if ($message =~ /^unignore(\s+(\S+))?$/i) {
169 return $noreply unless (&hasFlag("o"));
177 if ($ignoreList{$what}) {
178 &status("unignoring $what at $userHandle's request");
179 delete $ignoreList{$what};
180 &msg($who, "removed $what from the ignore list");
182 &status("unignore FAILED for $1 at $who's request");
183 &msg($who, "no entry for $1 on the ignore list");
188 # clear unignore list.
189 if ($message =~ /^clear ignorelist$/i) {
190 return $noreply unless (&hasFlag("o"));
192 &status("unignoring all ($who said the word)");
197 # lobotomy. sometimes we want the bot to be _QUIET_.
198 if ($message =~ /^(lobotomy|bequiet)$/i) {
199 return $noreply unless (&hasFlag("o"));
202 &performReply("i'm already lobotomized");
204 &performReply("i have been lobotomized");
212 if ($message =~ /^(unlobotomy|benoisy)$/i) {
213 return $noreply unless (&hasFlag("o"));
215 &performReply("i have been unlobotomized, woohoo");
218 &performReply("i'm not lobotomized");
224 if ($message =~ /^op(\s+(.*))?$/i) {
225 return $noreply unless (&hasFlag("o"));
230 if ($opee =~ /^(\S+)\s+(\S+)$/) {
233 if (!&validChan($2)) {
234 &msg($who,"error: invalid chan ($2).");
238 &msg($who,"error: invalid params.");
242 @chans = keys %channels;
248 next unless (&IsNickInChan($opee,$_));
250 if ($channels{$_}{'o'}{$opee}) {
251 &status("op: $opee already has ops on $_");
256 &status("opping $opee on $_ at ${who}'s request");
257 &performStrictReply("opping $opee on $_");
262 &status("op: opped on all possible channels.");
264 &DEBUG("found => '$found'.");
265 &DEBUG("op => '$op'.");
272 if ($message =~ /^deop(\s+(.*))?$/i) {
273 return $noreply unless (&hasFlag("o"));
278 if ($opee =~ /^(\S+)\s+(\S+)$/) {
281 if (!&validChan($2)) {
282 &msg($who,"error: invalid chan ($2).");
286 &msg($who,"error: invalid params.");
290 @chans = keys %channels;
296 next unless (&IsNickInChan($opee,$_));
298 if (!exists $channels{$_}{'o'}{$opee}) {
299 &status("deop: $opee already has no ops on $_");
304 &status("deopping $opee on $_ at ${who}'s request");
309 &status("deop: deopped on all possible channels.");
311 &DEBUG("deop: found => '$found'.");
312 &DEBUG("deop: op => '$op'.");
319 if ($message =~ s/^say\s+(\S+)\s+(.*)//) {
320 return $noreply unless (&hasFlag("o"));
321 my ($chan,$msg) = (lc $1, $2);
322 &DEBUG("chan => '$1', msg => '$msg'.");
324 if (&validChan($chan)) {
327 &msg($who,"i'm not on \002$1\002, sorry.");
333 if ($message =~ /^die$/) {
334 return $noreply unless (&hasFlag("n"));
338 status("Dying by $who\'s request");
343 if ($message =~ /^jump(\s+(\S+))?$/i) {
344 return $noreply unless (&hasFlag("n"));
352 if ($2 =~ /^(\S+)(:(\d+))?$/) {
356 &msg($who,"invalid format.");
360 &status("jumping servers... $server...");
361 &rawout("QUIT :jumping to $server");
363 if (&irc($server,$port) == 0) {
369 if ($message =~ /^reload$/i) {
370 return $noreply unless (&hasFlag("n"));
372 &status("USER reload $who");
373 &msg($who,"reloading...");
375 &msg($who,"reloaded.");
381 if ($message =~ /^rehash$/) {
382 return $noreply unless (&hasFlag("n"));
384 &msg($who,"rehashing...");
386 &status("USER rehash $who");
387 &msg($who,"rehashed");
393 if ($message =~ /^set(\s+(\S+)?(\s+(.*))?)?$/i) {
394 return $noreply unless (&hasFlag("n"));
395 my ($param,$what) = ($2,$4);
397 if ($param eq "" and $what eq "") {
398 &msg($who,"\002Usage\002: set <param> [what]");
402 if (!exists $param{$param}) {
403 &msg($who,"error: param{$param} cannot be set");
408 if ($param{$param} eq "") {
409 &msg($who,"param{$param} has \002no value\002.");
411 &msg($who,"param{$param} has value of '\002$param{$param}\002'.");
416 if ($param{$param} eq $what) {
417 &msg($who,"param{$param} already has value of '\002$what\002'.");
421 $param{$param} = $what;
422 &msg($who,"setting param{$param} to '\002$what\002'.");
428 if ($message =~ /^unset(\s+(\S+))?$/i) {
429 return $noreply unless (&hasFlag("n"));
433 &msg($who,"\002Usage\002: unset <param>");
437 if (!exists $param{$param}) {
438 &msg($who,"error: \002$param\002 cannot be unset");
442 if ($param{$param} == 0) {
443 &msg($who,"\002param{$param}\002 has already been unset.");
448 &msg($who,"unsetting \002param{$param}\002.");