mirror of
https://github.com/JimenezJC/discord-7tv-emoji-app.git
synced 2025-12-05 23:39:55 -05:00
adding emote fucntion
This commit is contained in:
parent
ae759b9153
commit
9aaf8d7a58
5 changed files with 62 additions and 19 deletions
35
responses.py
35
responses.py
|
|
@ -1,16 +1,39 @@
|
|||
import random
|
||||
import seventv
|
||||
import requests
|
||||
from PIL import Image
|
||||
from io import BytesIO
|
||||
import pyvips
|
||||
|
||||
|
||||
def get_response(message: str) -> str:
|
||||
def get_response(message: str):
|
||||
p_message = message.lower()
|
||||
|
||||
if p_message == 'hello':
|
||||
return 'Hey there!'
|
||||
|
||||
if message == 'roll':
|
||||
return str(random.randint(1, 6))
|
||||
if p_message[:3] == ("add"):
|
||||
url = p_message.split(" ")[1]
|
||||
return(addGif(url))
|
||||
|
||||
if p_message == '!help':
|
||||
return '`This is a help message that you can modify.`'
|
||||
if p_message == 'help':
|
||||
return helpText()
|
||||
|
||||
return 'I didn\'t understand what you wrote. Try typing "!help".'
|
||||
print(p_message[:3])
|
||||
return 'I didn\'t understand what you wrote. Try typing "help".'
|
||||
|
||||
def helpText():
|
||||
return '`This is a help message that you can modify.`'
|
||||
|
||||
|
||||
def addGif(url):
|
||||
webpUrl = seventv.get_webp_url(url)
|
||||
try:
|
||||
webp_data = requests.get(webpUrl).content
|
||||
except requests.exceptions.RequestException:
|
||||
return ("Invalid URL")
|
||||
|
||||
image = pyvips.Image.new_from_buffer(webp_data, '')
|
||||
gif_data = image.write_to_buffer('.gif')
|
||||
|
||||
return gif_data
|
||||
Loading…
Add table
Add a link
Reference in a new issue