Skip to content
This repository has been archived by the owner on Apr 22, 2019. It is now read-only.

Create Wishlist.py #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Wishlist.py
Original file line number Diff line number Diff line change
@@ -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)