diff --git a/Wishlist.py b/Wishlist.py new file mode 100644 index 0000000..69452b2 --- /dev/null +++ b/Wishlist.py @@ -0,0 +1,36 @@ +import getopt +FILE_NAME = "files/wishlist.txt" + +@command("wishlist") +def wishlist(nick, user, channel, message): + url = False + if message.startswith("add"): + args = message.split() + optlist, args = getopt.getopt(args, 'u:') + for opt, val in optlist: + if opt = "-u" + url = True + try: + f=open("FILE_NAME","a") + f.write("\n") + if url: + f.write("URL: %s Item: %s Reason: "%args[0]%args[1]) + #remove the first two args already written to file + args.pop(0) + args.pop(0) + for i in args: + say(channel, "%s "%i) + f.write("%s "%i) + f.close() + + except IOError: + say(channel, "Error: couldn't add to wishlist. Botler running with correct permissions?") + + + elif message.startswith("remove"): + say(channel, "%s: Deletes are hard. I can't do that yet."%nick) + else: + say(channel, "%s: usage is !wish (-u url) [add|remove] item reason"%nick) + + +