Advertisement
luckytyphlosion

luckybot commandmanager

Nov 24th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.86 KB | None | 0 0
  1. commands = {
  2.     "!luckypls":[cmd_luckypls,"Member",None,[0],None,None],
  3.     "!luckyplsperma":[cmd_luckypls,"BotOwner",None,[0],None,None],
  4.     "test":[cmd_test,"Member",None,[0],"",None],
  5.     "!yolocoin":[cmd_yolocoin,"Member",bot_channel,[0],None,None],
  6.     "!animation":[cmd_animation,"Member",None,[0],None,None],
  7.     "!scrolltext":[cmd_scrolltext,"Member",None,[-1],None,None],
  8.     "!wall":[cmd_wall,"Moderators",None,[1,-2],"-",None],
  9.     "!pyramid":[cmd_pyramid,"Moderators",None,[1,-2],"-",None],
  10.     "!funkytext":[cmd_funkytext,"User",None,[-1],None,None],
  11.     "!enablespam":[cmd_enablespam,"Moderators",None,[0],None,None],
  12.     "!disablespam":[cmd_disablespam,"Moderators",None,[0],None,None],
  13.     "!slots":[cmd_slots,"Member",bot_channel,[0],None,None],
  14.     "!records":[cmd_slotsrecords,"Member",bot_channel,[1],None,None],
  15.     "!points":[cmd_points,"Member",bot_channel,[1],None,None],
  16.     "!leaderboards":[cmd_leaderboards,"Member",bot_channel,[0],None,None],
  17.     "!anyone":[cmd_anyone,"Member",None,[1,2],None,"\\"],
  18.     "!slots_dabomstewisadirtycheater":[cmd_slots,"Member",None,[0],None,None],
  19.     "!usernoprofile":[cmd_usernoprofile,"BotOwner",None,[0],None,None],
  20.     "!coin":[cmd_coin,"Member",bot_channel,[1],None,None],
  21.     "!dc":[cmd_dc,"BotOwner",None,[0],None,None],
  22.     "!exit":[cmd_dc,"BotOwner",None,[0],None,None],
  23.     "!rigged":[cmd_rigged,"Member",bot_channel,[0],None,None],
  24.     "!rngtest":[cmd_rngtest,"Member",bot_channel,[0],None,None],
  25.     "!nolocoin":[cmd_yolocoin,"Member",bot_channel,[0],None,None],
  26.     "!callrandom":[cmd_callrandom,"Member",None,[0],None,None],
  27.     "!dsum":[cmd_dsum,"Member",None,[0],None,None],
  28.     "!trolltext":[cmd_trolltext,"Member",None,[1,-2],None,None],
  29.     "!enablerng":[cmd_enablerng,"Moderator",None,[0],None,None],
  30.     "!disablerng":[cmd_disablerng,"Moderator",None,[0],None,None],
  31.     "!foryoueekcast":[cmd_foryoueekcast,"BotOwner",None,[0],None,None],
  32.     "!y151":[cmd_y151,"Member",None,[0],None,None],
  33.     "!roles":[cmd_roles,"Member",None,[0],None,None],
  34. }
  35. @client.event
  36. def on_message(message):
  37.     saved_message = message
  38.    
  39.     author = saved_message.author.name
  40.     taguser = lambda: "<@%s> -> " % (saved_message.author.id)
  41.     tagusernoarrow = lambda: "<@%s> " % (saved_message.author.id)
  42.    
  43.     checkForProfile = lambda: True if author in slots_data else False
  44.    
  45.     userNoProfile = lambda: client.send_message(saved_message.channel, taguser() + "You haven't played slots yet.")
  46.    
  47.     correctcase_usernames = {u.lower(): u for u in slots_data.keys()}
  48.    
  49.     if author == "luckytyphlosion" and len(luckymsgs) >= 10:
  50.         temp_message = luckymsgs.pop(0)
  51.    
  52.     # commandmanager
  53.     possible_cmd = saved_message.content
  54.     new_cmd = False
  55.     saved_possible_cmd = possible_cmd
  56.    
  57.     rigged_msg = saved_message.content.lower()
  58.     print rigged_msg
  59.     if (("rigged" in rigged_msg) or ("r i g g e d" in rigged_msg)) and saved_message.channel.name == bot_channel and author != "luckytyphlosion":
  60.         client.send_message(saved_message.channel, "if it's rigged then why are you using it Kappa")
  61.    
  62.     for command in commands:
  63.         possible_cmd = saved_possible_cmd
  64.        
  65.         if commands[command][4] == "": # get absolute value
  66.             if command != possible_cmd:
  67.                 continue
  68.             else:
  69.                 new_cmd = command
  70.                 break
  71.         else:
  72.             possible_cmd = (possible_cmd.split(commands[command][4],1))[0]
  73.             command_ = (command.split(commands[command][4],1))[0]
  74.            
  75.             if commands[command][4]:
  76.                 possible_cmd += commands[command][4]
  77.                 command_ += commands[command][4]
  78.             else:
  79.                 possible_cmd = possible_cmd.strip() + " "
  80.                 command_ = command.strip() + " "
  81.            
  82.             if command_.startswith(possible_cmd):
  83.                 new_cmd = command
  84.                 break
  85.                
  86.     # found a command
  87.     if new_cmd:
  88.         command = new_cmd
  89.         # check perms
  90.         can_execute_cmd = False
  91.         for role_no in range(len(saved_message.author.roles)):
  92.             if can_execute_cmd:
  93.                 break
  94.                
  95.             if author == "luckytyphlosion" or command == "!slots": # bot owner has access to all commands
  96.                 print(saved_message.author.roles[role_no].name + " | " + commands[command][1])
  97.                 pass
  98.             else:
  99.                 if commands[command][1] != saved_message.author.roles[role_no].name:
  100.                     print(saved_message.author.roles[role_no].name + " | " + commands[command][1])
  101.                     continue
  102.            
  103.             # check channel perms
  104.             if not commands[command][2]:
  105.                 can_execute_cmd = True
  106.                 break
  107.             elif commands[command][2] != saved_message.channel.name:
  108.                 continue
  109.             else:
  110.                 can_execute_cmd = True
  111.                 break
  112.        
  113.         if can_execute_cmd:
  114.             query = None
  115.             if commands[command][4] != "":
  116.                 query = (saved_possible_cmd.split(commands[command][4],1)).pop() # get query
  117.            
  118.             queries = get_queries(query,commands[command][3],commands[command][5]) # get what type of queries
  119.            
  120.             print "Command: %s" % command
  121.             commands[command][0](queries,saved_message,author,taguser,checkForProfile,userNoProfile,correctcase_usernames)
  122.                
  123.     if author == "luckytyphlosion":
  124.         luckymsgs.append(saved_message) # do this later so !luckypls doesn't overwrite itself
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement