- Go 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .env.example | ||
| .gitignore | ||
| auth.go | ||
| commands.go | ||
| env.go | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| main.go | ||
| pixiv.go | ||
| README.md | ||
| review_bot.go | ||
| target.go | ||
| telegram.go | ||
pixiv-story-bot
A minimal Telegram user login client built with github.com/gotd/td.
It performs user login, saves the Telegram session credentials to a local file, and can download the first image of a Pixiv artwork to send it to a Telegram group story.
Usage
Create a Telegram application at https://my.telegram.org/apps, then run:
TELEGRAM_APP_ID=123456 \
TELEGRAM_APP_HASH=your_app_hash \
TELEGRAM_PHONE=+8613800000000 \
go run . login
The program will prompt for the Telegram login code. If your account has 2FA enabled, it will also prompt for the 2FA password.
Optional environment variables:
TELEGRAM_SESSION_FILE: session file path, defaults totelegram-session.json.TELEGRAM_PASSWORD: Telegram 2FA password. If unset and 2FA is required, the program prompts interactively.TELEGRAM_TARGET_GROUP_ID: target group/channel IDs for story sending. Multiple groups can be configured with comma-separated values.TELEGRAM_TARGET_GROUP_ACCESS_HASH: target group/channel access hashes. Multiple hashes can be configured with comma-separated values matchingTELEGRAM_TARGET_GROUP_ID.PIXIV_REFRESH_TOKEN: Pixiv refresh token used bygithub.com/txperl/pixivgofor authenticated Pixiv App-API requests.PIXIV_ACCESS_TOKEN: optional existing Pixiv access token. If set, it is used directly withPIXIV_REFRESH_TOKEN.PIXIV_MIN_VIEW_COUNT: optional minimum view count for accepted Pixiv illustrations. Empty means no limit.PIXIV_MIN_BOOKMARK_COUNT: optional minimum bookmark count for accepted Pixiv illustrations. Empty means no limit.TELEGRAM_BOT_TOKEN: Telegram Bot token for thebotreview command.TELEGRAM_BOT_ALLOWED_USER_ID: optional comma-separated Telegram user IDs allowed to use the review bot.
Example with a custom session path:
TELEGRAM_APP_ID=123456 \
TELEGRAM_APP_HASH=your_app_hash \
TELEGRAM_PHONE=+8613800000000 \
TELEGRAM_SESSION_FILE=.telegram/session.json \
go run . login
List group/channel IDs and access hashes after logging in:
go run . groups
Use the printed TELEGRAM_TARGET_GROUP_ID and TELEGRAM_TARGET_GROUP_ACCESS_HASH values to send the first image of a Pixiv artwork to the target group story. When multiple groups are configured, the CLI send command uses the first group:
TELEGRAM_APP_ID=123456 \
TELEGRAM_APP_HASH=your_app_hash \
TELEGRAM_TARGET_GROUP_ID=123456789 \
TELEGRAM_TARGET_GROUP_ACCESS_HASH=987654321 \
PIXIV_REFRESH_TOKEN=your_pixiv_refresh_token \
go run . send 22238487
Start the review bot. Use /group to list target groups and /group <number> (for example /group 1) to choose the target group for the current chat. Send /get to browse recommended Pixiv illustrations, /rank to browse today's illustration ranking, /search <keyword> to browse search results, or /send <artwork-id> to directly send one artwork. Browse commands show illustrations one by one with [Send] [Next] [Related] [Cancel] buttons; [Related] switches the current session to recommendations related to the displayed artwork.
TELEGRAM_BOT_TOKEN=your_bot_token \
TELEGRAM_BOT_ALLOWED_USER_ID=123456789,987654321 \
go run .
Keep the generated session file private; it contains credentials for your Telegram account session.