Update Dockerfile, main.yml, and index.ts for bot configuration and activity status

This commit is contained in:
암냥 2025-12-11 01:19:09 +09:00
commit 4cb7666826
No known key found for this signature in database
4 changed files with 35 additions and 6 deletions

View file

@ -40,8 +40,8 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/imnyang/yanmang/bot:latest
ghcr.io/imnyang/yanmang/bot:${{ env.RELEASE_VERSION }}
ghcr.io/imnyang/memos-rss/bot:latest
ghcr.io/imnyang/memos-rss/bot:${{ env.RELEASE_VERSION }}
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')

View file

@ -1,8 +1,6 @@
FROM oven/bun:alpine as build
# Set timezone to KST
ENV TZ=Asia/Seoul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apk add --no-cache tzdata git
WORKDIR /app
@ -20,6 +18,8 @@ RUN bun run build
FROM alpine:latest as runtime
RUN apk add --no-cache tzdata
ENV TZ=Asia/Seoul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

12
compose.yml Normal file
View file

@ -0,0 +1,12 @@
services:
# Main Discord bot application
bot:
image: ghcr.io/imnyang/memos-rss/bot:latest
container_name: bot
restart: unless-stopped
env_file:
- .env
volumes:
# Mount any persistent data directories if needed
- ./rss.toml:/app/rss.toml
- ./processed.json:/app/processed.json

View file

@ -1,4 +1,4 @@
import { Client, GatewayIntentBits, REST, Routes } from "discord.js";
import { ActivityType, Client, GatewayIntentBits, REST, Routes } from "discord.js";
import { token, INTERVAL_MS } from "./lib/config";
import { commands, handleClearForum } from "./commands";
import { checkRssFeeds } from "./lib/rss";
@ -7,8 +7,25 @@ const client = new Client({
intents: [GatewayIntentBits.Guilds],
});
async function getGitCommitHash(): Promise<string> {
try {
const data = await Bun.file("./version").text();
return data.trim();
} catch {
return "unknown";
}
}
client.once("clientReady", async () => {
console.log(`Logged in as: ${client.user?.tag}`);
// Git commit hash로 상태 설정
const commitHash = await getGitCommitHash();
client.user?.setActivity({
name: `${commitHash}`,
type: ActivityType.Playing,
});
console.log(`Version: ${commitHash}`);
// Register slash commands
try {