Menu

Perl Code receiving-chat-msg

David
2007-06-21
2013-01-14
  • David

    David - 2007-06-21

    Description:
        Emitted when a chat message is received. The callback can replace the name of the sender, the message, or the flags by modifying the pointer to the strings. This can also be used to cancel displaying a message by returning TRUE.

    I would like to replace the message using a perl plugin, but my Perl syntax knowledge is really weak. I can create a working plugin and capture the message from the call back, but the altering the message part so that it appears in Pidgin is giving me trouble.

    The basic callback would look like this:

    sub receiving_chat_msg_cb {
        my ($account, $sender, $message, $conv, $flag) = @_;
        Purple::Debug::info("testplugin", "$sender : $message");
    }

    What would I need to do to alter the message?

     
    • Etan Reisner

      Etan Reisner - 2007-06-22

      I believe you just need to change the correct items in @_, so something like $_[2] = "foobar";.

       
    • David

      David - 2007-06-22

      Thanks, that was exactly what I needed. I thought it was an array but wasn't sure of the syntax.

      I looked it up, PERL sure is full of lazy catch-all variables.