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
- slots_data = {}
- nodecimal = lambda x: ("%s" % (x))[:-2]
- 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,
- }
- 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 = json.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
- 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', 'KappaRoss42069') # 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)
- """
- 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):
- 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):
- client.send_message(message.channel, "icicles")
- def cmd_yolocoin(queries,saved_message,author,taguser,checkForProfile,userNoProfile):
- client.send_message(message.channel, "Congratulations on the new RIP!")
- def cmd_animation(queries,saved_message,author,taguser,checkForProfile,userNoProfile):
- luckypls = "!luckypls"
- tempstring = " _ _ "
- anim_msg = client.send_message(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):
- scrollmsg = queries[0]
- 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):
- if not disablespam[0]:
- wall = ""
- wallargs = queries[0]
- count = 1
- for char in wallargs:
- if char == " ":
- break
- else:
- count += 1
- size = int(wallargs[:count])
- wallargs = wallargs[count:]
- 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):
- if not disablespam[0]:
- pyramid = ""
- pyramidargs = queries[0]
- count = 1
- for char in pyramidargs:
- if char == " ":
- break
- else:
- count += 1
- size = int(pyramidargs[:count])
- pyramidargs = pyramidargs[count:]
- 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)
- def cmd_funkytext(queries,saved_message,author,taguser,checkForProfile,userNoProfile):
- scrollmsg = queries[0]
- 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):
- disablespam[0] = False
- def cmd_disablespam(queries,saved_message,author,taguser,checkForProfile,userNoProfile):
- disablespam[0] = True
- def cmd_slots(queries,saved_message,author,taguser,checkForProfile,userNoProfile):
- if not checkForProfile():
- add_user(author)
- 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 = taguser() + "%s | %s | %s" % (slots[0],slots[1],slots[2])
- newpoints = slots_calcpoints(debugcount)
- slots_updatepoints(author, newpoints)
- nodecimal_msg = nodecimal(newpoints)
- slotsmsg += " Number of tries: %s. Points won: %s" % (debugcount,nodecimal_msg)
- 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):
- if not checkForProfile:
- userNoProfile()
- else:
- nodecimal_msg = nodecimal(slots_data[author]["slots_points"])
- slots_pointsmsg = taguser() + "Your balance is %s points" % nodecimal_msg
- client.send_message(saved_message.channel, slots_pointsmsg)
- def cmd_slotsrecords(queries,saved_message,author,taguser,checkForProfile,userNoProfile):
- if not checkForProfile():
- userNoProfile()
- else:
- slots_recordmsg = taguser() + "Number of !slots done: %s" % (slots_data[author]["slots_executions"])
- client.send_message(saved_message.channel, slots_recordmsg)
- slots_recordmsg = taguser() + "Number of tries: %s" % (slots_data[author]["slots_tries"])
- client.send_message(saved_message.channel, slots_recordmsg)
- slots_recordmsg = taguser() + "Number of wins: %s" % (slots_data[author]["slots_wins"])
- client.send_message(saved_message.channel, slots_recordmsg)
- def cmd_leaderboards(queries,saved_message,author,taguser,checkForProfile,userNoProfile):
- 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 get_queries(query,query_types,query_seperator):
- if query_types == "Query":
- return [query]
- elif not query_types:
- return [None]
- else:
- return (query.split(query_seperator)).append(query)
- 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:
- - None = absolute command
- -
- """
- commands = {
- "!luckypls":[cmd_luckypls,"Member",None,0,None],
- "!luckyplsperma":[cmd_luckypls,"BotOwner",None,0,None],
- "!luckyplsperma":[cmd_luckypls,"Member",None,0,None],
- "test":[cmd_test,"Member",None,0,""],
- "!yolocoin":[cmd_yolocoin,"Member",bot_channel,0,None],
- "!animation":[cmd_animation,"Member",None,0,None],
- "!scrolltext":[cmd_scrolltext,"Member",None,"Query",None],
- "!wall":[cmd_wall,"Moderators",bot_channel,"Query","-"],
- "!pyramid":[cmd_pyramid,"Moderators",bot_channel,"Query","-"],
- "!funkytext":[cmd_funkytext,"User",None,"Query",None],
- "!enablespam":[cmd_enablespam,"Moderators",None,0,None],
- "!disablespam":[cmd_disablespam,"Moderators",None,0,None],
- "!slots":[cmd_slots,"Member",None,0,None],
- "!records":[cmd_slotsrecords,"Member",bot_channel,0,None],
- "!points":[cmd_points,"Member",bot_channel,0,None],
- "!leaderboards":[cmd_leaderboards,"Member",bot_channel,0,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.")
- if author == "luckytyphlosion" and len(luckymsgs) >= 10:
- temp_message = luckymsgs.pop(0)
- # commandmanager
- delta_cmd = saved_message.content
- new_cmd = False
- saved_delta_cmd = delta_cmd
- for command in commands:
- possible_cmd = ""
- delta_cmd = saved_delta_cmd
- if commands[command][4] == "": # get absolute value
- if command != delta_cmd:
- continue
- else:
- new_cmd = command
- else:
- the_cmd = ""
- if commands[command][4]:
- possible_cmd = delta_cmd + commands[command][4]
- the_cmd = command + commands[command][4]
- else:
- possible_cmd = delta_cmd.strip()
- the_cmd = command.strip()
- if the_cmd.startswith(possible_cmd):
- new_cmd = command
- break
- # found a command
- if new_cmd:
- command = new_cmd
- # check perms
- for role in saved_message.author.roles:
- if author == "luckytyphlosion": # bot owner has access to all commands
- pass
- else:
- if not commands[command][1] in role.names:
- continue
- # check channel perms
- if not commands[command][2]:
- pass
- elif commands[command][2] != saved_message.channel.name:
- continue
- query = (delta_cmd.split(commands[command][4],1)).pop() # get query
- queries = get_queries(query,commands[command][3],commands[command][4]) # get what type of queries
- print command
- commands[command][0](queries,saved_message,author,taguser,checkForProfile,userNoProfile)
- break
- 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