PDA

View Full Version : GiftBot



Donavin69
12-20-2011, 01:18 PM
GiftBot 0.3

Like a lot of scripts, I utilize ZLib (thanks Zarqon)

Thanks to my code contributors (even though they didn't know they did it) Bumcheekcity (crimbo gifter), Zarqon(randbot), Bale(candycredits)
And special thanks to Theraze for helping me get the chatbot part working!

This script will buy 1 Crimbo gift for each person talking in chat, it will automatically turn candy into credits with a limit on value/credit every 30 minutes.

To run this as a "chatbot" simply download it (and zlib if you don't have it) put them in your scripts folder, then at the CLI type
set chatbotScript = GiftBot.ash

To avoid any chance of multiabuse, make sure you edit this and modify it to blacklist your multies!

Any suggestions, let me know.

Revision History:
0.1 Initial release (Dec 20, 2011)
0.2 Check available credits before attempting to send, and turning in candy, only turn in candy if less than 5000 credits (also ignores PMs)
0.3 Rollover turn-in timer for new day, if too low to buy a gift, try to turn in.

Donavin69
12-20-2011, 06:24 PM
Is there a way to see this before trying to send a gift?

--10148: Detect when your desired victim already has a Crimbo present --

lostcalpolydude
12-20-2011, 06:36 PM
Is there a way to see this before trying to send a gift?

--10148: Detect when your desired victim already has a Crimbo present --

If you find a way to figure it out in vanilla KoL, let us know.

slyz
12-20-2011, 06:58 PM
Nope. r10148 just means that when you try to buy a big present for someone, the purchase is not logged if the response text contains "already has one of those".

The only way of knowing if someone has a present is trying to send him one, anyway.

Donavin69
12-20-2011, 07:03 PM
That's what I thought....I just didn't want to be hitting the server for it if I didn't have to.

Thanks for the responses :)

Donavin69
12-20-2011, 09:13 PM
Is there already a built in way of finding credit amount, or do I need to parse the screen?

slyz
12-20-2011, 09:31 PM
> ash buy_price( $coinmaster[ Crimbo 2011 ], $item[ Daffy Taffy ] )

Returned: 5

Donavin69
12-20-2011, 09:49 PM
no, I meant how many credits I have....

slyz
12-20-2011, 10:12 PM
Oh, sorry.



> ash get_property( "availableCandyCredits" )

Returned: 71

Donavin69
12-20-2011, 10:16 PM
I should have found that in there...

Thanks!

slyz
12-20-2011, 10:41 PM
Just so you know, you can get all kinds of information on a coinmaster by doing the following:


> ash $coinmaster[ Crimbo 2011 ]

Returned: Crimbo 2011
token => Candy Credit
item => none
property => availableCandyCredits
available_tokens => 11
buys => true
sells => true

In this case, the token (Candy Credit) isn't an item ($coinmaster[ Crimbo 2011 ].item = none), but $coinmaster[ Crimbo 2011 ].property will tell you which Mafia property will tell you the amount of tokens you currently have.

EDIT:

I overlooked it, but


$coinmaster[ Crimbo 2011 ].available_tokens

is an easier way to access the amount of candy credits you have.

jwylot
12-21-2011, 09:40 PM
re your comment in the script "sometimes, for some reason, it sends 'none' filter out and give them a second chance", $item[5504] doesn't exist so this is fixable by removing line 100 and changing line 99 to "int x=random(6);".

Donavin69
12-22-2011, 11:44 AM
I had already fixed that in version 0.3, apparently didn't remove the comment.

I also changed it to random(9) and gave the '30 credit' items double chance...

Thanks though!

asturia
12-22-2011, 08:43 PM
How can we change the script so that it also works with other chat channels?

Donavin69
12-22-2011, 10:23 PM
I'm not sure if it can monitor the others, but I would assume that if you change (or add) the line that specifies /clan, it should monitor others.


if(channel == "/clan") {
vPrint("Checking gift status for: "+Sender,6);
if (get_credits() < 2500) {
turn_in_candy();
set_property("GiftBot_LastTurnIn", now_to_string("HHmm"));
}
CrimboGifter(Sender);
}


You could add a section after that that would read something like


if(channel == "/newbie") {
vPrint("Checking gift status for: "+Sender,6);
if (get_credits() < 2500) {
turn_in_candy();
set_property("GiftBot_LastTurnIn", now_to_string("HHmm"));
}
CrimboGifter(Sender);
}

Donavin69
12-22-2011, 11:22 PM
I'd like to change the blacklist to a zlib variable rather than hard coded, how would I go about that?

jwylot
12-23-2011, 07:11 PM
erm I think that mafia's chatbot function is limited to /clan, possibly to avoid easy spamming of /newbie etc but I may be wrong.

StDoodle
12-25-2011, 03:20 AM
Yeah, mafia chat-botting only works on /clan and the various dungeon channels, and pm's.