mirror of https://github.com/stijndcl/didier
Use meme class
parent
f2b62c3ce7
commit
77addbc30c
10
cogs/fun.py
10
cogs/fun.py
|
@ -91,7 +91,7 @@ class Fun(commands.Cog):
|
|||
return await ctx.send("Controleer je argumenten.")
|
||||
|
||||
# Get the meme info that corresponds to this name
|
||||
result = memes.getMeme(name)
|
||||
result: memes.Meme = memes.getMeme(name)
|
||||
|
||||
# No meme found
|
||||
if result is None:
|
||||
|
@ -101,15 +101,15 @@ class Fun(commands.Cog):
|
|||
fields = list(fields)
|
||||
|
||||
# If there's only one field, the user isn't required to use quotes
|
||||
if result[2] == 1:
|
||||
if result.fields == 1:
|
||||
fields = [" ".join(fields)]
|
||||
|
||||
# Apply mock to mocking spongebob memes
|
||||
if result[1] == "mocking spongebob":
|
||||
if result.name == "mocking spongebob":
|
||||
fields = list(map(mock.mock, fields))
|
||||
|
||||
# X, X everywhere only takes X as an argument
|
||||
if result[1] == "x, x everywhere":
|
||||
if result.name == "x, x everywhere":
|
||||
fields[0] = " ".join(fields)
|
||||
fields.append(fields[0] + " everywhere")
|
||||
|
||||
|
@ -127,7 +127,7 @@ class Fun(commands.Cog):
|
|||
|
||||
if req["success"]:
|
||||
caption = {
|
||||
"template_id": result[0],
|
||||
"template_id": result.meme_id,
|
||||
"username": os.getenv("IMGFLIPNAME"),
|
||||
"password": os.getenv("IMGFLIPPASSWORD"),
|
||||
"boxes[0][text]": boxes[0]["text"],
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from attr import dataclass
|
||||
|
||||
from functions.database import utils
|
||||
|
||||
|
||||
|
@ -18,9 +20,23 @@ def getMeme(name):
|
|||
cursor = connection.cursor()
|
||||
cursor.execute("SELECT * FROM memes WHERE name like %s", ["%" + name.lower() + "%"])
|
||||
result = cursor.fetchall()
|
||||
|
||||
if len(result) == 0:
|
||||
return None
|
||||
return result[0]
|
||||
|
||||
meme = Meme(result[0][0], result[0][1], result[0][2])
|
||||
|
||||
return meme
|
||||
|
||||
|
||||
@dataclass
|
||||
class Meme:
|
||||
"""
|
||||
Dataclass to represent a meme in order to avoid having to use [] on tuples all the time
|
||||
"""
|
||||
meme_id: int
|
||||
name: str
|
||||
fields: int
|
||||
|
||||
|
||||
def getAllMemes():
|
||||
|
|
Loading…
Reference in New Issue