/whois

Tpj_4000

Member
Is there any way to return whether or not a character is logged in? (/whois)

The reasons are:
  • I figured it would be much more polite to check if a buffbot is online before sending meat so that when it logs in it doesn't have a list of 400 to process from everyone else doing the same.
  • I currently have my script sending meat, looping x # of times, and checking have_effect(), then sleeping until next check if no effect found. If failed, on to the next bot. I think this is terribly inefficient.
  • I want my own list adaptive so that if a message is returned, I'll generate an error log to see if the buffbot is being taken down, prices changed, etc. (Trying to maintain my involvment as much as possible script side w/feedback as not to take advantage of the people nice enough to run buffbots)


I didn't see anything in a forums search or in the documentation.
Thanks.
 

dangerpin

Member
Mafia has its own, internal "online validator" to check if a Buffbot is online, but I don't see anything that makes this available for scripting. Basically it does a whois and parses for "online" within chat.

My understanding is that most things relating to chat are not available for scripting because of the risk of a spambot.

Anyone have more info on this?
 

Alhifar

Member
The only chat related ability in ASH seems to be the ability to respond to a blue message. Mind you, I haven't found a way to figure out what was IN that blue message, so it doesn't seem very useful to me. Other than that, there are no chat related functions, and visit_url("lchat.php") returns an empty string, indicating to me that you cannot use that for chat related functions either.

As well, it seems that there is nowhere else that the online status of a player is indicated. It seems to me that you may be out of luck, at least without help from a mafia dev.
 

zarqon

Well-known member
There is a way, but it's a bit ugly.

1) Visit showplayer.php for the player whose online status you want to check.
2) Follow the link there to showclan.php (if that player is not in a clan, you're screwed, but I think most buffbots are clan-run or at least in a clan).
3) Parse that page to see if there is a + in front of the player's name.

Would involve two server hits and a lot of tedious string parsing. If it's too tedious, I'm sure someone here could write it for you given the proper motivation.

EDIT: if you hardcode the playername/clan information, it could be reduced to one server hit per player check.
 

dangerpin

Member
It definitely sounds like it could be useful in this instance, one of you should put in a Feature request.

NICE workaround, Zarqon.
 

Tpj_4000

Member
There is a way, but it's a bit ugly.

1) Visit showplayer.php for the player whose online status you want to check.
2) Follow the link there to showclan.php (if that player is not in a clan, you're screwed, but I think most buffbots are clan-run or at least in a clan).
3) Parse that page to see if there is a + in front of the player's name.

Would involve two server hits and a lot of tedious string parsing. If it's too tedious, I'm sure someone here could write it for you given the proper motivation.

EDIT: if you hardcode the playername/clan information, it could be reduced to one server hit per player check.


I was originally thinking along those lines, but then came up short when I realized that if the person isn't in a clan you couldn't tell if they were online or not. But, yes, logically you would assume a buffbot is clanned. However, I don't want to depend on that assumption, and as you stated, it's a bunch of server hits.

I thought of doing a /whois and monitoring my outgoing trafiic, but since Norton Anti-crap bought Sygate and basically turned their software into a steaming pile of *^^*&, I have been without decent traffic monitoring tools for a while.

I'm ok on the coding, but I appreciate the offer. I found how to parse the hermit page for clovers (I think it was your example you posted :D ), and used it to parse npc store item prices.
 

Tpj_4000

Member
Ok, I got bogged down with school/finals. Anything come out of this? Was there an official yes or no regarding adding this?
 

kain

Member
I fiddled with something like this a while back ... I was trying to get a list of clannies currently in clan chat, though. I got something that kinda-sorta worked, but not really.
 

Tpj_4000

Member
As an update, running this seems to continue to loop until j=4 even if you receive the buff you are looking for before the loop finishes.

Code:
for j from 0 to 4{
	print("Checking for " + stringbuff + ".");
	buffed = have_effect(buff);

	if( !(buffed>curr_buffed) ){
		print("Waiting 60 seconds until re-check...");
		wait(60);
	}
	else{
		print(stringbuff + " buff acquired.");	
		return buffed;
		}
	}


The only thing that seems to work is hitting the refresh button in Mafia to reload character data and then it recognizes it. Or, inserting a visit_url("main.php") directly after the wait(60) will force it to update. However that is undesirable as it hits the server a bunch.

Doesn't a buff reception or message received etc. generate an interrupt within Mafia and force updates? It seems when running a script, things outside the script are irrelevant. Is there a way to force an buff status update via .ash because have_effect() doesn't seem to do it.

Can anyone clarify this for me?
 
Last edited:

Tpj_4000

Member
Excellent! Thanks :)


edit, edit:

I forgot to erase a line of code initially, but that worked. Thanks again.
 
Last edited:
Top