Advertisement
Aareon

LDogeCasino Source (13:59pm CST)

Dec 9th, 2015
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.39 KB | None | 0 0
  1. from util.hook import *
  2. import random
  3. import math
  4. import time
  5. from collections import Counter
  6.  
  7. me = 'ldogecasino'
  8. flip = 'flip'
  9. bJ = 'blackjack'
  10. doGamble = 0
  11. tipbotName = 'LDoge-Tipbot'
  12. checkTimeOld = ''
  13. dice = []
  14.  
  15. # !log
  16.  
  17. @hook(cmds=["log"],isTrusted=True)
  18. def sayLog(code, input):
  19.     tipbot = code.chan["#litedoge-casino"][tipbotName]
  20.     check = [i['time'] for i in tipbot['messages']][-1]
  21.     print(check)
  22.  
  23.  
  24. @hook(rule=r'.*tipped')
  25. def tip(code, input):
  26. ##Begin new verify
  27.     if "#litedoge-casino" in input.channel:
  28.         if tipbotName in input.nick:
  29.             if me in input.lower():
  30.                 inp = input.split(' ')
  31.                 betAmt = float(inp[3])
  32.                 betNick = inp[8]
  33.                 betNickLog = code.chan["#litedoge-casino"][betNick]
  34.                 checkMsg = [i['message'] for i in betNickLog['messages']][-1]
  35.                 msg = checkMsg.split(' ')
  36.                 try:
  37.                     if "flip" in msg[3].lower():
  38.                         betFace = msg[4]
  39.                         if betAmt <= 1000:
  40.                             flip(code,betNick,betAmt,betFace)
  41.                             return()
  42.                         else:
  43.                             code.say("!tip "+betNick+" "+str(betAmt)+ ' Maximum bet is 1000')
  44.                             return()
  45.                     if msg[3].lower() in ['donate','donation']:
  46.                         code.say('{red}'+betNick+': Thanks for the donation!')
  47.                     else:
  48.                         code.say("{red}"+betNick+": That's not a game, silly.")
  49.                     return()
  50.                 except IndexError:
  51.                     code.say("{red}"+betNick+": Looks like you're missing something. Try !games")
  52.                     code.say('!tip '+betNick+' '+str(betAmt))
  53.                    
  54.             #game is [3], last param is [4]
  55.  
  56.             #Get value of tip and sender
  57.             #Set chanlog to a variable
  58.             #Get last message of sender (i)
  59.             #If last message of sender contains tip value then
  60.             #Get bet parameters (flip, blackjack, bomb, etc.)
  61.             #Else check last message (i) -1
  62.             #If input.nick is not tipbotName, return()
  63. ###End new verify
  64.  
  65.  
  66. ##Begin old verify
  67.     #tipbot = code.chan["#litedoge-casino"][tipbotName]
  68.     #user = code.chan["#litedoge-casino"][input.nick]
  69. #
  70.     #tipbotMessage = [i['message'] for i in tipbot['messages']][-1]
  71. #
  72.     #userMessageTime = [i['time'] for i in tipbot['messages']][-1]
  73.     #tipbotMessageTime = [i['time'] for i in tipbot['messages']][-1]
  74. #
  75.     #while tipbotMessageTime < userMessageTime:
  76.     #   tipbot = code.chan["#litedoge-casino"][tipbot] #refresh the list
  77.     #   tipbotMessageTime = [i['time'] for i in tipbot['messages']][-1] #get time of last message
  78.     #   tipbotMessage = [i['message'] for i in tipbot['messages']][-1] #refresh last message to use next
  79. #
  80.     #if tipbotMessageTime >= userMessageTime:
  81.     #   if input.nick + "tipped LDogeCasino" in tipbotMessage:
  82.     #       code.reply("Yay!")
  83. ###End verification
  84.  
  85. def flip(code,betNick,betAmt,betFace):
  86.     coin = random.randint(1,2)
  87.     if coin == 1:
  88.         landFace = "heads"
  89.     else:
  90.         landFace = "tails"
  91.     toWin = (betAmt*.3)*.97
  92.     betTotal = betAmt+toWin
  93.     if betFace in landFace:
  94.         code.say("You bet "+str(betAmt)+" ldoge on "+betFace+". The coin landed on "+landFace+". You win "+str(toWin)+"!")
  95.         code.say("!tip "+betNick+" "+str(betTotal))
  96.     else:
  97.         code.say("You bet "+str(betAmt)+" ldoge on "+betFace+". The coin landed on "+landFace)
  98.     return()
  99.  
  100.  
  101. #def dice(code,betNick,betAmt,betDice):
  102. @hook(cmds=["dice"])
  103. def rolldice(code, input):
  104.     dice = []
  105.     try:
  106.         betNick = input.nick
  107.         splitNick = input.split(' ')
  108.         betAmt = int(splitNick[1])
  109.         betDice = int(splitNick[2])
  110.  
  111.         if betAmt > 3000:
  112.             code.reply('Max bet is 3000')
  113.             return()
  114.         else:
  115.             if betDice > 6:
  116.                 code.reply('You must bet on a number between 1-6.')
  117.                 return()
  118.             else:
  119.                 ##code.say(betNick+": I'm working on it!")
  120.                 ##code.say('!tip '+betNick+' '+str(betAmt))
  121.                 ##return()
  122.  
  123.                 #4 dice being rolled, out of those, how many land on the number that the user has bet on
  124.                 dice.append(random.randint(1, 6)), dice.append(random.randint(1, 6)), dice.append(random.randint(1, 6)), dice.append(random.randint(1, 6))
  125.                 dieTotal = dice.count(betDice)
  126.                 if dieTotal > 0:
  127.                     dieWin = (betAmt*(.25*dieTotal))-.97
  128.                     code.say(betNick+': You bet on '+str(betDice)+'. Out of 4 dice, '+str(dieTotal)+' landed on '+str(betDice)+'. You win '+str(dieWin)+'!')
  129.                 else:
  130.                     code.say(betNick+': You bet on '+str(betDice)+'. Out of 4 dice, '+str(dieTotal)+' landed on '+str(betDice)+'. You lost.')
  131.                 return()
  132.     except IndexError:
  133.         code.say("{red}"+betNick+": Looks like you're missing something. Try !games")
  134.         #code.say('!tip '+betNick+' '+str(betAmt))
  135.     except ValueError:
  136.         code.say("{red}"+betNick+": Looks like you're missing something. Try !games")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement