Command prefix is now set globally and set in the config.

dev
pocketjawa 2018-12-17 19:00:32 -05:00
parent 8283500514
commit 9d33574064
2 changed files with 28 additions and 24 deletions

View File

@ -13,6 +13,9 @@ public_channel_id:
#User and Group IDs #User and Group IDs
owner_id: owner_id:
#Command Prefix
command_prefix:
#Reddit Stuff #Reddit Stuff
reddit_client_id: reddit_client_id:
reddit_client_secret: reddit_client_secret:

View File

@ -23,6 +23,7 @@ token = config.get("configuration", "token")
bot_channel_id = discord.Object(id=config.get("configuration", "bot_channel_id")) bot_channel_id = discord.Object(id=config.get("configuration", "bot_channel_id"))
public_channel_id = discord.Object(id=config.get("configuration", "public_channel_id")) public_channel_id = discord.Object(id=config.get("configuration", "public_channel_id"))
owner_id = discord.User(id=config.get("configuration", "owner_id")) owner_id = discord.User(id=config.get("configuration", "owner_id"))
command_prefix = config.get("configuration", "command_prefix")
#Reddit Setup #Reddit Setup
reddit_client_id = config.get("configuration", "reddit_client_id") reddit_client_id = config.get("configuration", "reddit_client_id")
@ -96,11 +97,11 @@ def on_message(message):
return return
#Maki Monday praise command #Maki Monday praise command
if (message.content.lower().startswith('!maki')) or (message.content.lower().startswith('!monday')): if (message.content.lower().startswith(command_prefix + 'maki')) or (message.content.lower().startswith(command_prefix + 'monday')):
yield from client.send_message(message.channel, 'https://maki.jawa.moe/monday.png') yield from client.send_message(message.channel, 'https://maki.jawa.moe/monday.png')
#Posts help info #Posts help info
elif message.content.lower().startswith('!help'): elif message.content.lower().startswith(command_prefix + 'help'):
args = message.content.partition(' ')[2] args = message.content.partition(' ')[2]
command = args.partition(' ')[0] command = args.partition(' ')[0]
if (command is '' ): if (command is '' ):
@ -113,7 +114,7 @@ def on_message(message):
yield from client.send_message(message.channel, 'Either that command does not exist, or it is too simple to deserve extra context <:tohrusmug:292110413129318401>') yield from client.send_message(message.channel, 'Either that command does not exist, or it is too simple to deserve extra context <:tohrusmug:292110413129318401>')
#Sleeps for 5 seconds. Don't know why I still have this tbh #Sleeps for 5 seconds. Don't know why I still have this tbh
elif message.content.lower().startswith('!sleep'): elif message.content.lower().startswith(command_prefix + 'sleep'):
output = "Aren't you tired?\nLet's call it a day\nand get some sleep." output = "Aren't you tired?\nLet's call it a day\nand get some sleep."
sleepemb = discord.Embed(description=output) sleepemb = discord.Embed(description=output)
sleepemb.set_author(name="Morgana") sleepemb.set_author(name="Morgana")
@ -123,21 +124,21 @@ def on_message(message):
yield from client.send_message(message.channel, 'Ok, done sleeping') yield from client.send_message(message.channel, 'Ok, done sleeping')
#Posts link to my mix archive #Posts link to my mix archive
elif message.content.lower().startswith('!mixes'): elif message.content.lower().startswith(command_prefix + 'mixes'):
yield from client.send_message(message.channel, 'You can download mp3s of any of my mixes at https://maki.jawa.moe/mixes/') yield from client.send_message(message.channel, 'You can download mp3s of any of my mixes at https://maki.jawa.moe/mixes/')
#Pokes the person who said the command #Pokes the person who said the command
elif message.content.lower().startswith('!pokeme'): elif message.content.lower().startswith(command_prefix + 'pokeme'):
yield from client.send_message(message.channel, "_pokes <@"+message.author.id+">_") yield from client.send_message(message.channel, "_pokes <@"+message.author.id+">_")
#Dump the navy seal copypasta #Dump the navy seal copypasta
elif message.content.lower().startswith('!wtf'): elif message.content.lower().startswith(command_prefix + 'wtf'):
yield from client.send_typing(message.channel) yield from client.send_typing(message.channel)
yield from asyncio.sleep(3) yield from asyncio.sleep(3)
yield from client.send_message(message.channel, 'What the fuck did you just fucking say about me, you little bitch? Ill have you know I graduated top of my class in the Navy Seals, and Ive been involved in numerous secret raids on Al-Quaeda, and I have over 300 confirmed kills. I am trained in gorilla warfare and Im the top sniper in the entire US armed forces. You are nothing to me but just another target. I will wipe you the fuck out with precision the likes of which has never been seen before on this Earth, mark my fucking words. You think you can get away with saying that shit to me over the Internet? Think again, fucker. As we speak I am contacting my secret network of spies across the USA and your IP is being traced right now so you better prepare for the storm, maggot. The storm that wipes out the pathetic little thing you call your life. Youre fucking dead, kid. I can be anywhere, anytime, and I can kill you in over seven hundred ways, and thats just with my bare hands. Not only am I extensively trained in unarmed combat, but I have access to the entire arsenal of the United States Marine Corps and I will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit. If only you could have known what unholy retribution your little “clever” comment was about to bring down upon you, maybe you would have held your fucking tongue. But you couldnt, you didnt, and now youre paying the price, you goddamn idiot. I will shit fury all over you and you will drown in it. Youre fucking dead, kiddo.') yield from client.send_message(message.channel, 'What the fuck did you just fucking say about me, you little bitch? Ill have you know I graduated top of my class in the Navy Seals, and Ive been involved in numerous secret raids on Al-Quaeda, and I have over 300 confirmed kills. I am trained in gorilla warfare and Im the top sniper in the entire US armed forces. You are nothing to me but just another target. I will wipe you the fuck out with precision the likes of which has never been seen before on this Earth, mark my fucking words. You think you can get away with saying that shit to me over the Internet? Think again, fucker. As we speak I am contacting my secret network of spies across the USA and your IP is being traced right now so you better prepare for the storm, maggot. The storm that wipes out the pathetic little thing you call your life. Youre fucking dead, kid. I can be anywhere, anytime, and I can kill you in over seven hundred ways, and thats just with my bare hands. Not only am I extensively trained in unarmed combat, but I have access to the entire arsenal of the United States Marine Corps and I will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit. If only you could have known what unholy retribution your little “clever” comment was about to bring down upon you, maybe you would have held your fucking tongue. But you couldnt, you didnt, and now youre paying the price, you goddamn idiot. I will shit fury all over you and you will drown in it. Youre fucking dead, kiddo.')
#Countdown until the Switch comes out! #Countdown until the Switch comes out!
elif message.content.lower().startswith('!switch'): elif message.content.lower().startswith(command_prefix + 'switch'):
now = datetime.datetime.now() now = datetime.datetime.now()
switchdate = datetime.datetime(2017, 3, 3) switchdate = datetime.datetime(2017, 3, 3)
switchdelta = switchdate - now switchdelta = switchdate - now
@ -148,7 +149,7 @@ def on_message(message):
yield from client.send_message(message.channel, switchmsg) yield from client.send_message(message.channel, switchmsg)
#Countdown until Smash comes out! #Countdown until Smash comes out!
elif message.content.lower().startswith('!smash'): elif message.content.lower().startswith(command_prefix + 'smash'):
now = datetime.datetime.now() now = datetime.datetime.now()
smashdate = datetime.datetime(2018, 12, 7) smashdate = datetime.datetime(2018, 12, 7)
smashdelta = smashdate - now smashdelta = smashdate - now
@ -159,18 +160,18 @@ def on_message(message):
yield from client.send_message(message.channel, smashmsg) yield from client.send_message(message.channel, smashmsg)
#Posts status of the UPS #Posts status of the UPS
elif message.content.lower().startswith('!ups'): elif message.content.lower().startswith(command_prefix + 'ups'):
ups_status = open("/tmp/ups_status.txt","r") ups_status = open("/tmp/ups_status.txt","r")
yield from client.send_message(message.channel, ups_status.read()) yield from client.send_message(message.channel, ups_status.read())
#Posts random picture of Tohru #Posts random picture of Tohru
elif message.content.lower().startswith('!tohru'): elif message.content.lower().startswith(command_prefix + 'tohru'):
tohru_list_file = open(cwd + "/lists/tohru_images.txt", "r") tohru_list_file = open(cwd + "/lists/tohru_images.txt", "r")
tohru_pics = tohru_list_file.read().split() tohru_pics = tohru_list_file.read().split()
yield from client.send_message(message.channel, random.choice(tohru_pics)) yield from client.send_message(message.channel, random.choice(tohru_pics))
#Sets the bot's Now Playing status #Sets the bot's Now Playing status
elif message.content.lower().startswith('!setplaying'): elif message.content.lower().startswith(command_prefix + 'setplaying'):
args = message.content.partition(' ')[2] args = message.content.partition(' ')[2]
yield from client.change_presence(game=discord.Game(name=args)) yield from client.change_presence(game=discord.Game(name=args))
conf_file = open(cwd + "/tmp/status.txt", "w") conf_file = open(cwd + "/tmp/status.txt", "w")
@ -178,13 +179,13 @@ def on_message(message):
conf_file.close() conf_file.close()
#Reset bot's Now Playing status #Reset bot's Now Playing status
elif message.content.lower().startswith('!resetplaying'): elif message.content.lower().startswith(command_prefix + 'resetplaying'):
if os.path.isfile(cwd + "/tmp/status.txt"): if os.path.isfile(cwd + "/tmp/status.txt"):
os.remove(cwd + "/tmp/status.txt") os.remove(cwd + "/tmp/status.txt")
yield from client.change_presence(game=discord.Game(name='with some droids')) yield from client.change_presence(game=discord.Game(name='with some droids'))
#xkcd comic fetcher #xkcd comic fetcher
elif message.content.lower().startswith('!xkcd'): elif message.content.lower().startswith(command_prefix + 'xkcd'):
args = message.content.partition(' ')[2] args = message.content.partition(' ')[2]
if (args is ''): if (args is ''):
comic = xkcd.getRandomComic() comic = xkcd.getRandomComic()
@ -209,13 +210,13 @@ def on_message(message):
yield from client.send_message(message.channel, '`'+args+'`' + 'is not a valid option. Please leave blank for a random comic, say "latest" for the latest comic or put the number of the comic you want.' ) yield from client.send_message(message.channel, '`'+args+'`' + 'is not a valid option. Please leave blank for a random comic, say "latest" for the latest comic or put the number of the comic you want.' )
#Post random submisison from /r/EarthPorn's top this week #Post random submisison from /r/EarthPorn's top this week
elif (message.content.lower().startswith('!earth')) or (message.content.lower().startswith('!earthporn')): elif (message.content.lower().startswith(command_prefix + 'earth')) or (message.content.lower().startswith(command_prefix + 'earthporn')):
earthporn = reddit.subreddit('earthporn').top('week') earthporn = reddit.subreddit('earthporn').top('week')
earthpornr = list(earthporn) earthpornr = list(earthporn)
yield from client.send_message(message.channel, random.choice(earthpornr).url) yield from client.send_message(message.channel, random.choice(earthpornr).url)
#Link some porn! (actually SFW) #Link some porn! (actually SFW)
elif message.content.lower().startswith('!porn') or message.content.lower().startswith('!pron'): elif message.content.lower().startswith(command_prefix + 'porn') or message.content.lower().startswith(command_prefix + 'pron'):
earthporn = reddit.subreddit('earthporn').hot(limit=10) earthporn = reddit.subreddit('earthporn').hot(limit=10)
serverporn = reddit.subreddit('ServerPorn').hot(limit=10) serverporn = reddit.subreddit('ServerPorn').hot(limit=10)
cableporn = reddit.subreddit('cableporn').hot(limit=10) cableporn = reddit.subreddit('cableporn').hot(limit=10)
@ -225,7 +226,7 @@ def on_message(message):
yield from client.send_message(message.channel, random.choice(porn_multi_r).url) yield from client.send_message(message.channel, random.choice(porn_multi_r).url)
#Kill the bot so it can be reloaded #Kill the bot so it can be reloaded
elif (message.content.lower().startswith('!kill')) or (message.content.lower().startswith('!restart')): elif (message.content.lower().startswith(command_prefix + 'kill')) or (message.content.lower().startswith(command_prefix + 'restart')):
author_id = message.author author_id = message.author
if author_id == owner_id: if author_id == owner_id:
yield from client.send_message(message.channel, 'Goodbye Onii-chan!!!') yield from client.send_message(message.channel, 'Goodbye Onii-chan!!!')
@ -234,14 +235,14 @@ def on_message(message):
yield from client.send_message(message.channel, 'Booooo you\'re not Onii-chan. You\'re not allowed to use this command!') yield from client.send_message(message.channel, 'Booooo you\'re not Onii-chan. You\'re not allowed to use this command!')
#Random jokes from /r/jokes #Random jokes from /r/jokes
elif message.content.lower().startswith('!joke'): elif message.content.lower().startswith(command_prefix + 'joke'):
jokes = reddit.subreddit('jokes').top('month') jokes = reddit.subreddit('jokes').top('month')
jokesr = random.choice(list(jokes)) jokesr = random.choice(list(jokes))
jokemsg = jokesr.title + '\n\n' + jokesr.selftext jokemsg = jokesr.title + '\n\n' + jokesr.selftext
yield from client.send_message(message.channel, jokemsg) yield from client.send_message(message.channel, jokemsg)
#Magic 8-ball simulator 2017 #Magic 8-ball simulator 2017
elif message.content.lower().startswith('!8ball'): elif message.content.lower().startswith(command_prefix + '8ball'):
ball_response_file = open(cwd + "/lists/8ball_responses.txt", "r") ball_response_file = open(cwd + "/lists/8ball_responses.txt", "r")
ball_responses = ball_response_file.read().split('\n') ball_responses = ball_response_file.read().split('\n')
args = message.content.partition(' ')[2] args = message.content.partition(' ')[2]
@ -251,7 +252,7 @@ def on_message(message):
yield from client.send_message(message.channel, 'The Magic 8-ball says... ' + random.choice(ball_responses)) yield from client.send_message(message.channel, 'The Magic 8-ball says... ' + random.choice(ball_responses))
#Magic Conch Shell simulator 2002 (way cooler than that lame "Magic" 8-ball) #Magic Conch Shell simulator 2002 (way cooler than that lame "Magic" 8-ball)
elif message.content.lower().startswith('!conch') or message.content.lower().startswith('!magicconch'): elif message.content.lower().startswith(command_prefix + 'conch') or message.content.lower().startswith(command_prefix + 'magicconch'):
ball_response_file = open(cwd + "/lists/8ball_responses.txt", "r") ball_response_file = open(cwd + "/lists/8ball_responses.txt", "r")
ball_responses = ball_response_file.read().split('\n') ball_responses = ball_response_file.read().split('\n')
args = message.content.partition(' ')[2] args = message.content.partition(' ')[2]
@ -261,7 +262,7 @@ def on_message(message):
yield from client.send_message(message.channel, 'The Magic Conch Shell says... ' + random.choice(ball_responses)) yield from client.send_message(message.channel, 'The Magic Conch Shell says... ' + random.choice(ball_responses))
#Create a message that will send the person who reacts correctly the contents of message. Use in either DMs or a channel the public cannot see. #Create a message that will send the person who reacts correctly the contents of message. Use in either DMs or a channel the public cannot see.
elif message.content.lower().startswith('!giveaway'): elif message.content.lower().startswith(command_prefix + 'giveaway'):
#Split off the text to send to the winner #Split off the text to send to the winner
args = message.content.partition(' ')[2] args = message.content.partition(' ')[2]
@ -283,7 +284,7 @@ def on_message(message):
yield from client.send_message(public_channel_id, 'Congrats to {0.user}!'.format(res)) yield from client.send_message(public_channel_id, 'Congrats to {0.user}!'.format(res))
yield from client.send_message(res.user, args) yield from client.send_message(res.user, args)
#Get currently playing stats from toukufm.com #Get currently playing stats from toukufm.com
elif message.content.lower().startswith('!np'): elif message.content.lower().startswith(command_prefix + 'np'):
#Load JSON from stream APIs #Load JSON from stream APIs
nprequest = requests.get(metadataurl) nprequest = requests.get(metadataurl)
@ -316,12 +317,12 @@ def on_message(message):
yield from client.send_message(message.channel, embed=npem) yield from client.send_message(message.channel, embed=npem)
#Post a random mix #Post a random mix
elif message.content.lower().startswith('!rmix'): elif message.content.lower().startswith(command_prefix + 'rmix'):
mixes = json.loads(requests.get("https://maki.jawa.moe/mixesjson/").text) mixes = json.loads(requests.get("https://maki.jawa.moe/mixesjson/").text)
yield from client.send_message(message.channel, "https://maki.jawa.moe/mixes/" + random.choice(mixes)['name']) yield from client.send_message(message.channel, "https://maki.jawa.moe/mixes/" + random.choice(mixes)['name'])
#Dice Roller (support rolling multiple dice at once) #Dice Roller (support rolling multiple dice at once)
elif message.content.lower().startswith('!roll'): elif message.content.lower().startswith(command_prefix + 'roll'):
#Set starting Variables #Set starting Variables
args = message.content.partition(' ')[2].upper() args = message.content.partition(' ')[2].upper()
argsplit = args.split() argsplit = args.split()
@ -367,7 +368,7 @@ def on_message(message):
yield from client.send_message(message.channel, output) yield from client.send_message(message.channel, output)
#Skip tracks/mixes on JawaFM #Skip tracks/mixes on JawaFM
elif message.content.lower().startswith('!fmskip'): elif message.content.lower().startswith(command_prefix + 'fmskip'):
args = message.content.partition(' ')[2] args = message.content.partition(' ')[2]
station = args.partition(' ')[0] station = args.partition(' ')[0]
if (station is ''): if (station is ''):