Skip to content

Commit 8e2d070

Browse files
committed
init with bots/auto-moderator
1 parent 5c91590 commit 8e2d070

File tree

21 files changed

+599
-0
lines changed

21 files changed

+599
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
on:
2+
- push
3+
- pull_request
4+
defaults:
5+
run:
6+
working-directory: bots/auto-moderator
7+
jobs:
8+
type-check:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v6
12+
- uses: oven-sh/setup-bun@v2
13+
with:
14+
bun-version: 1.2.5
15+
- run: bun install --frozen-lockfile
16+
- run: bun ci
17+
biome:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v6
21+
- uses: biomejs/setup-biome@v2
22+
- run: biome check

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# commonly ignored files
2+
node_modules
3+
.direnv
4+
.devenv
5+
.env
6+
.envrc.local

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Discord Bots
2+
3+
何か書く。
4+
5+
## Bot追加方法
6+
7+
1.
8+
9+
```sh
10+
mkdir bots/YOUR_BOT
11+
```
12+
13+
2. bots/YOUR_BOT にBotを書く
14+
3. `rollcron.yaml` に YOUR_BOT の cron スケジュールとスクリプトを書く。
15+
4. VPS にすでに実行環境がない場合は、実行環境を作る (Docker ランナーはそのうちサポートする予定)

bots/auto-moderator/.envrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
use flake
2+
if [ -f ./.envrc.local ]; then
3+
source .envrc.local
4+
fi
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export DISCORD_WEBHOOK_URL=
2+
export NOTION_API_KEY=

bots/auto-moderator/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.direnv
3+
.envrc.local

bots/auto-moderator/AGENTS.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Agents Guide
2+
3+
This file provides guidance to coding agents when working with code in this repository.
4+
5+
## Overview
6+
7+
This is an auto-moderator application that monitors task deadlines in a Notion database and sends reminders to Discord. It fetches tasks with deadlines within 3 days that are not marked as completed, formats them with assignee mentions, and sends notifications via Discord webhook.
8+
9+
## Development Commands
10+
11+
- **Start the application**: `bun run start`
12+
- **Type checking**: `bun run ci` or `bunx tsc`
13+
- **Linting and formatting**: `biome check --write` (configured for 120 character line width, 2-space indentation)
14+
15+
## Project Structure
16+
17+
The codebase is organized into 4 focused TypeScript modules:
18+
19+
- **`src/main.ts`**: Main application logic that orchestrates task fetching, formatting, and notification sending
20+
- **`src/validator.ts`**: Valibot schemas for validating Notion API responses and type definitions
21+
- **`src/io.ts`**: I/O utilities for environment variables, retry logic, Discord webhooks, and Notion API queries
22+
- **`src/data.ts`**: Static mapping between Notion user names and Discord user IDs for @mentions
23+
24+
## Architecture
25+
26+
The application follows a functional architecture with clear separation:
27+
28+
1. **Data Layer**: Notion API integration with type-safe schema validation using Valibot
29+
2. **Business Logic**: Task filtering (3-day deadline window), formatting with Discord mentions
30+
3. **I/O Layer**: Discord webhook notifications with retry mechanism
31+
32+
## Environment Variables
33+
34+
Required environment variables:
35+
- `NOTION_API_KEY`: Notion integration token
36+
- `DISCORD_WEBHOOK_URL`: Discord webhook URL for notifications
37+
38+
## Git Hooks
39+
40+
Lefthook is configured for pre-commit hooks:
41+
- Biome formatting and linting with auto-fix
42+
- TypeScript type checking
43+
44+
Run `lefthook install` to set up hooks.
45+
46+
## Technology Stack
47+
48+
- **Runtime**: Bun
49+
- **Language**: TypeScript with strict mode
50+
- **Validation**: Valibot for runtime type safety
51+
- **APIs**: Notion API v2022-06-28, Discord webhooks
52+
- **Tooling**: Biome for linting/formatting, Lefthook for git hooks

bots/auto-moderator/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

bots/auto-moderator/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# auto-moderator

bots/auto-moderator/biome.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
3+
"formatter": {
4+
"enabled": true,
5+
"indentStyle": "space",
6+
"indentWidth": 2,
7+
"lineWidth": 120
8+
},
9+
"linter": {
10+
"enabled": true,
11+
"rules": {
12+
"recommended": true
13+
}
14+
},
15+
"vcs": {
16+
"enabled": true,
17+
"clientKind": "git",
18+
"useIgnoreFile": true
19+
}
20+
}

0 commit comments

Comments
 (0)