Quite easy. I was trying to write a bot in perl using Net::IRC but ran into troubles trying to do modular commands, and gave up. I did figure out how to change the command char though.
$commandchar="#";
then, later in your code, do
$commandchar = quotemeta $commandchar;
quotemeta escapes anything that could be confused as a regex expression character.. so now you can do
Yes, we've known how we want to do it for a while, but we decided that it was best to move it into 1.3.x development. However, the quotemeta thing is very helpful, thanks a lot.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2000-02-25
in PerlbotCore.pm, bot hashref sub
$commandchar = $_[0]->{commandchar}[0];
# default to '.'
$commandchar or $commandchar = '.';
$regex_commandchar or $regex_commandchar = quotemeta $commandchar;
Quite easy. I was trying to write a bot in perl using Net::IRC but ran into troubles trying to do modular commands, and gave up. I did figure out how to change the command char though.
$commandchar="#";
then, later in your code, do
$commandchar = quotemeta $commandchar;
quotemeta escapes anything that could be confused as a regex expression character.. so now you can do
if(($event->args)[0] =~ /^$commandchar.*/) {
#blah...
}
ookie?
warewolf/efnet
Yes, we've known how we want to do it for a while, but we decided that it was best to move it into 1.3.x development. However, the quotemeta thing is very helpful, thanks a lot.
in PerlbotCore.pm, bot hashref sub
$commandchar = $_[0]->{commandchar}[0];
# default to '.'
$commandchar or $commandchar = '.';
$regex_commandchar or $regex_commandchar = quotemeta $commandchar;
and where to check if it's a command....
if(($event->args)[0] =~ /^$regex_commandchar.*/) {