Perl Plugin: Send Pidgin User a Message

Etan Reisner pidgin at unreliablesource.net
Mon Dec 14 22:04:48 EST 2009


On Mon, Dec 14, 2009 at 03:36:30PM -0600, Tom Krizan wrote:
> Hi all,
> I would like to send the user of Pidgin a message on an event.  The
> documentation told me to use:
> print "Message";
> But I get this error in the debug window:
> (15:10:31) oscar: incomingim_ch1: unknown TLV 0x0013 (len 1)
> (15:10:31) oscar: Received IM from tom with 1 parts

This message almost certainly has nothing to do with your plugin, 'print
"message";' in your plugin however is likely not doing anything resembling
what you want it to do though.

> If I delete the print "Message"; part, the plugin works fine.

What exactly breaks when you include that print line? Does the plugin load
and simply not work? Does it not load? Does the Debug Window say anything
different (other than the above message)?

> Also,
> there should be another item that sends text to both users but that
> does not happen (the print error kills it?).  I tried
> $im->conv_write("message"); but that sends the message to both users
> (whereas I only want the Pidgin user to see it.)

I'm assuming you mean $im->conv_im_write? And I'm further assuming you
actually gave it all the arguments it requires? Assuming that is the case
that should only have written the message locally, however depending on
when you did it you may very well have simply not cancelled the
incoming/outgoing message that triggered it (which given your comments
later in your email sounds likely).

> If I'm unclear, I want a message to be sent to the Pidgin User, but
> not the chat buddy.  For an example, when sending a file to someone,
> Pidgin says "Attempting to start file transfer of ..." and you'll
> notice that that is only in the Pidgin users window.  The Chat buddy
> see's "Tom is attempting to send you a file."

The $im->conv_im_write, $chat->conv_chat_write, and $conv->write functions
should do just that.

> While we're at it, I manipulate the conversation so that my sent
> message is changed, but the conversation still sees both messages.
> How can I stop the original message?
> My Code:
> 			my $im;
> 			my @convs = Purple::get_conversations();
> 			foreach my $conv (@convs) {
> 				$im = $conv->get_im_data() and last if $conv->get_name eq $sender;
> 			}
> $im->send("My manipulated message is: $message"); #BUG: Shows both
> users the message but sends the original non-manipulated message
> 	}
>
> I want only the above to be sent, getting rid of the original message.

Where is this code? This code cannot possibly prevent any message from
getting sent or displayed. This code is simply looping over the list of
open conversations and printing the same message to each one. In order to
prevent a message from being sent/displayed you need to connect to the
correct message signal and do what the documentation indicates will cancel
the message.

> Thanks,
> Tom

    -Etan




More information about the Devel mailing list