Posted: Tue Jun 14, 2005 2:57 pm Post subject: Get Bot's Own Username
If you run more dynamic bots, it may be useful to get the current bot's username to tell it apart from the others. Here's how to do so with the various messengers and their modules.
AIM - Net::OSCAR
$screenname = $aim->screenname();
where $aim is the Net::OSCAR object
AIM - Net::AIM
$screenname = $aim->{_conn}->{_screenname};
where $aim is the Net::AIM object
MSN - MSN.pm
$handle = $msn->{Handle};
$handle = $self->{Msn}->{Handle};
where $msn is your MSN server object, and $self is your switchboard object from conversation events
IRC - Net::IRC
$nick = $irc->nick;
where $irc is your Net::IRC object
Jabber Messenger - Net::Jabber::Client
Quote:
I'm not sure how to do a one-liner way of getting the Jabber username, but on initialization (when you're creating the object and still have access to its unique username), you can assign it to a hashref, i.e.
$jabber->{mynick} = $username;
And then you can get the username by doing:
$username = $jabber->{mynick}
where $jabber is your Net::Jabber::Client object
HTTP Daemon - HTTP::Daemon
$url = $daemon->url;
where $daemon is your HTTP::Daemon object
First of all, maybe HALF of those are documented. The ones that use hashrefs to get it (Net::AIM, MSN) are NOT documented, and the ones you have to "cheat" for like Jabber are ALSO not documented.
And also, Google searches for things such as "Net::AIM screenname" or "Net::AIM own screenname" etc. don't return ANY results about getting the bot's own screenname, EXCEPT for results on--guess what--Bot-Depot!!!
So there are people who don't know, and now they do, and plus I posted this as a reference so people who work with all different protocols don't need to spend half their time searching around for all these little tips and tricks.
So stop waiting to pounce on any kind of error you see Cer potentially make, without Google searching yourself to back up half your b/s claims.
Cer is right, it takes maybe an hour to find good results on google, but if it's in a thread here, you can easily go find it. And since the thread is writen for a specific reason, they are often easier to understand.