Perl plugin using Purple constants (finch)

Adam Tistler atistler at gmail.com
Mon Mar 16 15:56:57 EDT 2009


Hi all,

I am attempting to use the received-chat-msg callback in my plugin  
however it does not seem to be called,
received-im-msg does get called.

According to the xml, this is a chat conversation:
<message to="xxxxxx at gmail.com/home4CDD9991" type="chat"  
id="D5E2C4CE8EA07AB7_14"

I think that I am confused as to the difference between what finch  
thinks is a "chat" and "im".  Can someone elaborate.  Also, is there  
an easy way to refer to C enums with the perl plugin or can I just send
a hex in its place?


void purple_conv_chat_add_user(PurpleConvChat *chat, const char *user,
                               const char *extra_msg,  
PurpleConvChatBuddyFlags flags,
                               gboolean new_arrival);


sub recieved_im_msg_cb {
    my ($account, $sender, $message, $conv, $flags) = @_;
    &log(sprintf("Got message: %s from %s on account %s\n", $message,  
$sender, $account->get_username()));
    &log(Dumper($conv));
    my $im = Purple::Conversation::get_im_data($conv);
    &log(Dumper($im));
}

sub recieved_chat_msg_cb {
    my ($account, $sender, $message, $conv, $flags) = @_;
    &log(sprintf("Got message: %s from %s on account %s\n", $message,  
$sender, $account->get_username()));
    &log(Dumper($conv));
    my $chat = Purple::Conversation::get_chat_data($conv);
    &log(Dumper($chat));
    $chat->add_user("chatproxyaim01", "resend: $message", 0, 0);
}


sub plugin_load {
     my $plugin = shift;
     &log("Plugin loaded");
     my $protocol = "prpl-xmpp";
     my $account_name = "atistler at gmail.com/home";
     my @accounts = Purple::Accounts::get_all();
     foreach my $account (@accounts) {
         &log(Dumper($account->get_username()));
     }
     my $conversation_handle = Purple::Conversations::get_handle();
     my $data = "hello";
#    Purple::Signal::connect($conversation_handle, "received-im-msg",  
$plugin, \&recieved_im_msg_cb, $data);
     Purple::Signal::connect($conversation_handle, "received-chat- 
msg", $plugin, \&recieved_chat_msg_cb, $data);
}








More information about the Support mailing list