Skip to content

Latest commit

 

History

History
72 lines (55 loc) · 1.58 KB

File metadata and controls

72 lines (55 loc) · 1.58 KB

notikit

notikit is a lightweight Go notification toolkit that allows you to send messages across multiple channels, including Telegram and Bark. It's designed to be easy to extend and integrate into any backend application or service.

✨ Features

  • 🔔 Send notifications via multiple channels
  • 📬 Built-in support for:
    • Telegram Bot Notification
    • Bark (iOS Push Notification)
  • 🧱 Modular and easy to extend
  • 🧪 Supports integration testing
  • 🕒 Timestamp with timezone support (for Telegram)

📦 Installation

go get github.com/sudowanderer/notikit

Or for local development:

replace github.com/sudowanderer/notikit => ../path/to/notikit

🚀 Usage Example

package main

import (
	"log"
	"os"
	"time"

	"github.com/sudowanderer/notikit/notifier"
)

func main() {
	// Optional timezone for Telegram messages
	loc, _ := time.LoadLocation("Asia/Shanghai")

	// Telegram Notifier
	tg := notifier.NewTelegramNotifierWithLocation(
		os.Getenv("BOT_TOKEN"),
		os.Getenv("CHAT_ID"),
		loc,
	)

	// Bark Notifier
	bark := notifier.NewBarkNotifier(os.Getenv("BARK_URL"))

	// Combine all channels
	multi := notifier.NewMultiNotifier(tg, bark)

	// Send message to all channels
	err := multi.Notify("🚀 Deployment completed successfully")
	if err != nil {
		log.Fatal(err)
	}
}

Set required environment variables

export BOT_TOKEN=xxx
export CHAT_ID=xxx
export BARK_URL=https://api.day.app/xxx

Run integration tests

go test -tags=integration ./notifier -v