|
|
8 months ago | |
|---|---|---|
| .. | ||
| .gitignore | 8 months ago | |
| README.md | 8 months ago | |
| bun.lock | 8 months ago | |
| notify.ts | 8 months ago | |
| package.json | 8 months ago | |
| telegram-notify.ts | 8 months ago | |
| tsconfig.json | 8 months ago | |
Simple Telegram notifications for OpenCode sessions.
telegram-notify.ts - OpenCode plugin for session eventsnotify.ts - Simple system notification plugin (uses say)telegram-bot.ts - Telegram bot implementationpackage.json - Dependencies and scriptstsconfig.json - TypeScript configuration/send-last, /send-to-phone// The plugin automatically responds to session events
import { TelegramNotify } from "./telegram-notify.js"
Commands you can use in OpenCode:
/send-last - Send the last message to Telegram/send-to-phone - Send the last message to your phone/last - Same as /send-last/phone - Same as /send-to-phone# Run the bot directly
bun telegram-bot.ts
# Test the plugin
bun telegram-notify.ts
Create a Telegram Bot
/newbotGet Your Chat ID
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdateschat_id in the responseConfigure Environment Variables
export TELEGRAM_BOT_TOKEN="your_bot_token_here"
export TELEGRAM_CHAT_ID="your_chat_id_here"
Or Update Configuration
Edit .opencode/plugin/telegram-config.json:
{
"telegramIdle": {
"enabled": true,
"botToken": "your_bot_token_here",
"chatId": "your_chat_id_here"
}
}
The plugin automatically initializes when OpenCode starts. It will:
You can customize the plugin behavior by modifying the configuration:
idleTimeout: Time in milliseconds before considering session idlecheckInterval: How often to check for idle statemessages: Customize notification messagesTo integrate this plugin with OpenCode's event system, you would need to:
handleActivity() when user interacts with OpenCodeinit() when OpenCode session startscleanup() when OpenCode session endsTest the plugin independently:
node .opencode/plugin/telegram-idle.js
TELEGRAM_BOT_TOKEN environment variableTELEGRAM_CHAT_ID environment variable