Advertisement
Aareon

I'm jumping

Dec 8th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.29 KB | None | 0 0
  1. from util.hook import *
  2. import random
  3. import math
  4. import time
  5.  
  6. me = 'LDogeCasino'
  7. flip = 'flip'
  8. bJ = 'blackjack'
  9. doGamble = 0
  10. tipbotName = 'LDoge-Tipbot'
  11. checkTimeOld = ''
  12.  
  13.  
  14. @hook(cmds=["log"],isTrusted=True)
  15. def sayLog(code, input):
  16.     tipbot = code.chan["#litedoge-casino"][tipbotName]
  17.     check = [i['time'] for i in tipbot['messages']][-1]
  18.     print(check)
  19.  
  20.  
  21. @hook(rule=r'.*tipped '+me)
  22. def tip(code, input):
  23.  
  24. ##Add $ to inp[3]
  25.  
  26. ##Begin new verify
  27.     if "#litedoge-casino" in input.channel:
  28.         if tipbotName in input.nick:
  29.             if me in input:
  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.                 checkTimeNew = [i['time'] for i in betNickLog['messages']][-1] #set new message to a variable
  36.                 if checkTimeNew == checkTimeOld:
  37.                     return()
  38.                 else:
  39.                     msg = checkMsg.split(' ')
  40.                     try:
  41.                         if "flip" in msg[3].lower():
  42.                             betFace = msg[4]
  43.                             flip(code,betNick,betAmt,betFace)
  44.                         if msg[3].lower() in ['donate','donation']:
  45.                             code.say('{red}'+betNick+': Thanks for the donation!')
  46.                         else:
  47.                             code.say("{red}"+betNick+": That's not a game, silly.")
  48.                     checkTimeOld = checkTimeNew
  49.                     except IndexError:
  50.                         code.say("{red}"+betNick+": Looks like you're missing something. Try !games")
  51.                         code.say('!tip '+betNick+' '+str(betAmt))
  52.             else:
  53.                 return()
  54.         elif me in input.nick:
  55.             return()
  56.             #game is [3], last param is [4]
  57.  
  58.             #Get value of tip and sender
  59.             #Set chanlog to a variable
  60.             #Get last message of sender (i)
  61.             #If last message of sender contains tip value then
  62.             #Get bet parameters (flip, blackjack, bomb, etc.)
  63.             #Else check last message (i) -1
  64.             #If input.nick is not tipbotName, return()
  65. ###End new verify
  66.  
  67.  
  68. ##Begin old verify
  69.     #tipbot = code.chan["#litedoge-casino"][tipbotName]
  70.     #user = code.chan["#litedoge-casino"][input.nick]
  71. #
  72.     #tipbotMessage = [i['message'] for i in tipbot['messages']][-1]
  73. #
  74.     #userMessageTime = [i['time'] for i in tipbot['messages']][-1]
  75.     #tipbotMessageTime = [i['time'] for i in tipbot['messages']][-1]
  76. #
  77.     #while tipbotMessageTime < userMessageTime:
  78.     #   tipbot = code.chan["#litedoge-casino"][tipbot] #refresh the list
  79.     #   tipbotMessageTime = [i['time'] for i in tipbot['messages']][-1] #get time of last message
  80.     #   tipbotMessage = [i['message'] for i in tipbot['messages']][-1] #refresh last message to use next
  81. #
  82.     #if tipbotMessageTime >= userMessageTime:
  83.     #   if input.nick + "tipped LDogeCasino" in tipbotMessage:
  84.     #       code.reply("Yay!")
  85. ###End verification
  86.  
  87. def flip(code,betNick,betAmt,betFace):
  88.     while betAmt > 1000:
  89.         code.say("!tip "+betNick+" "+str(betAmt))
  90.         code.say(betNick+": Maximum bet is 1000")
  91.         code.say("!tip "+betNick+" "+str(betAmt))
  92.         break
  93.     else:
  94.         coin = random.randint(1,2)
  95.         if coin == 1:
  96.             landFace = "heads"
  97.         else:
  98.             landFace = "tails"
  99.         toWin = (betAmt*.3)*.98
  100.         betTotal = betAmt+toWin
  101.         if betFace in landFace:
  102.             code.say("You bet "+str(betAmt)+" ldoge on "+betFace+". The coin landed on "+landFace+". You win "+str(toWin)+"!")
  103.             code.say("!tip "+betNick+" "+str(betTotal))
  104.             doGamble = 1
  105.         else:
  106.             code.say("You bet "+str(betAmt)+" ldoge on "+betFace+". The coin landed on "+landFace)
  107.             doGamble = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement