1) как сделать чтоб он, не на все -msg public- отвечал "Im bot", а чтоб на определенные команды.
2) (1) + команды принимались только от человека $admin
3) чтобы бот отвечал человеку, который написал в приват.
4) и как использовать CTCP requests
5) в чём разница между [$conn->add_global_handler] и
[$conn->add_handler]
1.
sub on_public {
my ($self, $event) = @_;
my $text = $event->{args}[0];
if($text eq 'test') {$self->privmsg($kanal, "Im bot");}
}
2.
sub on_msg {
my ($self, $event) = @_;
my $from = $event->{nick};
if($from eq $admin){ $self->privmsg($admin, "private msg");}
}
3.
sub on_msg {
my ($self, $event) = @_;
my $from = $event->{nick};
$self->privmsg($from, "private msg");
}
5.
# This sub will assign a user's custom function to a particular event which
# might be received by any Connection object.
# Takes 3 args: the event to modify, as either a string or numeric code
# If passed an arrayref, the array is assumed to contain
# all event names which you want to set this handler for.
# a reference to the code to be executed for the event
# (optional) A value indicating whether the user's code should replace
# the built-in handler, or be called with it. Possible values:
# 0 - Replace the built-in handlers entirely. (the default)
# 1 - Call this handler right before the default handler.
# 2 - Call this handler right after the default handler.
# These can also be referred to by the #define-like strings in %define.
sub add_global_handler {
my ($self, $event, $ref, $rp) = @_;
return $self->_add_generic_handler($event, $ref, $rp, \%_udef, 'add_global_handler');
}
# This sub will assign a user's custom function to a particular event which
# this connection might receive. Same args as above.
sub add_handler {
my ($self, $event, $ref, $rp) = @_;
return $self->_add_generic_handler($event, $ref, $rp, $self->{_handler}, 'add_handler');
}