3 Commits
Author SHA1 Message Date
Michelle dc763d54c1 update version
Build and publish ich_iel bot / build (push) Successful in 5m45s
Build and publish ich_iel bot / build (release) Failing after 20m35s
2026-05-26 12:45:10 +02:00
Michelle ecd0ca09ea Merge pull request 'add capybara command' (#2) from Amy/ich_iel-Bot:master into master
Build and publish ich_iel bot / build (push) Failing after 18m8s
Reviewed-on: #2
2026-05-26 12:34:15 +02:00
Amy 4a633809f8 add capybara command 2026-05-26 12:30:05 +02:00
+28 -2
View File
@@ -55,7 +55,7 @@ async def post_reddit_periodically():
async def get_latest_post(subreddit):
post_limit = os.getenv("POST_LIMIT", 20)
url = f"https://www.reddit.com/r/{subreddit}/hot.rss?limit={post_limit}"
headers = {"User-Agent": "Mozilla/5.0 (compatible; ich_iel-Bot/0.6.3)"}
headers = {"User-Agent": "Mozilla/5.0 (compatible; ich_iel-Bot/0.7.0)"}
response = requests.get(url, headers=headers)
if response.status_code != 200:
logging.error(f"Failed to fetch RSS feed: {response.status_code}")
@@ -121,7 +121,7 @@ async def setChannel(message):
@bot.command()
async def version(message):
await message.channel.send("Version 0.6.3 is running\nSource code: https://github.com/michelleDeko/ich_iel-bot")
await message.channel.send("Version 0.7.0 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()
@@ -214,6 +214,32 @@ async def bnuy(message):
file_ext = content_type.split("/")[-1] if content_type.startswith("image/") else "jpg"
await message.channel.send(file=fluxer.File(image_bytes, filename=f"bnuy.{file_ext}"))
@bot.command()
@bot.command("capy")
async def capybara(message):
async with aiohttp.ClientSession() as session:
async with session.get("https://api.capy.lol/v1/capybara?json=true") as response:
if response.status != 200:
await message.channel.send("Failed to fetch image of a bunny")
return
data = await response.json()
image_url = (
data.get("data", {}).get("url")
)
if not image_url:
await message.channel.send("Failed to fetch image of a capybara")
return
async with session.get(image_url) as image_response:
if image_response.status != 200:
await message.channel.send("Failed to fetch image of a capybara")
return
image_bytes = await image_response.read()
content_type = image_response.headers.get("Content-Type", "").split(";")[0]
file_ext = content_type.split("/")[-1] if content_type.startswith("image/") else "jpeg"
await message.channel.send(file=fluxer.File(image_bytes, filename=f"capybara.{file_ext}"))
async def post_reddit():
subreddit = os.getenv("SUBREDDIT", "ich_iel")
posts = await get_latest_post(subreddit)