ASH-scripted clan buffs?

Alomir

New member
I've looked through all of the documentation that I can lay my hands on, to no avail - so I thought I'd ask here as a last-ditch effort.

Is there any way to script buying a clan buff? Specifically, the non-stat ones like Bootyliciousness (item drop bonus).

Thanks!

- A
 
visit_url()? I think (I wouldn't know as I have never bought them) that you could use the browser-based Mafia to view the url used to make the purchase. I image it would be something like;
clanbuffs.php?type=NAME&amount=BLAH_BLAH_BLAH

That is definately NOT it. But it will most likely be in that format. Just keep digging, eventually you will figure it out. i just know from experience that you can do ALMOST anything with visit_url() you will just have to script EVERYTHING out. Good luck! :)
 

hippymon

Member
Just FYI:
visit_url() is your friend in this case.
The easiest way I could think of to do this would be to:
Open mini-browser
go to the clan buff page
purchase a buff / some buffs
and copy the URL...
 

Alomir

New member
Entirely excellent - worked like a charm, thanks!

- A

PS: in case anyone is interested:
Code:
  string url = "clan_buytraining.php?action=buyround&pwd&members=1&size=3&whichgift=7&gift=Buy+It";
  string str = visit_url(url);
I'm not sure if that "members=1" would be different for anyone else; I tried it with two different characters (in clans of different sizes), and it didn't change.
 
Here's an idea i had based off of this Basically, I think That if you send a message to the bot it will try to buy clan buffs if you are on the approved list. Mind you, I have almost no experience with maps, I like arrays... (PHP side of me). So the way I did it is most likely wrong. Also, my verification of the map/sender if probably wrong too. For all I know the whole thing is wrong... But hopefully it will give someone else an Idea to finish it/make it cleaner.

Here is how you would use it: [taken from the post mentioned above]
After you log onto an account for the first time with KoLMafia, you will end up with a configuration file in your kolmafia/settings folder - named something like aprocalypse_prefs.txt.

You need to open up that file and then edit a certain line on it:
chatbotScript=

To use any given script you need to add the name of the script after chatbotScript, for example for this script:

chatbotScript=whitelistBot.ash

Of course, the script must also be in your script folder, just like any other script.

To start running the script you must simply enter chat - a KoLMafia chatbot will trigger whenever a PM (blue message) is sent to that character.

Keep in mind that this script will trigger EVERY TIME you recieve a PM (blue message) when in the KoLMafia chat, so if you don't want this to happen - remove that line from your config file, or rename your script so it does not run.

Of course, this requires a "somewhat modern" version of KoLMafia. Basically, anything with a version over 10 should be able to run chatbotScripts, so this isn't too much to worry about.

Code:
void main (string sender, string message)
	{
		string [boolean] appoved;
		approved["username", "username2", "username3"];
		string check = substring(message,0,1);
		string target=substring(message,1);
		if (check = "!" && approved contains target)
			{				visit_url("clan_buytraining.php?action=buyround&pwd&members=1&size=3&whichgift=7&gift=Buy+It");
				chat_reply("! buffs found: Attempted to perchase clan buffs");
			}
		else 
			{
				chat_reply("Sorry, you are not authorized to perchase clan buffs. Please report issue to clan administration. Thank you!");
			}
	}
 

hippymon

Member
There are a few problems with your script.... I fixed them below and posted a working copy. Also, I added a couple of "print" lines.
Just an FYI: Anytime you write a script, try to use "verify SCRIPTNAME" and fix all you can, if you get stuck, ask for help...
Code:
void main (string sender, string message){
	int [string] approved;
	approved["NAME 1"] = 1;
	approved["NAME 2"] = 2;
	approved["NAME 3"] = 3;
	string check = substring(message, 0, 1);
	string target = substring(message, 1);
	if (check = "!" && (approved contains target)){
		print("Buffing " + sender + " with a clan buff.");
		visit_url("clan_buytraining.php?action=buyround&pwd&members=1&size=3&whichgift=7&gift=Buy+It");
		chat_reply("! buffs found: Attempted to perchase clan buffs");
	}
	else{
		print("Rejected " + sender + " for he/she is not pre-approved for buffing");
		chat_reply("Sorry, you are not authorized to purchase clan buffs. Please report issue to clan administration. Thank you!");
	}
}
 
Top