Menu

user defined command character support

Help
Anonymous
2000-02-24
2000-02-25
  • Anonymous

    Anonymous - 2000-02-24

    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

     
    • Andrew Burke

      Andrew Burke - 2000-02-25

      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.

       
      • Anonymous

        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;

        and where to check if it's a command....

          if(($event->args)[0] =~ /^$regex_commandchar.*/) {

         

Log in to post a comment.