Send and verify messages (Perl)

Greg Chagnon gcgaim at gmail.com
Tue Jun 26 13:06:21 EDT 2007


Hi,
Thanks for the response...I'm using hte sample code, I'll post it below.
Pretty much all I want to do is send a message to a user:




sub plugin_load {
    my $plugin = shift;
    my $protocol = "prpl-oscar";
    my $account_name = "test";

    $account = Purple::Accounts::find($account_name, $protocol);
    # First we create two new conversations.    print "Testing
Purple::Conversation->new()...";
    $conv1 = Purple::Conversation->new(1, $account, "Test Conversation 1");
    if ($conv1) { print "ok.\n"; } else { print "fail.\n"; }

    print "Testing Purple::Conversation->new()...";
    $conv2 = Purple::Conversation->new(1, $account, "Test Conversation 2");
    if ($conv2) { print "ok.\n"; } else { print "fail.\n"; }
        # Second we create a window to display the conversations in.
 #  Note that the package here is Pidgin::Conversation::Window
print "Testing Pidgin::Conversation::Window->new()...\n";
    $win = Pidgin::Conversation::Window->new();
    # The third thing to do is to move second the conversation to a
new window.    # The subroutine add_gtkconv() returns the number of
conversations    # present in the window.    print "Testing
Pidgin::Conversation::Window::add_conversation()...";
    $gtkconv2 = Pidgin::Conversation::get_gtkconv($conv2);
    $gtkconv2->get_window()->remove_gtkconv($gtkconv2);
    $conv_count = $win->add_gtkconv($gtkconv2);
    if ($conv_count) {
        print "ok..." . $conv_count . " conversations...\n";
    } else {
        print "fail.\n";
    }
    # Now the window is displayed to the user.    print "Testing
Pidgin::Conversation::Window::show()...\n";
    $win->show();
    # Use get_im_data() to get a handle for the conversation    print
"Testing Purple::Conversation::get_im_data()...\n";
    $im = $conv1->get_im_data();
    if ($im) { print "ok.\n"; } else { print "fail.\n"; }
    # Here we send messages to the conversation    print "Testing
Purple::Conversation::IM::send()...\n";
    $im->send("Message Test.");

    print "Testing Purple::Conversation::IM::write()...\n";
    $conv2->get_im_data()->write("SENDER", "<b>Message</b> Test.", 0, 0);
}




On 6/25/07, Etan Reisner <pidgin at unreliablesource.net> wrote:
>
> On Mon, Jun 25, 2007 at 04:34:09PM -0400, Greg Chagnon wrote:
> > I'm looking at the sample Perl code to sign on and send IMs, but when I
> run
> > it it seems like I'm only sending the message to myself.  How do I send
> a
> > message to another user through the Perl interface?  Also, if I'm signed
> on
> > as the recipient, how do I verify the message was actually
> sent.  Basically,
> > what I want to do is have 2 accounts signed on from different computers
> and
> > have one send the message to the other, and verify that it was in fact
> > sent.  Thanks for any help!
>
> Without seeing the code you are using it is really hard to say what the
> problem is. At a guess I would say that you are using something like
> Purple::Conversation::write instead of Purple::Conversation::IM::send.
>
> The only way to verify that what you sent got to a receiver correctly is
> to use some sort of checksum that gets verified and sent back. Assuming
> you really need to know that the message you sent got to the other end
> exactly the way you sent it.
>
>        -Etan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pidgin.im/pipermail/devel/attachments/20070626/d6aea54a/attachment.html>


More information about the Devel mailing list