11 Commits

Author SHA1 Message Date
Michelle 4d802aba94 feat: update version number to 0.5.1
Build and publish ich_iel bot / build (push) Successful in 1m31s
Build and publish ich_iel bot / build (release) Successful in 1m36s
2026-04-25 17:35:54 +02:00
Michelle 668eb52673 fix: correct response status check in racoon command
Build and publish ich_iel bot / build (push) Successful in 1m31s
2026-04-25 17:31:04 +02:00
Michelle 90684ba27f fix: use aiohttp for racoon command
Build and publish ich_iel bot / build (push) Successful in 1m29s
2026-04-25 17:28:16 +02:00
Michelle 08778bf0a5 fix: add logging for failed racoon image decoding
Build and publish ich_iel bot / build (push) Successful in 1m32s
2026-04-25 17:18:29 +02:00
Michelle 63972faa63 fix: racoon command should work now
Build and publish ich_iel bot / build (push) Successful in 1m29s
2026-04-25 17:14:25 +02:00
Michelle f0729f43c9 feat: add racoon command to post racoon images
Build and publish ich_iel bot / build (push) Successful in 1m30s
2026-04-25 17:06:26 +02:00
Michelle 91b31ed114 feat: update version number to 0.5.0
Build and publish ich_iel bot / build (push) Successful in 1m29s
Build and publish ich_iel bot / build (release) Successful in 1m34s
2026-04-25 16:50:37 +02:00
Michelle 6df7d68f5a fix: update dog and fox commands, they should actually work now
Build and publish ich_iel bot / build (push) Successful in 1m31s
2026-04-25 16:47:08 +02:00
Michelle 8615cc4d0d fix: sorry i just copy pasted the cat command which didn't work
Build and publish ich_iel bot / build (push) Successful in 1m31s
2026-04-25 16:43:32 +02:00
Michelle b9e1740e10 feat: add dog and fox commands
Build and publish ich_iel bot / build (push) Successful in 1m32s
2026-04-25 16:39:23 +02:00
Michelle 4c874cbaa4 fix: remove on_guild_remove to avoid wiping data on outages
Build and publish ich_iel bot / build (push) Successful in 1m34s
2026-04-25 14:29:21 +02:00
2 changed files with 46 additions and 23 deletions
+44 -22
View File
@@ -1,7 +1,9 @@
import aiohttp
import fluxer
import requests
import json
import asyncio
import base64
from dotenv import load_dotenv
import sqlite3
import os
@@ -118,7 +120,7 @@ async def setChannel(message):
@bot.command()
async def version(message):
await message.channel.send("Version 0.4.1 is running\nSource code: https://github.com/michelleDeko/ich_iel-bot")
await message.channel.send("Version 0.5.1 is running\nSource code: https://github.com/michelleDeko/ich_iel-bot")
# the cat bot died, so i wanted to add this command to this bot
@bot.command()
@@ -133,6 +135,46 @@ async def cat(message):
else:
await message.channel.send("Failed to fetch cat image")
# i thought dogs and foxes would be nice to have too
@bot.command()
async def dog(message):
response = requests.get("https://dog.ceo/api/breeds/image/random")
if response.status_code == 200:
data = response.json()
if data and isinstance(data, dict) and "message" in data:
await message.channel.send(data["message"])
else:
await message.channel.send("Could not fetch dog image")
else:
await message.channel.send("Failed to fetch dog image")
@bot.command()
async def fox(message):
response = requests.get("https://randomfox.ca/floof/")
if response.status_code == 200:
data = response.json()
if data and isinstance(data, dict) and "image" in data:
await message.channel.send(data["image"])
else:
await message.channel.send("Could not fetch fox image")
else:
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"
])
async with aiohttp.ClientSession() as session:
async with session.get(urls) as response:
image_bytes = await response.read()
if response.status != 200:
await message.channel.send("Failed to fetch racoon image")
return
await message.channel.send(file=fluxer.File(image_bytes, filename="racoon.jpg"))
async def post_reddit():
subreddit = os.getenv("SUBREDDIT", "ich_iel")
posts = await get_latest_post(subreddit)
@@ -170,6 +212,7 @@ async def post_reddit():
else:
logging.warning(f"Bot is not in guild {guild_id}, removing guild from database")
cur.execute("DELETE FROM channels WHERE guild_id = ?", (guild_id,))
cur.execute("DELETE FROM posted WHERE guild_id = ?", (guild_id,))
con.commit()
break
else:
@@ -201,27 +244,6 @@ async def check_guild(guild_id):
logging.warning(f"Bot doesn't have access to guild {guild_id}")
return False
@bot.event
async def on_guild_remove(guild):
if isinstance(guild, fluxer.Guild):
guild_id = guild.id
logging.info(f"Removed from guild: {guild.name} (ID: {guild_id}), removing from database")
else:
if guild.get("unavailable"):
logging.info(f"Guild {guild.get('id')} is temporarily unavailable, ignoring")
return
guild_id = int(guild["id"])
logging.info(f"Removed from guild {guild_id}, removing from database")
try:
con = sqlite3.connect('data/ich_iel-bot.db')
cur = con.cursor()
cur.execute("DELETE FROM channels WHERE guild_id = ?", (guild_id,))
cur.execute("DELETE FROM posted WHERE guild_id = ?", (guild_id,))
con.commit()
logging.info(f"Guild {guild_id} removed from database successfully")
except sqlite3.Error as e:
logging.error(f"Database error while removing guild {guild_id}: {e}")
if __name__ == "__main__":
logging.info("Starting bot...")
asyncio.run(init_db())
+2 -1
View File
@@ -1,4 +1,5 @@
fluxer.py
requests
asyncio
dotenv
dotenv
aiohttp