Merge pull request 'Add meme blame command' (#15) from meme-blame into main
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Reviewed-on: #15
This commit is contained in:
commit
3c7cb1c4a5
@ -16,6 +16,7 @@ Features
|
||||
- [X] Get a random meme
|
||||
- [X] Get a set of memes
|
||||
- [X] Upload memes to bucket
|
||||
- [X] Find the uploader of a meme
|
||||
- [ ] Check status of Plex instance
|
||||
|
||||
Enviroment vars
|
||||
|
24
src/memes.py
24
src/memes.py
@ -185,7 +185,7 @@ def getMemeUploader(file_name):
|
||||
uploader = tags.get("uploader")
|
||||
if uploader != None:
|
||||
return uploader
|
||||
return "Unkown"
|
||||
return "No-one (probably tyler)"
|
||||
|
||||
# gets a random meme
|
||||
# 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!"
|
||||
|
||||
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
|
||||
import requests
|
||||
import os, random, sys
|
||||
from memes import parseMeme, memeCount, memeDump, allMemes, uploadMeme
|
||||
from memes import parseMeme, memeCount, memeDump, allMemes, uploadMeme, memeBlame
|
||||
import discord
|
||||
|
||||
async def showHelp(very, useless, arguments):
|
||||
str = "```Usage:\n"
|
||||
str += "!help\n"
|
||||
str += " Print this message\n"
|
||||
str += "!meme [QUERY]\n"
|
||||
str += " Get a meme. Query for the exact name or search. Paramater is optional\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 += "!allmemes 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 += " 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 += " 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 += "```"
|
||||
return str
|
||||
|
||||
@ -31,13 +35,14 @@ calldict = {
|
||||
"!memecount" : memeCount,
|
||||
"!memedump" : memeDump,
|
||||
"!allmemes" : allMemes,
|
||||
"!help" : showHelp,
|
||||
"!up" : uploadMeme,
|
||||
"!upload" : uploadMeme,
|
||||
"!uploadmeme": uploadMeme,
|
||||
#"!memeblame" : memeBlame
|
||||
"!memeblame" : memeBlame,
|
||||
"!blame" : memeBlame,
|
||||
# plex
|
||||
#"!plexleaderboard" : getTopUsers,
|
||||
"!help" : showHelp,
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user