adding emote fucntion

This commit is contained in:
Juan 2023-07-09 22:22:23 -04:00
parent ae759b9153
commit 9aaf8d7a58
5 changed files with 62 additions and 19 deletions

View file

@ -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