Clan Fortune Script

Stewbeef

New member
I'm going to give it an update later, but I made a script for the Clan Fortune. Lets you set default answers, send requests and responses. It's all CLI atm.
Here's a link to the info on it:
https://github.com/stewbeef/clanfortune/tree/readme

Probably going to give it an update in a couple days and split it back into multiple files (right now it is a compilation of 3 files since I have a couple files I made for different helper functions).

Edit: It still needs a bit of work behind the scenes, but it should do everything in the readme just fine. This is my first script I've made public.
 
Last edited:

Crowther

Active member
2538 lines! And so many one line functions.

There is some weird handling of "defaults". For one, they aren't set automatically, which to me isn't a default. Yet, doing "defaults,info" will set them. Also, to me the words "answer" and "response" mean the same thing, so I found it very confusing, but you documented it clearly, so I finally got things right. Anyway...

Here's what I really came here to say:
Code:
import clanfortune.ash

void main()
{
    chat_private("Easyfax", "fortune");
    waitq(9);
    clanfortune_parse("clan,Easyfax,pizza,batman,thick");
}
I'm not announcing this widely, because I'm not sure how well it will work. If this is too much stress for Easyfax, I might have to turn it off. Oh, and it is very ugly. Neither side actually listens for a message, they both just wait and hope things are ready in time. Easyfax waits 10 seconds, but because chat messages are slow, you don't get that long.
 

Stewbeef

New member
Yeah, I couldn't think of a better way to describe "answer" and "response". Maybe I should have used "submit" and "response"? Does that sound clearer?

I guess I didn't want to hardcode the defaults a particular person uses, since a given clan might decide on a different set of defaults. Maybe that was a mistake though. Hmm, I'll do an update at some point that will do that, and only use the manually set items if they have been specified.

Thanks for the feedback.

Edit. It's long because I have some helper code for various projects and I just put them all together in one file. So a fair amount of it isn't used. I am going to switch it to using dependencies at some point so that there isn't a whole bunch of other stuff and it is easier to maintain.
One line functions are mostly in case those functions are passed variables in a different form (e.g. string for an item instead of an item variable), then it converts them. I guess I like doing that since it makes using those functions easier if I import it or some other part of the code calls it.
 
Last edited:

Timbatim

New member
I installed it today, took me a while to figure out how to set up as I assumed I typed in what it want.
Either way, now it works like a charm and I wrote an own .ash file with 3 lines to send and respond automatically on logon.

Thank you sir/madame, it is appreciated!
 

Stewbeef

New member
I tried this script, and I'm extremely confused as to how to get the NPC buffs.

Sorry for the delay in the response, I've been very busy lately IRL.

You need to make sure there are no spaces when you do the commands.
> clanfortune npc,meat
-- that gets you the meat buff.
but
> clanfortune npc, meat
-- that does nothing


I will try to release a new version this weekend that's a bit easier. I'll make it so you don't need to have the "npc" part and so that it trims off leading and trailing spaces.
There are some other checks and improvements I want to make, such as allowing a list of guild contacts. If the first one can't be reached (not in guild or you are still awaiting a response), then it will try the next one on the list, and so on.
 

Pazleysox

Member
Very cool. This whole thing in my opinion can be made easier to understand if you highlight the commands to type, and make them shorter. Changing npc,meat to just meat would simplify things. There are other things I would change to make understanding easier, but I do love the script! I incorporated it to be used by my clan bot, and it runs great.
 
Thanks for the script! :)

Currently I'm sending the fortune requests to the same person 3 times. Is it possible to run the script with delay in between?

As a temporary workaround, I'm currently using this - I'm a newbie at coding for kolmafia so pardon if my script is bad.
Basically I used quicksend 3 times with delay in between.

Note: I've yet to fully test it out yet, because I used up my 3 fortune requests on trying out the original script and realising it does not have delay.

cli_execute {
/whitelist bonus
clanfortune quicksend
wait 3
clanfortune quicksend
wait 3
clanfortune quicksend
/whitelist ferengi
}
 

Pazleysox

Member
Code:
cli_execute {
 /whitelist bonus
 clanfortune quicksend
 wait 3
 clanfortune quicksend
 wait 3
 clanfortune quicksend
 /whitelist ferengi
 }

Here's how I would do that same script.

Code:
void main()
{
cli_execute ("/whitelist bonus");
cli_execute ("fortune quicksend");
wait (5;)
cli_execute ("fortune quicksend");
wait (5);
cli_execute ("fortune quicksend");
cli_execute ("/whitelist ferengi");
 }


