weedlord1998

Untitled

Jul 18th, 2011
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.27 KB | None | 0 0
  1. def betting(nick, channel, message, source): #main betting function
  2.  
  3. # betting todo (- = complete)
  4.  
  5. #-track entrants
  6. #-track active bets (races with entry open)
  7. #-nick changes (welcome notice on correct nick)
  8. #-option to turn off notices
  9. # track first .done and payout
  10. # .give/.donate user amount
  11. # .bet user amount
  12. # .removebet user
  13. # .pool channel
  14. # .balance user (blank gives self)
  15. # .bets user
  16. # minimum balance?
  17. # bet precision (no decimals)
  18. # track bet history...?
  19. # back up money for rollbacks
  20. # bet against bot with odds based on rankings
  21. # .top10
  22. # .bottom10
  23.  
  24.     pastebinlink = '(pastebin goes here)'
  25.    
  26.     def name_validity(nick):
  27.         srlprofile = urllib2.urlopen('http://speedrunslive.com/profiles/?player=%s' % nick).read()
  28.         if srlprofile == 'Not a valid player name.': return False
  29.         else: return True
  30.        
  31.     def initialize_user(nick):
  32.         filepath = 'C:\\testbot\\betting users\\%s.txt' % nick
  33.         f = open(filepath, 'w')
  34.         cash = '10000'
  35.         f.write(cash)
  36.         f.close()
  37.         user_cash[nick] = cash
  38.    
  39.     def notice_status(nick):
  40.         filepath = 'C:\\testbot\\betting settings\\notices.txt'
  41.         f = open(filepath, 'r')
  42.         if nick+'|' in f.readline():
  43.             f.close()
  44.             return False #notices off
  45.         else:
  46.             f.close()
  47.             return True #notices on
  48.              
  49.     if source == 'NICK':
  50.         if not name_validity(nick) and notice_status(nick):
  51.             irc.send('NOTICE %s hey, i don\'t recognize you! you need to have raced at least once in order to bet on races. '
  52.                      'make sure your nick is correct.\r\n' % nick)
  53.         else:
  54.             if nick in user_cash.keys():
  55.                 if notice_status(nick):
  56.                     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))
  57.             else:
  58.                 initialize_user(nick)
  59.                 irc.send('NOTICE %s i recognize you now! since this is your first time here, you\'ve been '
  60.                          'given $%s. for help with commands, check here: %s\r\n' % (nick, user_cash[nick], pastebinlink))
  61.                          
  62.     elif source == 'JOIN':
  63.         if not name_validity(nick) and notice_status(nick):
  64.             irc.send('NOTICE %s welcome to #srl-betting! you need to have raced at least once in order to bet on races. '
  65.                      'make sure your nick is correct.\r\n' % nick)
  66.         else:
  67.             if nick in user_cash.keys():
  68.                 if notice_status(nick):
  69.                     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))
  70.             else:
  71.                 initialize_user(nick)
  72.                 irc.send('NOTICE %s welcome to #srl-betting! since this is your first time here, you\'ve been '
  73.                          'given $%s. for help with commands, check here: %s\r\n' % (nick, user_cash[nick], pastebinlink))
  74.    
  75.     elif source == 'PRIVMSG':
  76.         if message == '.notices off':
  77.             filepath = 'C:\\testbot\\betting settings\\notices.txt'
  78.             f = open(filepath, 'r')
  79.             noticelist = f.readline().split('|')
  80.             if nick not in noticelist:
  81.                 f = open(filepath, 'a')
  82.                 f.write(nick+'|')
  83.                 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)
  84.             else:
  85.                 irc.send('NOTICE %s notices are already off. except for this one. whatever.\r\n' % nick)
  86.         elif message == '.notices on':
  87.             filepath = 'C:\\testbot\\betting settings\\notices.txt'
  88.             f = open(filepath, 'r')
  89.             noticelist = f.readline().split('|')
  90.             try:
  91.                 noticelist.remove(nick)
  92.                 f = open(filepath, 'w')
  93.                 f.write('|'.join(noticelist))
  94.                 irc.send('NOTICE %s notices have been turned back on. i will serenade you with annoying shit every time you join.\r\n' % nick)
  95.             except ValueError:
  96.                 irc.send('NOTICE %s notices are already on. idiot.\r\n' % nick)
Add Comment
Please, Sign In to add comment