Add memegen integration
This commit is contained in:
parent
e054c87db3
commit
4500d2b4a8
|
@ -0,0 +1,32 @@
|
||||||
|
import requests,plugin
|
||||||
|
|
||||||
|
def fixUp(text):
|
||||||
|
if not text: return "_" # escape empty string
|
||||||
|
text = text.replace("_","__") # escape underscores
|
||||||
|
text = text.replace(" ","_") # escape spaces
|
||||||
|
text = text.replace("-","--") # escape dashes
|
||||||
|
text = text.replace("''",'"') # escape double quote
|
||||||
|
text = text.replace("?","~q") # escape question marks
|
||||||
|
text = text.replace("%","~p") # escape question marks
|
||||||
|
text = text.replace("#","~h") # escape question marks
|
||||||
|
text = text.replace("/","~s") # escape question marks
|
||||||
|
return text
|
||||||
|
|
||||||
|
@plugin.command("meme","<template/url> Top Text | Bottom Text")
|
||||||
|
def memegen(bot,channel,nick,template,*msg):
|
||||||
|
if not msg:
|
||||||
|
raise TypeError() # usage screen
|
||||||
|
msg = " ".join(msg)
|
||||||
|
if "|" in msg:
|
||||||
|
top, bottom = msg.split("|")
|
||||||
|
else:
|
||||||
|
top, bottom = "", msg
|
||||||
|
top = fixUp(top)
|
||||||
|
bottom = fixUp(bottom)
|
||||||
|
if "://" in template: # URL
|
||||||
|
bot.say(channel,"{}: https://memegen.link/custom/{}/{}.jpg?alt={}".format(nick,top,bottom,template))
|
||||||
|
else:
|
||||||
|
r = requests.get("https://memegen.link/{}/{}/{}".format(template,top,bottom))
|
||||||
|
r.raise_for_status()
|
||||||
|
r = r.json()
|
||||||
|
bot.say(channel,"{}: {}".format(nick,r["direct"]["masked"]))
|
Loading…
Reference in New Issue