First, the command is "fortune (XXX)" not clanfortune (XXX). Second wait (X); needs to be it's own command, it's not a cli command. I would put a delay of at least 5, unless the bot is super fast
 
Last edited:
Here's how I would do that same script.

Code:
void main()
{
cli_execute ("/whitelist bonus");
cli_execute ("fortune quicksend");
wait (5;)
cli_execute ("fortune quicksend");
wait (5);
cli_execute ("fortune quicksend");
cli_execute ("/whitelist ferengi");
 }


First, the command is "fortune (XXX)" not clanfortune (XXX). Second wait (X); needs to be it's own command, it's not a cli command. I would put a delay of at least 5, unless the bot is super fast


And "fortune" is a built-in command. You override it with your script name?


Thanks guys for the advice.

I actually thought it had to put "clanfortune" in front because the script name is clanfortune.ash and on the github page, they had other commands which started with clanfortune (e.g clanfortune help, clanfortune defaults,<setting name>,<setting>)

I recall typing "clanfortune quicksend" in the gCLI manually and it worked for me.

But I find it a little odd that the command "quicksend" did not work, since on the github page, the command was only "quicksend".

How did you guys manage to find out it was "fortune quicksend"?
 
Last edited:

Malurth

Member
Just popping in to say I made a little code snippet based off this script, which pretty cleanly handles auto-responding to all clannies awaiting a consultation response from you. Mafia already has built-in functionality for sending out requests, and has built-in preferences for what words to use when sending and responding to fortunes, so I figure the only real thing that wants to be scripted is auto-replying, and it should use those preferences. I think your script was made before mafia added such functionality, and it seems a wee bit ridiculously complex to me, so I just made my own. (Initially I tried to do it all on my own, but hit a minor roadblock when my usual method of scoping out button-sourced URLs, the Mini-Browser, wouldn't work for some reason, so I just looked up your script to see what the URL was. I wound up copying more than that, though, since your regex was better than mine :p)

So without further ado, here's the snippet:

Code:
buffer page = visit_url("clan_viplounge.php?preaction=lovetester");

string [int][int] request_array = page.group_string("(clan_viplounge.php\\?preaction=testlove&testlove=\\d*)\">(.*?)</a>");

foreach i in request_array {
	string response_url = request_array[i][1].replace_string("preaction\=testlove","preaction\=dotestlove") + "&pwd&option=1&q1=" + get_property("clanFortuneReply1") + "&q2=" + get_property("clanFortuneReply2") + "&q3=" + get_property("clanFortuneReply3");
	visit_url(response_url);
	print("Response sent to " + request_array[i][2] + ".", "green");
}

You can just save that as an .ash file and run it to auto-respond using mafia's built-in prefs (clanFortuneReply1, clanFortuneReply2, and clanFortuneReply3).
 

taltamir

Member
Just popping in to say I made a little code snippet based off this script, which pretty cleanly handles auto-responding to all clannies awaiting a consultation response from you. Mafia already has built-in functionality for sending out requests, and has built-in preferences for what words to use when sending and responding to fortunes, so I figure the only real thing that wants to be scripted is auto-replying, and it should use those preferences. I think your script was made before mafia added such functionality, and it seems a wee bit ridiculously complex to me, so I just made my own. (Initially I tried to do it all on my own, but hit a minor roadblock when my usual method of scoping out button-sourced URLs, the Mini-Browser, wouldn't work for some reason, so I just looked up your script to see what the URL was. I wound up copying more than that, though, since your regex was better than mine :p)

So without further ado, here's the snippet:

Code:
buffer page = visit_url("clan_viplounge.php?preaction=lovetester");

string [int][int] request_array = page.group_string("(clan_viplounge.php\\?preaction=testlove&testlove=\\d*)\">(.*?)</a>");

foreach i in request_array {
    string response_url = request_array[i][1].replace_string("preaction\=testlove","preaction\=dotestlove") + "&pwd&option=1&q1=" + get_property("clanFortuneReply1") + "&q2=" + get_property("clanFortuneReply2") + "&q3=" + get_property("clanFortuneReply3");
    visit_url(response_url);
    print("Response sent to " + request_array[i][2] + ".", "green");
}

You can just save that as an .ash file and run it to auto-respond using mafia's built-in prefs (clanFortuneReply1, clanFortuneReply2, and clanFortuneReply3).

Thanks. I started using it and it works great for automatic replying.
 
Top