Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- reel_list = []
- goldenslots_flag = False
- delay_value = 0.2
- cur_delay = delay_value
- which_reel = 0
- animated_msg = None
- goldenslots_msg = None
- disable_interrupts = False
- goldenslots_user = None
- def kill_timers():
- global reel_list
- for reel_object in reel_list:
- reel_object.cancel()
- def kill_goldenslots():
- kill_timers()
- botchannelobject = None
- for server in client.servers:
- if server.name == "PokemonSpeedruns":
- for channel in server.channels:
- if channel.name == config.bot_channel:
- botchannelobject = channel
- break
- client.send_message(channel,"Inactivity with current GoldenSlots, shutting down!")
- global goldenslots_flag
- goldenslots_flag = False
- def cmd_goldenslots(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- global goldenslots_flag
- if goldenslots_flag:
- client.send_message(saved_message.channel,"GoldenSlots is currently assisting someone.")
- global goldenslots_user
- goldenslots_user = author
- num_loops = 5 #int(queries["2"])
- max_slot = 17 #int(queries["1"])
- intro_msg = client.send_message(saved_message.channel,"Time to play GoldenSlots!")
- separator = " | "
- all_goldenslots = []
- reel_1 = []
- reel_2 = []
- reel_3 = []
- goldenslots_emotes = random.sample(config.emotes, 16)
- for slot in range(max_slot):
- temp_emotes = []
- for random_emote in range(3):
- temp_emotes.append(random.choice(goldenslots_emotes))
- reel_1.append(temp_emotes[0])
- reel_2.append(temp_emotes[1])
- reel_3.append(temp_emotes[2])
- all_goldenslots.append(temp_emotes[0] + separator + temp_emotes[1] + separator + temp_emotes[2])
- old_times = []
- initialslots = ""
- print all_goldenslots
- for initial_reel in all_goldenslots[0:3]:
- initialslots += initial_reel + "\r\n"
- initialslots = initialslots[:-2]
- global goldenslots_msg
- goldenslots_msg = client.send_message(saved_message.channel,initialslots)
- global animated_msg
- animated_msg = initialslots
- reel_1_final_emotes = []
- reel_2_final_emotes = []
- reel_3_final_emotes = []
- global disable_interrupts
- def goldenslots_reel_firstround(cur_slot):
- global animated_msg
- temp_slot = cur_slot
- old_times.append([time.clock()])
- animated_msg = ((animated_msg.split("\r\n", 1))[1] + "\r\n" + all_goldenslots[cur_slot])
- client.edit_message(goldenslots_msg,animated_msg)
- old_times[temp_slot-3].append(time.clock())
- def goldenslots_reel(times_index,index):
- global delay_value
- global cur_delay
- global goldenslots_flag
- global which_reel
- global animated_msg
- global disable_interrupts
- if goldenslots_flag:
- old_times.append([time.clock()])
- if not which_reel:
- animated_msg = ((animated_msg.split("\r\n", 1))[1] + "\r\n" + all_goldenslots[index])
- client.edit_message(goldenslots_msg,animated_msg)
- elif which_reel == 1:
- if not disable_interrupts:
- disable_interrupts = True
- reel_1_final_emotes.append(reel_1[index-2])
- reel_1_final_emotes.append(reel_1[index-1])
- reel_1_final_emotes.append(reel_1[index])
- animated_msg = "%s | %s | %s\r\n%s | %s | %s\r\n%s | %s | %s" % (
- reel_1_final_emotes[0], reel_2[index-2], reel_3[index-2],
- reel_1_final_emotes[1], reel_2[index-1], reel_3[index-1],
- reel_1_final_emotes[2], reel_2[index], reel_3[index]
- )
- client.edit_message(goldenslots_msg,animated_msg)
- which_reel += 1
- disable_interrupts = False
- elif which_reel == 2:
- animated_msg = "%s | %s | %s\r\n%s | %s | %s\r\n%s | %s | %s" % (
- reel_1_final_emotes[0], reel_2[index-2], reel_3[index-2],
- reel_1_final_emotes[1], reel_2[index-1], reel_3[index-1],
- reel_1_final_emotes[2], reel_2[index], reel_3[index]
- )
- client.edit_message(goldenslots_msg,animated_msg)
- elif which_reel == 3:
- if not disable_interrupts:
- disable_interrupts = True
- reel_2_final_emotes.append(reel_2[index-2])
- reel_2_final_emotes.append(reel_2[index-1])
- reel_2_final_emotes.append(reel_2[index])
- animated_msg = "%s | %s | %s\r\n%s | %s | %s\r\n%s | %s | %s" % (
- reel_1_final_emotes[0], reel_2_final_emotes[0], reel_3[index-2],
- reel_1_final_emotes[1], reel_2_final_emotes[1], reel_3[index-1],
- reel_1_final_emotes[2], reel_2_final_emotes[2], reel_3[index]
- )
- client.edit_message(goldenslots_msg,animated_msg)
- which_reel += 1
- disable_interrupts = False
- elif which_reel == 4:
- animated_msg = "%s | %s | %s\r\n%s | %s | %s\r\n%s | %s | %s" % (
- reel_1_final_emotes[0], reel_2_final_emotes[0], reel_3[index-2],
- reel_1_final_emotes[1], reel_2_final_emotes[1], reel_3[index-1],
- reel_1_final_emotes[2], reel_2_final_emotes[2], reel_3[index]
- )
- client.edit_message(goldenslots_msg,animated_msg)
- reel_list[index] = (threading.Timer(cur_delay, goldenslots_reel, [times_index,index]))
- reel_list[index].daemon = True
- (reel_list[index]).start()
- old_times[times_index].append(time.clock())
- def wait_for_timers():
- count = 0
- none_alive = False
- reel_list_len = len(reel_list) - 1
- while not none_alive:
- if len(reel_list) == 0:
- break
- for reel in reel_list:
- if reel.is_alive():
- break
- elif reel_list.index(reel) == reel_list_len:
- none_alive = True
- global reel_list
- reel_list = []
- global delay_value
- global cur_delay
- for cur_slot in range(3,max_slot):
- reel_list.append(threading.Timer(cur_delay, goldenslots_reel_firstround, [cur_slot]))
- reel_list[cur_slot-3].daemon = True
- (reel_list[cur_slot-3]).start()
- cur_delay += delay_value
- wait_for_timers()
- global which_reel
- which_reel = 0
- index = 0
- reel_list = []
- delay_value = 0.2
- cur_delay = delay_value
- for i in range(max_slot):
- times_index = len(old_times) + i
- reel_list.append(threading.Timer(cur_delay, goldenslots_reel, [times_index,i]))
- reel_list[i].daemon = True
- (reel_list[i]).start()
- cur_delay += delay_value
- reel_list.append(threading.Timer(30, kill_goldenslots))
- reel_list[len(reel_list) - 1].daemon = True
- reel_list[len(reel_list) - 1].start()
- goldenslots_flag = True
- client.send_message(saved_message.channel,'Use "!reel" to stop the reels!')
- def cmd_reel(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- global goldenslots_flag
- global goldenslots_msg
- global goldenslots_user
- if not goldenslots_flag:
- client.send_message(saved_message.channel,"GoldenSlots hasn't been activated yet.")
- return
- elif goldenslots_user != author:
- client.send_message(saved_message.channel,"Someone is currently using GoldenSlots.")
- return
- global which_reel
- if which_reel == 4:
- kill_timers()
- client.send_message(saved_message.channel,"GoldenSlots has been completed.")
- goldenslots_flag = False
- elif which_reel == 0 or which_reel == 2:
- which_reel += 1
- print which_reel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement