feat: add racoon command to post racoon images
Build and publish ich_iel bot / build (push) Successful in 1m30s

This commit is contained in:
2026-04-25 17:06:26 +02:00
parent 91b31ed114
commit f0729f43c9
+24
View File
@@ -2,6 +2,7 @@ import fluxer
import requests import requests
import json import json
import asyncio import asyncio
import base64
from dotenv import load_dotenv from dotenv import load_dotenv
import sqlite3 import sqlite3
import os import os
@@ -158,6 +159,29 @@ async def fox(message):
else: else:
await message.channel.send("Failed to fetch fox image") await message.channel.send("Failed to fetch fox image")
# time for racoons
@bot.command()
async def racoon(message):
urls = random.choice([
"https://api.mapach.es/v1/meme",
"https://api.mapach.es/v1/coon"
])
response = requests.get(urls)
if response.status_code != 200:
await message.channel.send("Failed to fetch racoon image")
return
match = re.match(r"data:image/(\w+);base64,(.+)", response.text.strip())
if not match:
await message.channel.send("Could not fetch racoon image")
return
ext, payload = match.group(1), match.group(2)
try:
image_bytes = base64.b64decode(payload)
except (ValueError, base64.binascii.Error):
await message.channel.send("Could not decode racoon image")
return
await message.channel.send(file=fluxer.File(image_bytes, filename=f"racoon.{ext}"))
async def post_reddit(): async def post_reddit():
subreddit = os.getenv("SUBREDDIT", "ich_iel") subreddit = os.getenv("SUBREDDIT", "ich_iel")
posts = await get_latest_post(subreddit) posts = await get_latest_post(subreddit)