Add meme blame command #15

Merged
tyler merged 4 commits from meme-blame into main 2022-12-24 19:48:43 +00:00
2 changed files with 23 additions and 4 deletions
Showing only changes of commit eaa981f60d - Show all commits

View File

@ -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,23 @@ async def uploadMeme(command, message, discordClient):
return "Thanks got your memes!" return "Thanks got your memes!"
async def memeBlame(command, message, discordClient):
if len(command) <= 1:
return "I need a file name or query!"
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

View File

@ -1,7 +1,7 @@
#!/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):
@ -31,13 +31,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,
} }