https://github.com/woozymasta/notify
The notify package provides an easy-to-use interface for sending, editing, and deleting notifications across multiple messaging platforms, including Discord and Telegram.
https://github.com/woozymasta/notify
discord golang telegram
Last synced: 2 months ago
JSON representation
The notify package provides an easy-to-use interface for sending, editing, and deleting notifications across multiple messaging platforms, including Discord and Telegram.
- Host: GitHub
- URL: https://github.com/woozymasta/notify
- Owner: WoozyMasta
- License: mit
- Created: 2025-01-16T23:10:15.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-16T23:19:49.000Z (over 1 year ago)
- Last Synced: 2025-12-31T14:58:25.296Z (6 months ago)
- Topics: discord, golang, telegram
- Language: Go
- Homepage: https://pkg.go.dev/github.com/woozymasta/notify
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Notify
The `notify` package provides an easy-to-use interface for sending, editing,
and deleting notifications across multiple messaging platforms, including
Discord and Telegram. It abstracts the underlying API interactions, allowing
developers to integrate messaging functionalities seamlessly into their Go
applications.
## Features
* **Discord Integration**:
Send, edit, and delete messages via Discord webhooks.
* **Telegram Integration**:
Send, edit, and delete messages using the Telegram Bot API.
* **Unified Interface**:
Consistent methods for different platforms.
* **Markdown Support**:
Utilize Markdown for message formatting where supported.
## Installation
To install the `notify` package, use `go get`:
```bash
go get github.com/woozymasta/notify
```
## Usage
### Discord
```go
package main
import (
"fmt"
"log"
"github.com/woozymasta/notify"
)
func main() {
// Initialize Discord notifier
discordWebhookID := "your_discord_webhook_id"
discordWebhookToken := "your_discord_webhook_token"
discordClient := notify.NewDiscord(discordWebhookID, discordWebhookToken)
// Send a message
messageID, err := discordClient.Send("Hello, **Discord**!")
if err != nil {
log.Fatalf("Failed to send Discord message: %v", err)
}
// Edit the message
if err = discordClient.Edit(messageID, "Bye, *Discord*!"); err != nil {
log.Fatalf("Failed to edit Discord message: %v", err)
}
// Delete the message
if err = discordClient.Delete(messageID); err != nil {
log.Fatalf("Failed to delete Discord message: %v", err)
}
}
```
### Telegram
```go
package main
import (
"fmt"
"log"
"github.com/woozymasta/notify"
)
func main() {
// Initialize Telegram notifier
telegramBotToken := "your_telegram_bot_token"
telegramChatID := "your_telegram_chat_id"
telegramClient := notify.NewTelegram(telegramBotToken, telegramChatID)
// Send a message
messageID, err := telegramClient.Send("Hello, *Telegram*!")
if err != nil {
log.Fatalf("Failed to send Telegram message: %v", err)
}
// Edit the message
if err = telegramClient.Edit(messageID, "Bye, *Telegram*!"); err != nil {
log.Fatalf("Failed to edit Telegram message: %v", err)
}
// Delete the message
if err = telegramClient.Delete(messageID); err != nil {
log.Fatalf("Failed to delete Telegram message: %v", err)
}
}
```
## Testing
Ensure you have the necessary environment variables set before running tests:
* `DISCORD_ID`: Discord webhook ID.
* `DISCORD_TOKEN`: Discord webhook token.
* `TELEGRAM_ID`: Telegram chat ID.
* `TELEGRAM_TOKEN`: Telegram bot token.
Run the tests using:
```bash
go test ./...
```