SHARE
TWEET

luckybot code v2

luckytyphlosion Nov 11th, 2015 (edited) 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time
  2. import discord
  3. import logging
  4. import random
  5. import json
  6. import math
  7. from yaml import safe_load
  8. from dis import dis
  9.  
  10. slots_data = {}
  11. autorepeat_cooldown = [time.time()]
  12. nodecimal = lambda x: ("%s" % (x))[:-2]
  13. dabomstew_pls = [False]
  14. dabomstew_cooldown_times = [182.767000198,182.77699995,182.802000046,182.616000175]
  15.  
  16. def slots_calcpoints(level):
  17.         if level >= 12.1:
  18.                 level = 42069 ** (1/math.log10(level))
  19.         elif level == 1:
  20.                 level = 42069
  21.         else:
  22.                 temp_value = int(math.sqrt(-69420 * (level-69)))
  23.                 level = 6.9 * temp_value
  24.                
  25.         level = round(level)
  26.         return level
  27.        
  28. def add_user(username):
  29.         slots_data[username] = {
  30.         "slots_cooldown": time.time(),
  31.         "slots_wins": 0,
  32.         "slots_tries": 0,
  33.         "slots_executions": 0,
  34.         "slots_points": 0,
  35.         "slots_unluckiest": 0,
  36.         "slots_coincooldown": time.time(),
  37.         }
  38.  
  39. def save_slots():
  40.         temp_data = slots_data
  41.        
  42.         with open('slots_data.json', 'w') as fp:
  43.                 json.dump(temp_data, fp, sort_keys = True)
  44.        
  45. def load_slots():
  46.         with open('slots_data.json', 'r') as fp:
  47.                 slots_data = safe_load(fp)
  48.         return slots_data
  49.                
  50. def slots_updatetime(username):
  51.         slots_data[username]["slots_cooldown"] = time.time()
  52.        
  53. def slots_updatewins(username):
  54.         slots_data[username]["slots_wins"] += 1
  55.  
  56. def slots_updatetries(username,tries):
  57.         slots_data[username]["slots_tries"] += tries
  58.        
  59. def slots_updateexecutions(username):
  60.         slots_data[username]["slots_executions"] += 1
  61.        
  62. def slots_updatepoints(username,amount):
  63.         slots_data[username]["slots_points"] += amount
  64.  
  65. def slots_updateworst(username,tries):
  66.         slots_data[username]["slots_worst"] = tries
  67.        
  68. def slots_updatecointime(username):
  69.         slots_data[username]["slots_coincooldown"] = time.time()
  70.  
  71. luckymsgs = []
  72. animationmsgs = []
  73. disablespam = [True]
  74.  
  75. """
  76. FORMAT: Username, Cooldown, number of first try wins, total tries, total command executions, performance
  77. """
  78.  
  79. # Set up the logging module to output diagnostic to the console.
  80. logging.basicConfig()
  81.  
  82. client = discord.Client()
  83. client.login('yellow151@memebig.net', 'kappa42069') # username/password
  84.  
  85. if not client.is_logged_in:
  86.         print('Logging in to Discord failed')
  87.         exit(1)
  88.  
  89. @client.event
  90. def on_ready():
  91.         print('Connected!')
  92.         print('Username: ' + client.user.name)
  93.         print('ID: ' + client.user.id)
  94.         print('------')
  95.         global slots_data
  96.         slots_data = load_slots()
  97.         print(slots_data)
  98.                        
  99.         save_slots()
  100.        
  101.         for server in client.servers:
  102.                 print(server.name)
  103.                 if server.name == "PokemonSpeedruns":
  104.                         for channel in server.channels:
  105.                                 print(channel.name)
  106.                                 if channel.name == bot_channel:
  107.                                         client.send_message(channel, "jp Start")
  108.                        
  109.         """
  110.         for server in client.servers:
  111.                 print(server.name)
  112.                 if server.name != "PokemonSpeedruns":
  113.                         continue
  114.                 for channel in server.channels:
  115.                         print(channel.name)
  116.                         if channel.name != bot_channel:
  117.                                 continue
  118.                         for role in server.roles:
  119.                                 client.send_message(channel,role.name)
  120.         """
  121. permissions = ["botowner","admin","moderator","user"]
  122.  
  123. def cmd_luckypls(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  124.         if len(luckymsgs) >= 1:
  125.                 if saved_message.content == "!luckyplsperma" and author != "luckytyphlosion":
  126.                         Kappa = ""
  127.                         for count in range(3):
  128.                                 Kappa += "Kappa "
  129.                                 client.send_message(saved_message.channel, Kappa)
  130.                         for count in range(2):
  131.                                 Kappa = Kappa[:-6]
  132.                                 client.send_message(saved_message.channel, Kappa)
  133.                 else:
  134.                         for message in luckymsgs:
  135.                                 if message.channel != saved_message.channel:
  136.                                         continue
  137.                                 else:
  138.                                         client.edit_message(message, "<message deleted>")
  139.                        
  140.                         if saved_message.content == "!luckyplsperma" and author == "luckytyphlosion":
  141.                                 pass
  142.                         else:
  143.                                 time.sleep(6.9)
  144.                                 for message in luckymsgs:
  145.                                         if message.channel != saved_message.channel:
  146.                                                 continue
  147.                                         else:
  148.                                                 client.edit_message(message, message.content)
  149.        
  150. def cmd_test(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  151.         client.send_message(saved_message.channel, "icicles")
  152.        
  153. def cmd_yolocoin(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  154.         if not checkForProfile:
  155.                 userNoProfile()
  156.  
  157.         elif saved_message.channel.name == bot_channel and (time.time() - (slots_data[author]["slots_coincooldown"]) >= 180):
  158.                 saved_points = slots_data[author]["slots_points"]
  159.                 if random.randint(0, 1) == 1:
  160.                         slots_updatepoints(author, saved_points)
  161.                         client.send_message(saved_message.channel, "Heads. +%s points." % nodecimal(saved_points))
  162.                 else:
  163.                         slots_updatepoints(author, -saved_points)
  164.                         client.send_message(saved_message.channel, "Tails. -%s points." % nodecimal(saved_points))
  165.                         client.send_message(saved_message.channel, "Congratulations on the new RIP!")
  166.                
  167.                 save_slots()
  168.                 slots_updatecointime(author)
  169.         elif saved_message.channel.name == bot_channel:
  170.                 client.send_message(saved_message.channel,taguser() + "On cooldown. (%d secs)" % (180 - (time.time() - slots_data[author]["slots_coincooldown"])))
  171.                
  172. def cmd_coin(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  173.         saved_points = int(queries["1"])
  174.         if not checkForProfile:
  175.                 userNoProfile()
  176.        
  177.         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"]:
  178.                 coinflip = random.randint(0, 1)
  179.                 if coinflip == 1:
  180.                         slots_updatepoints(author, saved_points)
  181.                         sign = "+"
  182.                         if saved_points < 0:
  183.                                 sign = "-"
  184.                         client.send_message(saved_message.channel, "Heads. " + sign + "%s points." % abs(saved_points))
  185.                 else:
  186.                         sign = "-"
  187.                         slots_updatepoints(author, -saved_points)
  188.                         if saved_points < 0:
  189.                                 sign = "+"
  190.                         client.send_message(saved_message.channel, "Tails. " + sign + "%s points." % abs(saved_points))
  191.                
  192.                 slots_updatecointime(author)
  193.                 save_slots()
  194.         elif saved_message.channel.name == bot_channel:
  195.                 client.send_message(saved_message.channel,taguser() + "On cooldown. (%d secs)" % (180 - (time.time() - slots_data[author]["slots_coincooldown"])))
  196.  
  197. def cmd_animation(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  198.         luckypls = "!luckypls"
  199.         tempstring = " _ _ "
  200.         anim_msg = client.send_message(saved_message.channel, luckypls)
  201.         for count in range(10):
  202.                 luckypls = tempstring + luckypls + tempstring
  203.                 anim_msg = client.edit_message(anim_msg, luckypls)
  204.                
  205.         for count in range(10):
  206.                 luckypls = luckypls[5:-5]
  207.                 anim_msg = client.edit_message(anim_msg, luckypls)
  208.        
  209. def cmd_scrolltext(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  210.         scrollmsg = queries["Query"]
  211.         sentmsg = client.send_message(saved_message.channel, "_ _")
  212.         deltamsg = ""
  213.         for char in scrollmsg:
  214.                 deltamsg += char
  215.                 anim_msg = client.edit_message(sentmsg, deltamsg)
  216.  
  217. def cmd_wall(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  218.         print queries
  219.         if not disablespam[0]:
  220.                 wall = ""
  221.                 size = int(queries["1"])
  222.                 wallargs = queries["2-"]
  223.                
  224.                 if wallargs:
  225.                         for count in range(size):
  226.                                 client.send_message(saved_message.channel, wallargs)
  227.                 else:
  228.                         client.send_message(saved_message.channel, "No sending null messages!")
  229.        
  230. def cmd_pyramid(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  231.         if not disablespam[0]:
  232.                 pyramid = ""
  233.                 size = int(queries["1"])
  234.                 pyramidargs = queries["2-"]
  235.                
  236.                 if pyramidargs:
  237.                         for count in range(size):
  238.                                 pyramid += pyramidargs + " "
  239.                                 client.send_message(saved_message.channel, pyramid)
  240.                         for count in range(size-1):
  241.                                 pyramid = pyramid[:-(len(pyramidargs)+1)]
  242.                                 client.send_message(saved_message.channel, pyramid)
  243.                 else:
  244.                         client.send_message(saved_message.channel, "No sending null messages!")
  245.        
  246. def cmd_funkytext(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  247.         scrollmsg = queries["Query"]
  248.         tempstring = " "
  249.         deltamsg = "_ _"
  250.         somemsg = client.send_message(saved_message.channel,"_ _")
  251.         for count in range(5):
  252.                 some_count = 0
  253.                 for char in scrollmsg:
  254.                         deltamsg = tempstring * some_count + char + tempstring * (len(scrollmsg) - some_count)
  255.                         client.edit_message(somemsg, deltamsg)
  256.                         some_count += 1
  257.                        
  258.         client.edit_message(somemsg, scrollmsg)
  259.        
  260. def cmd_enablespam(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  261.         disablespam[0] = False
  262.        
  263. def cmd_disablespam(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  264.         disablespam[0] = True
  265.        
  266. def cmd_slots(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  267.         if not checkForProfile():
  268.                 add_user(author)
  269.                        
  270.         slots_cooldown = time.time() - (slots_data[author]["slots_cooldown"])
  271.         if author == "Dabomstew":
  272.                 dabomstew_cooldown_times.append(slots_cooldown)
  273.                 print "Dabomstew's Cooldown: %s" % slots_cooldown
  274.                 if len(dabomstew_cooldown_times) >= 7 and (max(dabomstew_cooldown_times) - min(dabomstew_cooldown_times) < 5):
  275.                         dabomstew_pls[0] = True
  276.                                
  277.         if saved_message.channel.name == bot_channel and ((time.time() - (slots_data[author]["slots_cooldown"]) >= 180) or (slots_data[author]["slots_executions"] == 0)):
  278.                
  279.                 debugcount = 1
  280.                 while True:
  281.                         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)
  282.                
  283.                         slots = []
  284.                                
  285.                         for count in range(3):
  286.                                 slots.append(random.choice(sampled_emotes))
  287.                                
  288.                         if slots[0] == slots[1] and slots[1] == slots[2]:
  289.                                 slotsmsg = ""
  290.                                
  291.                                 slotsmsg += taguser() + "%s | %s | %s" % (slots[0],slots[1],slots[2])
  292.                                
  293.                                 newpoints = slots_calcpoints(debugcount)
  294.                                 if (dabomstew_pls[0] and author == "Dabomstew") or saved_message.content == "!slots_dabomstewisadirtycheater":
  295.                                         newpoints = newpoints * -1
  296.                                
  297.                                 slots_updatepoints(author, newpoints)
  298.                                
  299.                                 nodecimal_msg = nodecimal(newpoints)
  300.                                
  301.                                 slotsmsg += " Number of tries: %s. Points won: %s" % (debugcount,nodecimal_msg)
  302.                                
  303.                                 if slots_data[author]["slots_worst"] < debugcount:
  304.                                         slots_updateworst(author,debugcount)
  305.                                
  306.                                 if (dabomstew_pls[0] and author == "Dabomstew") or saved_message.content == "!slots_dabomstewisadirtycheater":
  307.                                         for count in range(20):
  308.                                                 client.send_message(saved_message.channel, slotsmsg)
  309.                                 else:
  310.                                         client.send_message(saved_message.channel, slotsmsg)
  311.                                
  312.                                
  313.                                 if debugcount == 1:
  314.                                         slotsmsg_win = tagusernoarrow() + "has won slots"
  315.                                
  316.                                         client.send_message(saved_message.channel, slotsmsg_win)
  317.                                        
  318.                                         slots_updatewins(author)
  319.                                
  320.                                 break
  321.                
  322.                         else:
  323.                                 debugcount += 1
  324.                
  325.                 slots_updatetime(author)
  326.                 slots_updatetries(author,debugcount)
  327.                 slots_updateexecutions(author)
  328.                 save_slots()
  329.         elif saved_message.channel.name == bot_channel:
  330.                 client.send_message(saved_message.channel,taguser() + "On cooldown. (%d secs)" % (180 - (time.time() - slots_data[author]["slots_cooldown"])))
  331.  
  332. def cmd_points(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  333.  
  334.         pointsuser = author
  335.         if queries["1"].lower() in correctcase_usernames:
  336.                 pointsuser = correctcase_usernames[queries["1"].lower()]
  337.                
  338.         if not checkForProfile and recordsuser == author:
  339.                 userNoProfile()
  340.         else:
  341.                 slots_pointsmsg = taguser()
  342.                 nodecimal_msg = nodecimal(slots_data[pointsuser]["slots_points"])
  343.                 if pointsuser == author:
  344.                         slots_pointsmsg += "Your balance is %s points" % nodecimal_msg
  345.                 else:
  346.                         slots_pointsmsg += "%s's balance is %s points" % (pointsuser,nodecimal_msg)
  347.                
  348.                 client.send_message(saved_message.channel, slots_pointsmsg)
  349.        
  350. def cmd_slotsrecords(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  351.         recordsuser = author
  352.        
  353.         if queries["1"].lower() in correctcase_usernames:
  354.                 recordsuser = correctcase_usernames[queries["1"].lower()]
  355.                
  356.         if not checkForProfile() and recordsuser == author:
  357.                 userNoProfile()
  358.         else:
  359.                 records = [
  360.                         ["Number of !slots done","slots_executions"],
  361.                         ["Number of tries","slots_tries"],
  362.                         ["Number of wins","slots_wins"],
  363.                         ["Worst roll","slots_worst"],
  364.                 ]
  365.                
  366.                 slots_recordmsg = taguser()
  367.                
  368.                 if recordsuser == author:
  369.                         slots_recordmsg += "Your stats are:\r\n"
  370.                 else:
  371.                         slots_recordmsg += "%s's stats are:\r\n" % recordsuser
  372.                
  373.                 for record in records:
  374.                         slots_recordmsg += record[0] + ": %s" % (slots_data[recordsuser][record[1]]) + "\r\n"
  375.                
  376.                 client.send_message(saved_message.channel, slots_recordmsg)
  377.        
  378. def cmd_leaderboards(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  379.         temp_boards = [(slots_data[username]["slots_points"], username) for username in slots_data]
  380.         temp_boards.sort(key=lambda l: l[0], reverse=True)
  381.        
  382.         boards_message = taguser() + "\r\n%s" % ('\r\n'.join(l[1] + u': ' + unicode(l[0]) for l in temp_boards[:5]))
  383.  
  384.         client.send_message(saved_message.channel, boards_message)
  385.        
  386. def cmd_anyone(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  387.         client.send_message(saved_message.channel, "Anyone can get a %s in %s with good execution" % (queries["1"],queries["2"]))
  388.  
  389. def cmd_usernoprofile(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  390.         userNoProfile()
  391.  
  392. def cmd_dc(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  393.         if random.randint(0,255) == 69:
  394.                 if saved_message.channel.name == bot_channel:
  395.                         for count in range(0,69):
  396.                                 client.send_message(saved_message.channel, "rst $38")
  397.                         client.send_message(saved_message.channel,"halt while LCD off")
  398.                         exit(1)
  399.                 else:
  400.                         client.send_message(saved_message.channel,"You got the 1/256 chance of missing the power button!")
  401.         else:
  402.                 client.send_message(saved_message.channel,"Stopping!")
  403.                 exit(1)
  404.                
  405. def cmd_rigged(queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames):
  406.         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!")
  407.        
  408. def get_queries(query,query_types,query_separator):
  409.         if query_types[0]:
  410.                 required_queries = {}
  411.                 indiv_queries = query.split(query_separator)
  412.                 print "Individual Queries: %s" % indiv_queries
  413.                 for arg in query_types:
  414.                         if arg > 0:
  415.                                 required_queries["%s" % arg] = indiv_queries[arg-1].strip()
  416.                         else:
  417.                                 arg_name = ""
  418.                                 if arg == -1:
  419.                                         arg_name = "Query"
  420.                                 else:
  421.                                         arg_name = "%s-" % abs(arg)
  422.                                
  423.                                 required_queries[arg_name] = (query.split(query_separator,abs(arg)-1    ).pop()).strip()
  424.                
  425.                 return required_queries
  426.         else:
  427.                 return {"Query":None}
  428.  
  429. bot_channel = "meme-bots"
  430. """
  431. command format:
  432. - command name
  433.         - command function pointer
  434.         - command permissions
  435.         - command channel permissions (None = all channels)
  436.         - command *args
  437.         - command args splitter:
  438.                 - special cases:
  439.                 - "" = absolute command
  440.                 - None = any length of whitespace
  441.         - command splitter
  442. """
  443.  
  444. commands = {
  445.         "!luckypls":[cmd_luckypls,"Member",None,[0],None,None],
  446.         "!luckyplsperma":[cmd_luckypls,"BotOwner",None,[0],None,None],
  447.         "!luckyplsperma":[cmd_luckypls,"Member",None,[0],None,None],
  448.         "test":[cmd_test,"Member",None,[0],"",None],
  449.         "!yolocoin":[cmd_yolocoin,"Member",bot_channel,[0],None,None],
  450.         "!animation":[cmd_animation,"Member",None,[0],None,None],
  451.         "!scrolltext":[cmd_scrolltext,"Member",None,[-1],None,None],
  452.         "!wall":[cmd_wall,"Moderators",None,[1,-2],"-",None],
  453.         "!pyramid":[cmd_pyramid,"Moderators",None,[1,-2],"-",None],
  454.         "!funkytext":[cmd_funkytext,"User",None,[-1],None,None],
  455.         "!enablespam":[cmd_enablespam,"Moderators",None,[0],None,None],
  456.         "!disablespam":[cmd_disablespam,"Moderators",None,[0],None,None],
  457.         "!slots":[cmd_slots,"Member",bot_channel,[0],None,None],
  458.         "!records":[cmd_slotsrecords,"Member",bot_channel,[1],None,None],
  459.         "!points":[cmd_points,"Member",bot_channel,[1],None,None],
  460.         "!leaderboards":[cmd_leaderboards,"Member",bot_channel,[0],None,None],
  461.         "!anyone":[cmd_anyone,"Member",None,[1,2],None,"\\"],
  462.         "luckypls":[cmd_luckypls,"Member",None,[0],None,None],
  463.         "!slots_dabomstewisadirtycheater":[cmd_slots,"Member",None,[0],None,None],
  464.         "!usernoprofile":[cmd_usernoprofile,"BotOwner",None,[0],None,None],
  465.         "!coin":[cmd_coin,"Member",bot_channel,[1],None,None],
  466.         "!dc":[cmd_dc,"BotOwner",None,[0],None,None],
  467.         "luckyplz":[cmd_luckypls,"Member",None,[0],None,None],
  468.         "!rigged":[cmd_rigged,"Member",bot_channel,[0],None,None],
  469. }
  470. @client.event
  471. def on_message(message):
  472.         saved_message = message
  473.        
  474.         author = saved_message.author.name
  475.         taguser = lambda: "<@%s> -> " % (saved_message.author.id)
  476.         tagusernoarrow = lambda: "<@%s> " % (saved_message.author.id)
  477.        
  478.         checkForProfile = lambda: True if author in slots_data else False
  479.        
  480.         userNoProfile = lambda: client.send_message(saved_message.channel, taguser() + "You haven't played slots yet.")
  481.        
  482.         correctcase_usernames = {u.lower(): u for u in slots_data.keys()}
  483.        
  484.         if author == "luckytyphlosion" and len(luckymsgs) >= 10:
  485.                 temp_message = luckymsgs.pop(0)
  486.        
  487.         # commandmanager
  488.         possible_cmd = saved_message.content
  489.         new_cmd = False
  490.         saved_possible_cmd = possible_cmd
  491.        
  492.         for command in commands:
  493.                 possible_cmd = saved_possible_cmd
  494.                
  495.                 if commands[command][4] == "": # get absolute value
  496.                         if command != possible_cmd:
  497.                                 continue
  498.                         else:
  499.                                 new_cmd = command
  500.                                 break
  501.                 else:
  502.                         possible_cmd = (possible_cmd.split(commands[command][4],1))[0]
  503.                         command_ = (command.split(commands[command][4],1))[0]
  504.                        
  505.                         if commands[command][4]:
  506.                                 possible_cmd += commands[command][4]
  507.                                 command_ += commands[command][4]
  508.                         else:
  509.                                 possible_cmd = possible_cmd.strip() + " "
  510.                                 command_ = command.strip() + " "
  511.                        
  512.                         if command_.startswith(possible_cmd):
  513.                                 new_cmd = command
  514.                                 break
  515.                                
  516.         # found a command
  517.         if new_cmd:
  518.                 command = new_cmd
  519.                 # check perms
  520.                 can_execute_cmd = False
  521.                 for role_no in range(len(saved_message.author.roles)):
  522.                         if can_execute_cmd:
  523.                                 break
  524.                                
  525.                         if author == "luckytyphlosion" or command == "!slots": # bot owner has access to all commands
  526.                                 print(saved_message.author.roles[role_no].name + " | " + commands[command][1])
  527.                                 pass
  528.                         else:
  529.                                 if commands[command][1] != saved_message.author.roles[role_no].name:
  530.                                         print(saved_message.author.roles[role_no].name + " | " + commands[command][1])
  531.                                         continue
  532.                        
  533.                         # check channel perms
  534.                         if not commands[command][2]:
  535.                                 can_execute_cmd = True
  536.                                 break
  537.                         elif commands[command][2] != saved_message.channel.name:
  538.                                 continue
  539.                         else:
  540.                                 can_execute_cmd = True
  541.                                 break
  542.                
  543.                 if can_execute_cmd:
  544.                         query = None
  545.                         if commands[command][4] != "":
  546.                                 query = (saved_possible_cmd.split(commands[command][4],1)).pop() # get query
  547.                        
  548.                         queries = get_queries(query,commands[command][3],commands[command][5]) # get what type of queries
  549.                        
  550.                         print command
  551.                         commands[command][0](queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames)
  552.                                
  553.         if author == "luckytyphlosion":
  554.                 luckymsgs.append(saved_message) # do this later so !luckypls doesn't overwrite itself
  555.                
  556.        
  557. client.run()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top