Hi, I'm writing a AIM bot using
Net::OSCAR.
If you're unfamilar with the module, it basically sets each AIM event (receiving an IM, someone going offline, etc) as a different callback (I would appreciate someone directing me towards a place I could get more information about these callbacks; I've looked and my searches have come up mostly empty) and then calls a function in your code. Some functions rely on the result of other functions to work properly (ie the function that changes the buddylist (
commit_buddylist() ) must recieve an status message about the previous change (
buddylist_ok() or
buddylist_error() ) before it can be called again, ).
The problem I'm experiencing is the program just rushes through execution without waiting for certain events to occur.
My question is: how do you stop excecution at a certain point, wait for a particular callback (or event) and then continue? Ideally, it should handle timing out after a certain time as well (if the expected result hasn't been returned). For example:
# assume $bot is a valid Net::OSCAR object
# callbacks
$bot->set_callback_signon_done(\&signon_done);
$bot->set_callback_buddylist_ok(\&buddylist_ok);
$bot->set_callback_buddylist_error(\&buddylist_error);
$bot->signon($sn,$passwd); #this logs you into the net
# Program should wait here until signon_done
# parse a list of @buddies to be added (this works)
foreach (@buddies) {
$bot->add_buddy($grp, $_) #adds a user
$bot->commit_buddylist(); # sets changes to the server
# program should wait here until either
# buddylist_ok() or buddylist_error() is returned
}
# ... do other stuff
Even if you aren't familar with Net::Oscar, I hope you understand what I'm trying to accomplish. If you don't understand anything above, please tell me and I'll try to clarify.