Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import discord
- import logging
- import random
- import json
- import math
- from yaml import safe_load
- from dis import dis
- slots_data = {}
- autorepeat_cooldown = [time.time()]
- nodecimal = lambda x: ("%s" % (x))[:-2]
- dabomstew_pls = [False]
- dabomstew_cooldown_times = [182.767000198,182.77699995,182.802000046,182.616000175]
- def slots_calcpoints(level):
- if level >= 12.1:
- level = 42069 ** (1/math.log10(level))
- elif level == 1:
- level = 42069
- else:
- temp_value = int(math.sqrt(-69420 * (level-69)))
- level = 6.9 * temp_value
- level = round(level)
- return level
- def add_user(username):
- slots_data[username] = {
- "slots_cooldown": time.time(),
- "slots_wins": 0,
- "slots_tries": 0,
- "slots_executions": 0,
- "slots_points": 0,
- "slots_unluckiest": 0,
- "slots_coincooldown": time.time(),
- }
- def save_slots():
- temp_data = slots_data
- with open('slots_data.json', 'w') as fp:
- json.dump(temp_data, fp, sort_keys = True)
- def load_slots():
- with open('slots_data.json', 'r') as fp:
- slots_data = safe_load(fp)
- return slots_data
- def slots_updatetime(username):
- slots_data[username]["slots_cooldown"] = time.time()
- def slots_updatewins(username):
- slots_data[username]["slots_wins"] += 1
- def slots_updatetries(username,tries):
- slots_data[username]["slots_tries"] += tries
- def slots_updateexecutions(username):
- slots_data[username]["slots_executions"] += 1
- def slots_updatepoints(username,amount):
- slots_data[username]["slots_points"] += amount
- def slots_updateworst(username,tries):
- slots_data[username]["slots_worst"] = tries
- def slots_updatecointime(username):
- slots_data[username]["slots_coincooldown"] = time.time()
- luckymsgs = []
- animationmsgs = []
- disablespam = [True]
- """
- FORMAT: Username, Cooldown, number of first try wins, total tries, total command executions, performance
- """
- # Set up the logging module to output diagnostic to the console.
- logging.basicConfig()
- client = discord.Client()
- client.login('yellow151@memebig.net', 'kappa42069') # username/password
- if not client.is_logged_in:
- print('Logging in to Discord failed')
- exit(1)
- @client.event
- def on_ready():
- print('Connected!')
- print('Username: ' + client.user.name)
- print('ID: ' + client.user.id)
- print('------')
- global slots_data
- slots_data = load_slots()
- print(slots_data)
- save_slots()
- for server in client.servers:
- print(server.name)
- if server.name == "PokemonSpeedruns":
- for channel in server.channels:
- print(channel.name)
- if channel.name == bot_channel:
- client.send_message(channel, "jp Start")
- """
- for server in client.servers:
- print(server.name)
- if server.name != "PokemonSpeedruns":
- continue
- for channel in server.channels:
- print(channel.name)
- if channel.name != bot_channel:
- continue
- for role in server.roles:
- client.send_message(channel,role.name)
- """
- permissions = ["botowner","admin","moderator","user"]
- def cmd_luckypls(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- if len(luckymsgs) >= 1:
- if saved_message.content == "!luckyplsperma" and author != "luckytyphlosion":
- Kappa = ""
- for count in range(3):
- Kappa += "Kappa "
- client.send_message(saved_message.channel, Kappa)
- for count in range(2):
- Kappa = Kappa[:-6]
- client.send_message(saved_message.channel, Kappa)
- else:
- for message in luckymsgs:
- if message.channel != saved_message.channel:
- continue
- else:
- client.edit_message(message, "<message deleted>")
- if saved_message.content == "!luckyplsperma" and author == "luckytyphlosion":
- pass
- else:
- time.sleep(6.9)
- for message in luckymsgs:
- if message.channel != saved_message.channel:
- continue
- else:
- client.edit_message(message, message.content)
- def cmd_test(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- client.send_message(saved_message.channel, "icicles")
- def cmd_yolocoin(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- if not checkForProfile:
- userNoProfile()
- elif saved_message.channel.name == bot_channel and (time.time() - (slots_data[author]["slots_coincooldown"]) >= 180):
- saved_points = slots_data[author]["slots_points"]
- if random.randint(0, 1) == 1:
- slots_updatepoints(author, saved_points)
- client.send_message(saved_message.channel, "Heads. +%s points." % nodecimal(saved_points))
- else:
- slots_updatepoints(author, -saved_points)
- client.send_message(saved_message.channel, "Tails. -%s points." % nodecimal(saved_points))
- client.send_message(saved_message.channel, "Congratulations on the new RIP!")
- save_slots()
- slots_updatecointime(author)
- elif saved_message.channel.name == bot_channel:
- client.send_message(saved_message.channel,taguser() + "On cooldown. (%d secs)" % (180 - (time.time() - slots_data[author]["slots_coincooldown"])))
- def cmd_coin(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- saved_points = int(queries["1"])
- if not checkForProfile:
- userNoProfile()
- elif saved_message.channel.name == bot_channel and (time.time() - (slots_data[author]["slots_coincooldown"]) >= 180) and abs(saved_points) <= slots_data[author]["slots_points"]:
- coinflip = random.randint(0, 1)
- if coinflip == 1:
- slots_updatepoints(author, saved_points)
- sign = "+"
- if saved_points < 0:
- sign = "-"
- client.send_message(saved_message.channel, "Heads. " + sign + "%s points." % abs(saved_points))
- else:
- sign = "-"
- slots_updatepoints(author, -saved_points)
- if saved_points < 0:
- sign = "+"
- client.send_message(saved_message.channel, "Tails. " + sign + "%s points." % abs(saved_points))
- slots_updatecointime(author)
- save_slots()
- elif saved_message.channel.name == bot_channel:
- client.send_message(saved_message.channel,taguser() + "On cooldown. (%d secs)" % (180 - (time.time() - slots_data[author]["slots_coincooldown"])))
- def cmd_animation(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- luckypls = "!luckypls"
- tempstring = " _ _ "
- anim_msg = client.send_message(saved_message.channel, luckypls)
- for count in range(10):
- luckypls = tempstring + luckypls + tempstring
- anim_msg = client.edit_message(anim_msg, luckypls)
- for count in range(10):
- luckypls = luckypls[5:-5]
- anim_msg = client.edit_message(anim_msg, luckypls)
- def cmd_scrolltext(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- scrollmsg = queries["Query"]
- sentmsg = client.send_message(saved_message.channel, "_ _")
- deltamsg = ""
- for char in scrollmsg:
- deltamsg += char
- anim_msg = client.edit_message(sentmsg, deltamsg)
- def cmd_wall(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- print queries
- if not disablespam[0]:
- wall = ""
- size = int(queries["1"])
- wallargs = queries["2-"]
- if wallargs:
- for count in range(size):
- client.send_message(saved_message.channel, wallargs)
- else:
- client.send_message(saved_message.channel, "No sending null messages!")
- def cmd_pyramid(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- if not disablespam[0]:
- pyramid = ""
- size = int(queries["1"])
- pyramidargs = queries["2-"]
- if pyramidargs:
- for count in range(size):
- pyramid += pyramidargs + " "
- client.send_message(saved_message.channel, pyramid)
- for count in range(size-1):
- pyramid = pyramid[:-(len(pyramidargs)+1)]
- client.send_message(saved_message.channel, pyramid)
- else:
- client.send_message(saved_message.channel, "No sending null messages!")
- def cmd_funkytext(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- scrollmsg = queries["Query"]
- tempstring = " "
- deltamsg = "_ _"
- somemsg = client.send_message(saved_message.channel,"_ _")
- for count in range(5):
- some_count = 0
- for char in scrollmsg:
- deltamsg = tempstring * some_count + char + tempstring * (len(scrollmsg) - some_count)
- client.edit_message(somemsg, deltamsg)
- some_count += 1
- client.edit_message(somemsg, scrollmsg)
- def cmd_enablespam(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- disablespam[0] = False
- def cmd_disablespam(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- disablespam[0] = True
- def cmd_slots(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- if not checkForProfile():
- add_user(author)
- slots_cooldown = time.time() - (slots_data[author]["slots_cooldown"])
- if author == "Dabomstew":
- dabomstew_cooldown_times.append(slots_cooldown)
- print "Dabomstew's Cooldown: %s" % slots_cooldown
- if len(dabomstew_cooldown_times) >= 7 and (max(dabomstew_cooldown_times) - min(dabomstew_cooldown_times) < 5):
- dabomstew_pls[0] = True
- if saved_message.channel.name == bot_channel and ((time.time() - (slots_data[author]["slots_cooldown"]) >= 180) or (slots_data[author]["slots_executions"] == 0)):
- debugcount = 1
- while True:
- sampled_emotes = random.sample([":bowtie:",":smile:",":laughing:",":blush:",":smiley:",":relaxed:",":smirk:",":heart_eyes:",":kissing_heart:",":kissing_closed_eyes:",":flushed:",":relieved:",":satisfied:",":grin:",":wink:",":stuck_out_tongue_winking_eye:",":stuck_out_tongue_closed_eyes:",":grinning:",":kissing:",":kissing_smiling_eyes:",":stuck_out_tongue:",":sleeping:",":worried:",":frowning:",":anguished:",":open_mouth:",":grimacing:",":confused:",":hushed:",":expressionless:",":unamused:",":sweat_smile:",":sweat:",":disappointed_relieved:",":weary:",":pensive:",":disappointed:",":confounded:",":fearful:",":cold_sweat:",":persevere:",":cry:",":sob:",":joy:",":astonished:",":scream:",":neckbeard:",":tired_face:",":angry:",":rage:",":triumph:",":sleepy:",":yum:",":mask:",":sunglasses:",":dizzy_face:",":imp:",":smiling_imp:",":neutral_face:",":no_mouth:",":innocent:",":alien:",":yellow_heart:",":blue_heart:",":purple_heart:",":heart:",":green_heart:",":broken_heart:",":heartbeat:",":heartpulse:",":two_hearts:",":revolving_hearts:",":cupid:",":sparkling_heart:",":sparkles:",":star:",":star2:",":dizzy:",":boom:",":collision:",":anger:",":exclamation:",":question:",":grey_exclamation:",":grey_question:",":zzz:",":dash:",":sweat_drops:",":notes:",":musical_note:",":fire:",":hankey:",":poop:",":shit:",":+1:",":thumbsup:",":-1:",":thumbsdown:",":ok_hand:",":punch:",":facepunch:",":fist:",":v:",":wave:",":hand:",":raised_hand:",":open_hands:",":point_up:",":point_down:",":point_left:",":point_right:",":raised_hands:",":pray:",":point_up_2:",":clap:",":muscle:",":metal:",":fu:",":runner:",":running:",":couple:",":family:",":two_men_holding_hands:",":two_women_holding_hands:",":dancer:",":dancers:",":ok_woman:",":no_good:",":information_desk_person:",":raising_hand:",":bride_with_veil:",":person_with_pouting_face:",":person_frowning:",":bow:",":couplekiss:",":couple_with_heart:",":massage:",":haircut:",":nail_care:",":boy:",":girl:",":woman:",":man:",":baby:",":older_woman:",":older_man:",":person_with_blond_hair:",":man_with_gua_pi_mao:",":man_with_turban:",":construction_worker:",":cop:",":angel:",":princess:",":smiley_cat:",":smile_cat:",":heart_eyes_cat:",":kissing_cat:",":smirk_cat:",":scream_cat:",":crying_cat_face:",":joy_cat:",":pouting_cat:",":japanese_ogre:",":japanese_goblin:",":see_no_evil:",":hear_no_evil:",":speak_no_evil:",":guardsman:",":skull:",":feet:",":lips:",":kiss:",":droplet:",":ear:",":eyes:",":nose:",":tongue:",":love_letter:",":bust_in_silhouette:",":busts_in_silhouette:",":speech_balloon:",":thought_balloon:",":feelsgood:",":finnadie:",":goberserk:",":godmode:",":hurtrealbad:",":rage1:",":rage2:",":rage3:",":rage4:",":suspect:",":trollface:"],16)
- slots = []
- for count in range(3):
- slots.append(random.choice(sampled_emotes))
- if slots[0] == slots[1] and slots[1] == slots[2]:
- slotsmsg = ""
- slotsmsg += taguser() + "%s | %s | %s" % (slots[0],slots[1],slots[2])
- newpoints = slots_calcpoints(debugcount)
- if (dabomstew_pls[0] and author == "Dabomstew") or saved_message.content == "!slots_dabomstewisadirtycheater":
- newpoints = newpoints * -1
- slots_updatepoints(author, newpoints)
- nodecimal_msg = nodecimal(newpoints)
- slotsmsg += " Number of tries: %s. Points won: %s" % (debugcount,nodecimal_msg)
- if slots_data[author]["slots_worst"] < debugcount:
- slots_updateworst(author,debugcount)
- if (dabomstew_pls[0] and author == "Dabomstew") or saved_message.content == "!slots_dabomstewisadirtycheater":
- for count in range(20):
- client.send_message(saved_message.channel, slotsmsg)
- else:
- client.send_message(saved_message.channel, slotsmsg)
- if debugcount == 1:
- slotsmsg_win = tagusernoarrow() + "has won slots"
- client.send_message(saved_message.channel, slotsmsg_win)
- slots_updatewins(author)
- break
- else:
- debugcount += 1
- slots_updatetime(author)
- slots_updatetries(author,debugcount)
- slots_updateexecutions(author)
- save_slots()
- elif saved_message.channel.name == bot_channel:
- client.send_message(saved_message.channel,taguser() + "On cooldown. (%d secs)" % (180 - (time.time() - slots_data[author]["slots_cooldown"])))
- def cmd_points(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- pointsuser = author
- if queries["1"].lower() in correctcase_usernames:
- pointsuser = correctcase_usernames[queries["1"].lower()]
- if not checkForProfile and recordsuser == author:
- userNoProfile()
- else:
- slots_pointsmsg = taguser()
- nodecimal_msg = nodecimal(slots_data[pointsuser]["slots_points"])
- if pointsuser == author:
- slots_pointsmsg += "Your balance is %s points" % nodecimal_msg
- else:
- slots_pointsmsg += "%s's balance is %s points" % (pointsuser,nodecimal_msg)
- client.send_message(saved_message.channel, slots_pointsmsg)
- def cmd_slotsrecords(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- recordsuser = author
- if queries["1"].lower() in correctcase_usernames:
- recordsuser = correctcase_usernames[queries["1"].lower()]
- if not checkForProfile() and recordsuser == author:
- userNoProfile()
- else:
- records = [
- ["Number of !slots done","slots_executions"],
- ["Number of tries","slots_tries"],
- ["Number of wins","slots_wins"],
- ["Worst roll","slots_worst"],
- ]
- slots_recordmsg = taguser()
- if recordsuser == author:
- slots_recordmsg += "Your stats are:\r\n"
- else:
- slots_recordmsg += "%s's stats are:\r\n" % recordsuser
- for record in records:
- slots_recordmsg += record[0] + ": %s" % (slots_data[recordsuser][record[1]]) + "\r\n"
- client.send_message(saved_message.channel, slots_recordmsg)
- def cmd_leaderboards(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- temp_boards = [(slots_data[username]["slots_points"], username) for username in slots_data]
- temp_boards.sort(key=lambda l: l[0], reverse=True)
- boards_message = taguser() + "\r\n%s" % ('\r\n'.join(l[1] + u': ' + unicode(l[0]) for l in temp_boards[:5]))
- client.send_message(saved_message.channel, boards_message)
- def cmd_anyone(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- client.send_message(saved_message.channel, "Anyone can get a %s in %s with good execution" % (queries["1"],queries["2"]))
- def cmd_usernoprofile(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- userNoProfile()
- def cmd_dc(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- if random.randint(0,255) == 69:
- if saved_message.channel.name == bot_channel:
- for count in range(0,69):
- client.send_message(saved_message.channel, "rst $38")
- client.send_message(saved_message.channel,"halt while LCD off")
- exit(1)
- else:
- client.send_message(saved_message.channel,"You got the 1/256 chance of missing the power button!")
- else:
- client.send_message(saved_message.channel,"Stopping!")
- exit(1)
- def cmd_rigged(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
- client.send_message(saved_message.channel,"Think the bot rigs coin outcomes? Try out negative coins then! Your endless tails streak will soon turn your measly point balance into a 7 digit figure!")
- def get_queries(query,query_types,query_separator):
- if query_types[0]:
- required_queries = {}
- indiv_queries = query.split(query_separator)
- print "Individual Queries: %s" % indiv_queries
- for arg in query_types:
- if arg > 0:
- required_queries["%s" % arg] = indiv_queries[arg-1].strip()
- else:
- arg_name = ""
- if arg == -1:
- arg_name = "Query"
- else:
- arg_name = "%s-" % abs(arg)
- required_queries[arg_name] = (query.split(query_separator,abs(arg)-1 ).pop()).strip()
- return required_queries
- else:
- return {"Query":None}
- bot_channel = "meme-bots"
- """
- command format:
- - command name
- - command function pointer
- - command permissions
- - command channel permissions (None = all channels)
- - command *args
- - command args splitter:
- - special cases:
- - "" = absolute command
- - None = any length of whitespace
- - command splitter
- """
- commands = {
- "!luckypls":[cmd_luckypls,"Member",None,[0],None,None],
- "!luckyplsperma":[cmd_luckypls,"BotOwner",None,[0],None,None],
- "!luckyplsperma":[cmd_luckypls,"Member",None,[0],None,None],
- "test":[cmd_test,"Member",None,[0],"",None],
- "!yolocoin":[cmd_yolocoin,"Member",bot_channel,[0],None,None],
- "!animation":[cmd_animation,"Member",None,[0],None,None],
- "!scrolltext":[cmd_scrolltext,"Member",None,[-1],None,None],
- "!wall":[cmd_wall,"Moderators",None,[1,-2],"-",None],
- "!pyramid":[cmd_pyramid,"Moderators",None,[1,-2],"-",None],
- "!funkytext":[cmd_funkytext,"User",None,[-1],None,None],
- "!enablespam":[cmd_enablespam,"Moderators",None,[0],None,None],
- "!disablespam":[cmd_disablespam,"Moderators",None,[0],None,None],
- "!slots":[cmd_slots,"Member",bot_channel,[0],None,None],
- "!records":[cmd_slotsrecords,"Member",bot_channel,[1],None,None],
- "!points":[cmd_points,"Member",bot_channel,[1],None,None],
- "!leaderboards":[cmd_leaderboards,"Member",bot_channel,[0],None,None],
- "!anyone":[cmd_anyone,"Member",None,[1,2],None,"\\"],
- "luckypls":[cmd_luckypls,"Member",None,[0],None,None],
- "!slots_dabomstewisadirtycheater":[cmd_slots,"Member",None,[0],None,None],
- "!usernoprofile":[cmd_usernoprofile,"BotOwner",None,[0],None,None],
- "!coin":[cmd_coin,"Member",bot_channel,[1],None,None],
- "!dc":[cmd_dc,"BotOwner",None,[0],None,None],
- "luckyplz":[cmd_luckypls,"Member",None,[0],None,None],
- "!rigged":[cmd_rigged,"Member",bot_channel,[0],None,None],
- }
- @client.event
- def on_message(message):
- saved_message = message
- author = saved_message.author.name
- taguser = lambda: "<@%s> -> " % (saved_message.author.id)
- tagusernoarrow = lambda: "<@%s> " % (saved_message.author.id)
- checkForProfile = lambda: True if author in slots_data else False
- userNoProfile = lambda: client.send_message(saved_message.channel, taguser() + "You haven't played slots yet.")
- correctcase_usernames = {u.lower(): u for u in slots_data.keys()}
- if author == "luckytyphlosion" and len(luckymsgs) >= 10:
- temp_message = luckymsgs.pop(0)
- # commandmanager
- possible_cmd = saved_message.content
- new_cmd = False
- saved_possible_cmd = possible_cmd
- for command in commands:
- possible_cmd = saved_possible_cmd
- if commands[command][4] == "": # get absolute value
- if command != possible_cmd:
- continue
- else:
- new_cmd = command
- break
- else:
- possible_cmd = (possible_cmd.split(commands[command][4],1))[0]
- command_ = (command.split(commands[command][4],1))[0]
- if commands[command][4]:
- possible_cmd += commands[command][4]
- command_ += commands[command][4]
- else:
- possible_cmd = possible_cmd.strip() + " "
- command_ = command.strip() + " "
- if command_.startswith(possible_cmd):
- new_cmd = command
- break
- # found a command
- if new_cmd:
- command = new_cmd
- # check perms
- can_execute_cmd = False
- for role_no in range(len(saved_message.author.roles)):
- if can_execute_cmd:
- break
- if author == "luckytyphlosion" or command == "!slots": # bot owner has access to all commands
- print(saved_message.author.roles[role_no].name + " | " + commands[command][1])
- pass
- else:
- if commands[command][1] != saved_message.author.roles[role_no].name:
- print(saved_message.author.roles[role_no].name + " | " + commands[command][1])
- continue
- # check channel perms
- if not commands[command][2]:
- can_execute_cmd = True
- break
- elif commands[command][2] != saved_message.channel.name:
- continue
- else:
- can_execute_cmd = True
- break
- if can_execute_cmd:
- query = None
- if commands[command][4] != "":
- query = (saved_possible_cmd.split(commands[command][4],1)).pop() # get query
- queries = get_queries(query,commands[command][3],commands[command][5]) # get what type of queries
- print command
- commands[command][0](queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames)
- if author == "luckytyphlosion":
- luckymsgs.append(saved_message) # do this later so !luckypls doesn't overwrite itself
- client.run()
Add Comment
Please, Sign In to add comment