User Control Panel
Advertisements

HELP US, HELP YOU!

offtopic?accessig idle/away info from the web

 
Post new topic   Reply to topic    Bot Depot Forum Index -> AIM Protocol & questions
View unanswered posts
Author Message
kennethj
Newbie
Newbie


Joined: 30 Mar 2005
Posts: 3

Reputation: 13.5

PostPosted: Wed Mar 30, 2005 6:34 am    Post subject: Reply with quote

Hello,
I recently started working on a simpleish bot that basically just acts as an intermediary between users. and forwards a message fom one SN to another creating "anonymous" chatting. However i was trying to create a web page that could check to make sure if these users were away/idle before someone tried to contact them. I've seen that there is an easy way that you can find out if a user is online or not by simply using big.oscar.com/screen_name?on_url=online&off_url=offline

is there a similar way to find idle or away status? or is there a good way to have the bot running on a web server and have the page query the bot to look through its list of users to find idle information?

for my complete project it would probably involve constantly changing the bots buddy list around to doit in a way such as that, which seems klunky.

thanks for any helpyou guys can give me,
ken
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Thu Mar 31, 2005 6:41 am    Post subject: Reply with quote

On most of the Perl AIM modules, the buddy update handlers usually include something where you can find out what their status is.

Net::AIM has an update_buddy handler that's called for every buddy update (online, offline, status change, etc.), and it receives a large number of variables in @_, many are self explanatory.

Net::OSCAR has a buddy_in and buddy_out handler (for signing in and out). A buddy_in handler is called when the buddy signs in or changes their status to anything other than offline. And that one gets $oscar, $username, $data, and $data->{away} would equal 1.

Go to http://search.cpan.org/ and type in Net::AIM or Net::OSCAR to find the module pages for those for more information.

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
kennethj
Newbie
Newbie


Joined: 30 Mar 2005
Posts: 3

Reputation: 13.5

PostPosted: Wed Apr 06, 2005 6:33 pm    Post subject: Reply with quote

thanks for the info...
i'm using net::oscar for my project. and am using the cksbot template thats starts off just returning the message that was sent....

being new to perl and bots, now i am having some more problems.
1. i'm trying to use The method---
buddy (BUDDY[, GROUP])
Returns information about a buddy on the user's buddylist.
and get data from the hasshref it returns specifically for the value 'online', but it seems to return 0 for pretty much anyone but the bot itself, any ideas why?

2. since i also want to know if the user is away or idle, i was trying to use get_away(WHO)...which forces the buddy_info callback, where i can find out this information by accessing the hashref, however...if i want this information to be returned to say the on_im handler for processing how could i accomplish this?

thanks again for the help.
ken
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Wed Apr 06, 2005 8:21 pm    Post subject: Reply with quote

The buddy_in handler is called for all buddy status changes (except for offline).

If your bot signs on, and 15 of its buddies are already online, buddy_in will be called for each of those 15 buddies (including a $data hashref which contains information like whether or not they're away or idle).

And then if some of those buddies goes offline, buddy_out is called for each buddy who goes offline. And then somebody else pops online, buddy_in is called with their information.

It should be all you'll need, you wouldn't need to actually call methods for getting buddy info unless your bot somehow lost the data (like you deleted hashref keys or something).

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
kennethj
Newbie
Newbie


Joined: 30 Mar 2005
Posts: 3

Reputation: 13.5

PostPosted: Wed Apr 06, 2005 11:02 pm    Post subject: Reply with quote

right...but let's say that i want to then use that information in another handler, such as the on_IM handler. How could i then pass that information from the buddy_in handler to the on_im handler so that some action could be taken...is the only way to create some type of global data structure. that would be updated.and then have the handler check to get the info?
thanks again


QUOTE(Cer @ Apr 6 2005, 03:21 PM)
The buddy_in handler is called for all buddy status changes (except for offline).

If your bot signs on, and 15 of its buddies are already online, buddy_in will be called for each of those 15 buddies (including a $data hashref which contains information like whether or not they're away or idle).

And then if some of those buddies goes offline, buddy_out is called for each buddy who goes offline. And then somebody else pops online, buddy_in is called with their information.

It should be all you'll need, you wouldn't need to actually call methods for getting buddy info unless your bot somehow lost the data (like you deleted hashref keys or something).
[right][snapback]47571[/snapback][/right]
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Thu Apr 07, 2005 11:40 am    Post subject: Reply with quote

You could make a totally separate subroutine that handles the data....

Like, if a buddy's online status changes to away, you'd put in the buddy_in handler something like:

Code:
&updateStatus ($screenname, 'online', $data->{away});


And then you'd have this subroutine:

Code:
sub updateStatus {<br />   my ($screenname, $status, $isAway) = @_;<br /><br />   # stuff here<br />}


Also a thing you can do is create a global hashref on your bot, like $bot, and keep all your information there so that any subroutine can update values in the hashref and it would be accessible from everywhere else in your bot.

Just put
Code:
our $bot = {};


In your main bot.pl file, and then with buddy_in and buddy_out you could do like...

Code:
# (for buddy_in, for example)<br />$bot->{$screenname}->{online} = 1;<br />$bot->{$screenname}->{away} = $data->{away}; # would be 1 or 0<br />$bot->{$screenname}->{idle} = $data->{idle}; # would be idle time or 0<br /># etc. . . .


And then your on_im handler could get information about a screenname by just getting it out of the hashref. Like.....

Code:
if ($msg =~ /^get data for (.*?)$/i) {<br />   my $for = $1;<br />   if (exists $bot->{$for}) {<br />      $self->send_im ($screenname, "$for:\n"<br />         . "online: $bot->{$for}->{online}\n"<br />         . "away: $bot->{$for}->{away}\n"<br />         . "etc...");<br />   }<br />   else {<br />      $self->send_im ($screenname, "I don't have any data on $for.");<br />   }<br />}

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> AIM Protocol & questions All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group