Hello Monks, I recently discovered the module Net::OSCAR (for writing AIM bots) and decided to play around with it. However, I continue to run into problems using the send_im function. If I use it in one of the callback methods, it works splendidly. That is, if it occurs in response to receiving an IM or because the user was fully logged in. But if I ever try to call it on its own or in response to a button click (I'm using Tk) it does nothing. Here's a piece of the code:
use Tk; use Net::OSCAR qw(:standard); use threads; my $aimbot = Net::OSCAR->new(capabilities => [qw(extended_status typin +g_status)]); ###############TK SETUP############################# my $main = MainWindow->new( -title => 'AimTk', -background => 'black' ); $main -> bind('<Key-Escape>', sub { exit }); $main->Button(-text => "Connect", -command => \&connect)->pack; $main->Button(-text => "Send", -command => \&sendMessage)->pack; $txt = $main -> Entry(-width=>40, -textvariable=>\$outGoing) -> pack() +; ############################################# MainLoop; ############SUBROUTINES################### sub on_im { my ($aim, $sender, $message, $away) = @_; $aimbot->send_im($sender, "Hiya."); print "They Said: $message.\n"; } sub done { $aimbot->send_im("NameToSendTo", "Check, check."); } sub sendMessage { print "$outGoing\n"; $aimbot->send_im("NameToSendTo", "Words go here."); } sub connect { $aimbot->set_callback_im_in(\&on_im); $aimbot ->set_callback_signon_done(\&done); $aimbot->signon("myUserName", "myPassword"); my $listenThread = threads->new(\&listening); $listenThread->detach; } sub listening { while(1) { $aimbot->do_one_loop(); } }
Does anyone have any idea why that might not be working? I suspect it may have something to do with Tk's flow of code clashing with the thread I established to do the other work. (I'm new to Tk as well, just to complicate matters further.) I also considered that it's possible that this module can ONLY send IM's in response to incoming ones -- but that seemed like it would be a horrible waste, as implementing an on-command send function after implementing the reflexive send function should've been fairly simple. Thanks for any help anyone can offer!

2006-06-27 Retitled by Corion, as per Monastery guidelines
Original title: 'Net::OSCAR'


In reply to using the send_im function in Net::OSCAR in Tk outside of a Net::OSCAR callback by fridayjones85

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.