Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def betting(nick, channel, message, source): #main betting function
- # betting todo (- = complete)
- #-track entrants
- #-track active bets (races with entry open)
- #-nick changes (welcome notice on correct nick)
- #-option to turn off notices
- # track first .done and payout
- # .give/.donate user amount
- # .bet user amount
- # .removebet user
- # .pool channel
- # .balance user (blank gives self)
- # .bets user
- # minimum balance?
- # bet precision (no decimals)
- # track bet history...?
- # back up money for rollbacks
- # bet against bot with odds based on rankings
- # .top10
- # .bottom10
- pastebinlink = '(pastebin goes here)'
- def name_validity(nick):
- srlprofile = urllib2.urlopen('http://speedrunslive.com/profiles/?player=%s' % nick).read()
- if srlprofile == 'Not a valid player name.': return False
- else: return True
- def initialize_user(nick):
- filepath = 'C:\\testbot\\betting users\\%s.txt' % nick
- f = open(filepath, 'w')
- cash = '10000'
- f.write(cash)
- f.close()
- user_cash[nick] = cash
- def notice_status(nick):
- filepath = 'C:\\testbot\\betting settings\\notices.txt'
- f = open(filepath, 'r')
- if nick+'|' in f.readline():
- f.close()
- return False #notices off
- else:
- f.close()
- return True #notices on
- if source == 'NICK':
- if not name_validity(nick) and notice_status(nick):
- irc.send('NOTICE %s hey, i don\'t recognize you! you need to have raced at least once in order to bet on races. '
- 'make sure your nick is correct.\r\n' % nick)
- else:
- if nick in user_cash.keys():
- if notice_status(nick):
- irc.send('NOTICE %s i recognize you now! your current balance is $%s. for help with commands, check here: %s\r\n' % (nick, user_cash[nick], pastebinlink))
- else:
- initialize_user(nick)
- irc.send('NOTICE %s i recognize you now! since this is your first time here, you\'ve been '
- 'given $%s. for help with commands, check here: %s\r\n' % (nick, user_cash[nick], pastebinlink))
- elif source == 'JOIN':
- if not name_validity(nick) and notice_status(nick):
- irc.send('NOTICE %s welcome to #srl-betting! you need to have raced at least once in order to bet on races. '
- 'make sure your nick is correct.\r\n' % nick)
- else:
- if nick in user_cash.keys():
- if notice_status(nick):
- irc.send('NOTICE %s welcome to #srl-betting! your current balance is $%s. for help with commands, check here: %s\r\n' % (nick, user_cash[nick], pastebinlink))
- else:
- initialize_user(nick)
- irc.send('NOTICE %s welcome to #srl-betting! since this is your first time here, you\'ve been '
- 'given $%s. for help with commands, check here: %s\r\n' % (nick, user_cash[nick], pastebinlink))
- elif source == 'PRIVMSG':
- if message == '.notices off':
- filepath = 'C:\\testbot\\betting settings\\notices.txt'
- f = open(filepath, 'r')
- noticelist = f.readline().split('|')
- if nick not in noticelist:
- f = open(filepath, 'a')
- f.write(nick+'|')
- irc.send('NOTICE %s notices have been turned off. i\'ll never bother you again. you don\'t have to be a dick about it.\r\n' % nick)
- else:
- irc.send('NOTICE %s notices are already off. except for this one. whatever.\r\n' % nick)
- elif message == '.notices on':
- filepath = 'C:\\testbot\\betting settings\\notices.txt'
- f = open(filepath, 'r')
- noticelist = f.readline().split('|')
- try:
- noticelist.remove(nick)
- f = open(filepath, 'w')
- f.write('|'.join(noticelist))
- irc.send('NOTICE %s notices have been turned back on. i will serenade you with annoying shit every time you join.\r\n' % nick)
- except ValueError:
- irc.send('NOTICE %s notices are already on. idiot.\r\n' % nick)
Add Comment
Please, Sign In to add comment