Compare commits
4
Commits
ecd0ca09ea
..
1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
139a5ad956 | ||
|
|
d4502bed84 | ||
|
|
c7adb15c86 | ||
|
|
dc763d54c1 |
+1
-1
@@ -4,6 +4,6 @@ ENV PATH=/usr/local/bin:$PATH
|
||||
WORKDIR /app
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg && rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ffmpeg && rm -rf /var/lib/apt/lists/*
|
||||
COPY . .
|
||||
CMD ["python", "-u", "main.py"]
|
||||
@@ -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/1.0.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 1.0.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()
|
||||
@@ -269,7 +269,18 @@ async def post_reddit():
|
||||
channel = await bot.fetch_channel(int(channel_id))
|
||||
if channel:
|
||||
if await check_guild(guild_id):
|
||||
await channel.send(f"{title}\nOriginal post: {image_url}")
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(image_url) as response:
|
||||
if response.status != 200:
|
||||
logging.error(f"Failed to fetch image from {image_url}: {response.status}")
|
||||
continue
|
||||
image_bytes = await response.read()
|
||||
content_type = response.headers.get("Content-Type", "").split(";")[0]
|
||||
file_ext = content_type.split("/")[-1] if content_type.startswith("image/") else "jpg"
|
||||
await channel.send(
|
||||
content=f"{title}\nOriginal post: {image_url}",
|
||||
file=fluxer.File(image_bytes, filename=f"{post_id}.{file_ext}")
|
||||
)
|
||||
cur.execute("INSERT OR REPLACE INTO posted (guild_id, post_id) VALUES (?, ?)", (guild_id, post_id))
|
||||
con.commit()
|
||||
logging.info(f"Posted to channel {channel_id} in guild {guild_id}")
|
||||
|
||||
Reference in New Issue
Block a user