English | 中文
A lightweight Go library for sending notifications via Feishu (Lark) and Telegram.
Feishu / Lark
- Webhook messages (text, rich-text / post)
- SDK-based messaging via official Lark Open Platform
- Phone urgent call notifications
Telegram
- Bot with chat ID whitelist middleware
- Simple
Notify()helper for one-off messages - Long-polling command handler with
Start()
- Go 1.24+
go get github.com/QuantProcessing/notifyImport only what you need:
import "github.com/QuantProcessing/notify/feishu"
import "github.com/QuantProcessing/notify/telegram"npx skills add QuantProcessing/notify| Variable | Required | Description |
|---|---|---|
FEISHU_WEBHOOK |
Yes (Feishu) | Webhook URL for bot messages |
FEISHU_APP_ID |
No | Lark App ID (for SDK features / urgent calls) |
FEISHU_APP_SECRET |
No | Lark App Secret |
FEISHU_USER_OPEN_ID |
No | User Open ID (for phone urgent calls) |
TELEGRAM_BOT_TOKEN |
Yes (Telegram) | Telegram bot token |
TELEGRAM_CHAT_ID |
Yes (Telegram) | Comma-separated chat IDs (first is default) |
See .env.example for a complete template.
package main
import (
"log"
"github.com/QuantProcessing/notify/feishu"
)
func main() {
feishu.Init(feishu.Config{
Webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/xxx",
})
if err := feishu.SendText("Hello from Go!"); err != nil {
log.Fatal(err)
}
}err := feishu.SendRichText("Alert", [][]feishu.PostElem{
{feishu.NewTextElem("Server "), feishu.NewAElem("down", "https://example.com")},
{feishu.NewAtElem("ou_user_id")},
})Requires App ID, App Secret, and User Open ID:
feishu.Init(feishu.Config{
Webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/xxx",
AppID: "cli_xxx",
AppSecret: "xxx",
UserOpenID: "ou_xxx",
})
if err := feishu.SendUrgentText("CRITICAL: System Down!"); err != nil {
log.Fatal(err)
}bot := feishu.NewBot(feishu.Config{
Webhook: "https://open.feishu.cn/open-apis/bot/v2/hook/xxx",
})
if err := bot.SendText("Hello!"); err != nil {
log.Fatal(err)
}package main
import (
"log"
"github.com/QuantProcessing/notify/telegram"
)
func main() {
if err := telegram.Init(telegram.Config{
BotToken: "123456:ABC-DEF...",
ChatID: "12345678", // comma-separated for multiple
}); err != nil {
log.Fatal(err)
}
if err := telegram.Notify("Trade executed: BUY 0.01 BTC @ $65,000"); err != nil {
log.Fatal(err)
}
}ctx, cancel := context.WithCancel(context.Background())
defer cancel()
telegram.Start(ctx) // blocks until ctx is cancelledbot, err := telegram.NewBot(telegram.Config{
BotToken: "123456:ABC-DEF...",
ChatID: "12345678",
})
if err != nil {
log.Fatal(err)
}
if err := bot.Notify("Hello!"); err != nil {
log.Fatal(err)
}notify/
├── feishu/ # Feishu (Lark) notification package
│ ├── bot.go # Global API + Bot struct
│ ├── client.go # HTTP webhook + Lark SDK client
│ └── types.go # Message type definitions
├── telegram/ # Telegram notification package
│ ├── bot.go # Global API + Bot struct
│ └── middleware.go # Chat ID authorization middleware
├── go.mod
├── LICENSE # MIT
└── README.md