9 Usage: $0 server bot-name target-channel
15 my $server = shift or usage;
16 my $botname = shift or usage;
17 my $channel = shift or usage;
19 my $irc = new Net::IRC;
21 my $conn = $irc->newconn(Nick => $botname, Server => $server)
22 or die "$0: can't connect to IRC server";
29 $self->join($channel);
40 my ($self, $event) = @_;
41 my ($args) = $event->args;
42 my $from = $event->from;
44 if ($args =~ s/^$botname:?\s*//io)
46 my ($victim, $task, $tasksref);
47 (my $command, $args) = split ' ', $args, 2;
48 $command = lc $command;
49 if ($command eq 'add' && $args =~ /^([^ \t]+)\s+(.*[^ \t])/)
51 ($victim, $task) = ($1, $2);
52 $tasksref = $tasks{$victim};
53 $tasksref = $tasks{$victim} = [] if not defined $tasksref;
54 $$tasksref[scalar @$tasksref] = $task;
55 $self->privmsg($channel, "cheers, added task for $victim:");
56 $self->privmsg($channel, " $task");
58 elsif ($command eq 'delete' && $args =~ /^([^ \t]+)\s+(.*[^ \t])/)
60 ($victim, $task) = ($1, $2);
61 $tasksref = $tasks{$victim};
62 if (defined $tasksref && scalar grep {$_ eq $task} @$tasksref)
64 @$tasksref = grep {$_ ne $task} @$tasksref;
65 $self->privmsg($channel, "cheers, deleted task for $victim:");
66 $self->privmsg($channel, " $task");
70 $self->privmsg($channel,
71 "sorry, never heard of that task for $victim:");
72 $self->privmsg($channel, " $task");
75 elsif ($command eq 'deleteall' && $args =~ /^([^ \t]+)/)
78 undef $tasks{$victim};
79 $self->privmsg($channel, "$victim is free! For a short time ...");
81 elsif ($command eq 'help')
83 $self->privmsg($channel, "No.");
85 elsif ($command eq 'list' && $args =~ /^([^ \t]+)/)
88 $tasksref = $tasks{$victim};
89 if (defined $tasksref && scalar @{$tasks{$victim}})
91 $self->privmsg($channel, "$victim is supposed to be doing:");
95 $self->privmsg($channel, "No tasks for $victim.");
97 foreach my $task (@{$tasks{$victim}})
99 $self->privmsg($channel, " $task");
102 elsif ($command eq 'quit')
104 $self->privmsg($channel, "They killed $botname! The bastards ...");
111 $conn->add_handler('376', \&on_connect);
112 $conn->add_handler('332', \&on_topic);
113 $conn->add_handler('public', \&on_public);