Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from util.hook import *
- import random
- import math
- import time
- from collections import Counter
- me = 'ldogecasino'
- flip = 'flip'
- bJ = 'blackjack'
- doGamble = 0
- tipbotName = 'LDoge-Tipbot'
- checkTimeOld = ''
- dice = []
- # !log
- @hook(cmds=["log"],isTrusted=True)
- def sayLog(code, input):
- tipbot = code.chan["#litedoge-casino"][tipbotName]
- check = [i['time'] for i in tipbot['messages']][-1]
- print(check)
- @hook(rule=r'.*tipped')
- def tip(code, input):
- ##Begin new verify
- if "#litedoge-casino" in input.channel:
- if tipbotName in input.nick:
- if me in input.lower():
- inp = input.split(' ')
- betAmt = float(inp[3])
- betNick = inp[8]
- betNickLog = code.chan["#litedoge-casino"][betNick]
- checkMsg = [i['message'] for i in betNickLog['messages']][-1]
- msg = checkMsg.split(' ')
- try:
- if "flip" in msg[3].lower():
- betFace = msg[4]
- if betAmt <= 1000:
- flip(code,betNick,betAmt,betFace)
- return()
- else:
- code.say("!tip "+betNick+" "+str(betAmt)+ ' Maximum bet is 1000')
- return()
- if msg[3].lower() in ['donate','donation']:
- code.say('{red}'+betNick+': Thanks for the donation!')
- else:
- code.say("{red}"+betNick+": That's not a game, silly.")
- return()
- except IndexError:
- code.say("{red}"+betNick+": Looks like you're missing something. Try !games")
- code.say('!tip '+betNick+' '+str(betAmt))
- #game is [3], last param is [4]
- #Get value of tip and sender
- #Set chanlog to a variable
- #Get last message of sender (i)
- #If last message of sender contains tip value then
- #Get bet parameters (flip, blackjack, bomb, etc.)
- #Else check last message (i) -1
- #If input.nick is not tipbotName, return()
- ###End new verify
- ##Begin old verify
- #tipbot = code.chan["#litedoge-casino"][tipbotName]
- #user = code.chan["#litedoge-casino"][input.nick]
- #
- #tipbotMessage = [i['message'] for i in tipbot['messages']][-1]
- #
- #userMessageTime = [i['time'] for i in tipbot['messages']][-1]
- #tipbotMessageTime = [i['time'] for i in tipbot['messages']][-1]
- #
- #while tipbotMessageTime < userMessageTime:
- # tipbot = code.chan["#litedoge-casino"][tipbot] #refresh the list
- # tipbotMessageTime = [i['time'] for i in tipbot['messages']][-1] #get time of last message
- # tipbotMessage = [i['message'] for i in tipbot['messages']][-1] #refresh last message to use next
- #
- #if tipbotMessageTime >= userMessageTime:
- # if input.nick + "tipped LDogeCasino" in tipbotMessage:
- # code.reply("Yay!")
- ###End verification
- def flip(code,betNick,betAmt,betFace):
- coin = random.randint(1,2)
- if coin == 1:
- landFace = "heads"
- else:
- landFace = "tails"
- toWin = (betAmt*.3)*.97
- betTotal = betAmt+toWin
- if betFace in landFace:
- code.say("You bet "+str(betAmt)+" ldoge on "+betFace+". The coin landed on "+landFace+". You win "+str(toWin)+"!")
- code.say("!tip "+betNick+" "+str(betTotal))
- else:
- code.say("You bet "+str(betAmt)+" ldoge on "+betFace+". The coin landed on "+landFace)
- return()
- #def dice(code,betNick,betAmt,betDice):
- @hook(cmds=["dice"])
- def rolldice(code, input):
- dice = []
- try:
- betNick = input.nick
- splitNick = input.split(' ')
- betAmt = int(splitNick[1])
- betDice = int(splitNick[2])
- if betAmt > 3000:
- code.reply('Max bet is 3000')
- return()
- else:
- if betDice > 6:
- code.reply('You must bet on a number between 1-6.')
- return()
- else:
- ##code.say(betNick+": I'm working on it!")
- ##code.say('!tip '+betNick+' '+str(betAmt))
- ##return()
- #4 dice being rolled, out of those, how many land on the number that the user has bet on
- dice.append(random.randint(1, 6)), dice.append(random.randint(1, 6)), dice.append(random.randint(1, 6)), dice.append(random.randint(1, 6))
- dieTotal = dice.count(betDice)
- if dieTotal > 0:
- dieWin = (betAmt*(.25*dieTotal))-.97
- code.say(betNick+': You bet on '+str(betDice)+'. Out of 4 dice, '+str(dieTotal)+' landed on '+str(betDice)+'. You win '+str(dieWin)+'!')
- else:
- code.say(betNick+': You bet on '+str(betDice)+'. Out of 4 dice, '+str(dieTotal)+' landed on '+str(betDice)+'. You lost.')
- return()
- except IndexError:
- code.say("{red}"+betNick+": Looks like you're missing something. Try !games")
- #code.say('!tip '+betNick+' '+str(betAmt))
- except ValueError:
- code.say("{red}"+betNick+": Looks like you're missing something. Try !games")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement