Add meme blame command #15
@ -16,6 +16,7 @@ Features
|
|||||||
- [X] Get a random meme
|
- [X] Get a random meme
|
||||||
- [X] Get a set of memes
|
- [X] Get a set of memes
|
||||||
- [X] Upload memes to bucket
|
- [X] Upload memes to bucket
|
||||||
|
- [X] Find the uploader of a meme
|
||||||
- [ ] Check status of Plex instance
|
- [ ] Check status of Plex instance
|
||||||
|
|
||||||
Enviroment vars
|
Enviroment vars
|
||||||
|
24
src/memes.py
24
src/memes.py
@ -185,7 +185,7 @@ def getMemeUploader(file_name):
|
|||||||
uploader = tags.get("uploader")
|
uploader = tags.get("uploader")
|
||||||
if uploader != None:
|
if uploader != None:
|
||||||
return uploader
|
return uploader
|
||||||
return "Unkown"
|
return "No-one (probably tyler)"
|
||||||
|
|
||||||
# gets a random meme
|
# gets a random meme
|
||||||
# this will ensure that the meme is not in the last_memes list
|
# this will ensure that the meme is not in the last_memes list
|
||||||
@ -347,5 +347,27 @@ async def uploadMeme(command, message, discordClient):
|
|||||||
|
|
||||||
return "Thanks got your memes!"
|
return "Thanks got your memes!"
|
||||||
|
|
||||||
|
async def memeBlame(command, message, discordClient):
|
||||||
|
query_string = ""
|
||||||
|
if len(command) <= 1:
|
||||||
|
if message.reference is not None: # this is a reply blame
|
||||||
|
m = await message.channel.fetch_message(message.reference.message_id)
|
||||||
|
if m.attachments is not None and len(m.attachments) > 0:
|
||||||
|
query_string = m.attachments[0].filename
|
||||||
|
else: return "No file attached to replied message!"
|
||||||
|
else: return "I need a file name or query!"
|
||||||
|
else: query_string = ' '.join(command[1:]) #get QUERY_STRING
|
||||||
|
|
||||||
|
return_string = ""
|
||||||
|
|
||||||
|
all_memes = getCurrentMemeList()
|
||||||
|
if query_string in all_memes:
|
||||||
|
author = getMemeUploader(query_string)
|
||||||
|
return_string = author + " uploaded " + query_string
|
||||||
|
else:
|
||||||
|
close_meme, total_close_memes = getCloseMemeToQuery(query_string)
|
||||||
|
author = getMemeUploader(close_meme)
|
||||||
|
return_string = "I think you meant \"" + close_meme + "\", which was "
|
||||||
|
return_string += "uploaded by " + author
|
||||||
|
|
||||||
|
return return_string
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import requests
|
import requests
|
||||||
import os, random, sys
|
import os, random, sys
|
||||||
from memes import parseMeme, memeCount, memeDump, allMemes, uploadMeme
|
from memes import parseMeme, memeCount, memeDump, allMemes, uploadMeme, memeBlame
|
||||||
import discord
|
import discord
|
||||||
|
|
||||||
async def showHelp(very, useless, arguments):
|
async def showHelp(very, useless, arguments):
|
||||||
str = "```Usage:\n"
|
str = "```Usage:\n"
|
||||||
|
str += "!help\n"
|
||||||
|
str += " Print this message\n"
|
||||||
str += "!meme [QUERY]\n"
|
str += "!meme [QUERY]\n"
|
||||||
str += " Get a meme. Query for the exact name or search. Paramater is optional\n"
|
str += " Get a meme. Query for the exact name or search. Paramater is optional\n"
|
||||||
str += "!memecount\n"
|
str += "!memecount\n"
|
||||||
@ -14,12 +16,14 @@ async def showHelp(very, useless, arguments):
|
|||||||
str += " Get COUNT random memes. If COUNT is not provided, we default to 5\n"
|
str += " Get COUNT random memes. If COUNT is not provided, we default to 5\n"
|
||||||
str += "!allmemes QUERY\n"
|
str += "!allmemes QUERY\n"
|
||||||
str += " Get all memes that are like the given query\n"
|
str += " Get all memes that are like the given query\n"
|
||||||
str += "!help\n"
|
|
||||||
str += " Print this message\n"
|
|
||||||
str += "!up [NAME]\n"
|
str += "!up [NAME]\n"
|
||||||
str += " Upload a meme. If NAME is provided it will be named as such.\n"
|
str += " Upload a meme. If NAME is provided it will be named as such.\n"
|
||||||
str += " You need to either attach the meme with the message, or reply to a\n"
|
str += " You need to either attach the meme with the message, or reply to a\n"
|
||||||
str += " message with the meme you want to upload\n"
|
str += " message with the meme you want to upload\n"
|
||||||
|
str += "!blame [NAME/QUERY]\n"
|
||||||
|
str += " Returns who uploaded the meme that matches the name or query\n"
|
||||||
|
str += " You can also reply to a message with a meme attached\n"
|
||||||
|
str += " to find the uploader\n"
|
||||||
str += "```"
|
str += "```"
|
||||||
return str
|
return str
|
||||||
|
|
||||||
@ -31,13 +35,14 @@ calldict = {
|
|||||||
"!memecount" : memeCount,
|
"!memecount" : memeCount,
|
||||||
"!memedump" : memeDump,
|
"!memedump" : memeDump,
|
||||||
"!allmemes" : allMemes,
|
"!allmemes" : allMemes,
|
||||||
"!help" : showHelp,
|
|
||||||
"!up" : uploadMeme,
|
"!up" : uploadMeme,
|
||||||
"!upload" : uploadMeme,
|
"!upload" : uploadMeme,
|
||||||
"!uploadmeme": uploadMeme,
|
"!uploadmeme": uploadMeme,
|
||||||
#"!memeblame" : memeBlame
|
"!memeblame" : memeBlame,
|
||||||
|
"!blame" : memeBlame,
|
||||||
# plex
|
# plex
|
||||||
#"!plexleaderboard" : getTopUsers,
|
#"!plexleaderboard" : getTopUsers,
|
||||||
|
"!help" : showHelp,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user