Perl Plugin Newbie Problem
Etan S. C. Reisner
pidgin at unreliablesource.net
Sun Apr 29 22:36:12 EDT 2007
On Sun, Apr 29, 2007 at 07:00:40PM -0500, Steven Osborn wrote:
> I'm trying to write a Perl Plugin and I've looked through all of
> the .xs files and examples and I'm afraid I still don't see how to
> tie an IM to a user. I'm figured out how to get my account connected
> and create a conversation and IM. I can even create a buddy object
> or reference a buddy from my Buddy list, but I'm not sure how to
> create an IM for that buddy. The code I have looks something like
> what I have below, cut down a lot for clarity.
> #Create a conversation
> $conv1 = Gaim::Conversation->new(1,$account,"Conversation 1");
Unless you want to send an IM to someone with the name "Conversation 1"
that's not what you want to be doing. The 'name' of the conversation is
the buddy to whom it is connected. Also, like I mention farther down if
you get the buddy first you can search for existing conversations before
resorting to creating one yourself.
> #IM Object from Converstation
> $im = $conv1->get_im_data();
> #This is my buddy
> $buddy = Gaim::BuddyList::Buddy::new($account,"Buddy","Best Friend");
You don't want to create a new buddy unless you know the buddy doesn't
already exist, you probably want Gaim::Find::Buddy($account, "buddy name")
instead. Also, if you find the buddy first you can search for an active
account with the buddy before you create one.
> #How do I specify who I'm sending this to?
> $im->send("Hello Nobody");
This sends the message to the buddy associated with the conversation.
> I'm sure I'm overlooking something fairly obvious, but I'm not really
> familiar with Pidgin's inner workings or Perl for that matter.
More information about the Devel