View Full Version : Request (with reward!) - Item Distribution script
fortyforks
02-27-2011, 04:00 AM
I was hoping someone could write a script for me. I'm looking for something that will respond to specific PMs with a kmail containing items (with a once-per-day limit). Like for example, say it receives a PM saying "beer" and it would kmail the sender a can of Sir Schlitz.
I'd be happy to reward/pay with meat! Not sure what the going rate is for this type of thing... a million meat maybe?
There's a few other little things I'd like it to do, but that would be the main function. If anyone would be willing to do this, leave/send me a message and I'll send you some more details.
Thanks!
-ff
mredge73
02-28-2011, 01:57 PM
Kmail or Chat PM? Bot script or Run once script?
Framework for both exist on the forum so creating this would just be copy/paste for the most part.
Specifics would help for the more difficult parts such as matching keywords to items.
FYI:
Typical hire rate for a scripter is 1 Mr. Accessory
heeheehee
02-28-2011, 02:51 PM
PM generally means PM, especially since the OP used kmail to mean what kmail means. I'd say the easiest way to approach this is to write a quick chatbot script and import zarqon's zlib.ash (http://wiki.kolmafia.us/index.php?title=Zlib), which has the handy kmail() function.
import <zlib.ash>
int [item] map;
map[$item[sir schlitz]] = 1;
void main(string sender, string message) {
if (message == "beer")
kmail(sender, "Here's some schlitz!", 0, map);
}
Alternatively, if you wanted, you could build a map that maps keyword to sent stuff, then use the following framework:
import <zlib.ash>
int [string, item] map;
map["beer", $item[sir schlitz]] = 1;
map["clovers", $item[disassembled clover]] = 1; // you can add multiple items to the same
map["clovers", $item[ten-leaf clover]] = 1; // key, and it'll work as you expect it to.
void main(string sender, string message) {
if (map contains message)
kmail(sender, "Here's some stuff!", 0, map[message]);
}
Be careful, Heeheehee's examples are just that - examples. They don't limit the number of requests per user, which is something you might want. It's a very good basis to start with, though.
heeheehee
02-28-2011, 03:06 PM
Yeah, if you wanted to limit the uses per user, I'd suggest using a datafile to keep track of that, presumably returning date of last use. For 1/day, extend the main() function as such:
void main(string sender, string message) {
int[string, string] used;
file_to_map("used.txt", used);
if (used[sender, message] != today_to_string())
if (map contains message) {
kmail(sender, "Here's some stuff!", 0, map[message]);
used[sender, message] = today_to_string();
}
map_to_file(used, "used.txt");
}
fortyforks
02-28-2011, 07:50 PM
This is great, thanks a lot! I'm going to test it out tonight.
Powered by vBulletin® Version 4.2.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.