Init
This commit is contained in:
commit
310fcc6eb0
86 changed files with 10611 additions and 0 deletions
42
telegram.go
Normal file
42
telegram.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
)
|
||||
|
||||
func startTelegramBot() {
|
||||
u := tgbotapi.NewUpdate(0)
|
||||
u.Timeout = 60
|
||||
|
||||
updates := bot.GetUpdatesChan(u)
|
||||
|
||||
for update := range updates {
|
||||
if update.Message == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
|
||||
_, err := bot.Send(msg)
|
||||
if err != nil {
|
||||
log.Printf("Error sending message: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func sendTelegramNotification(message string) {
|
||||
if bot == nil {
|
||||
log.Println("Telegram bot is not initialized")
|
||||
return
|
||||
}
|
||||
|
||||
// Replace with the actual chat ID you want to send messages to
|
||||
chatID := int64(YOUR_TELEGRAM_CHAT_ID)
|
||||
|
||||
msg := tgbotapi.NewMessage(chatID, message)
|
||||
_, err := bot.Send(msg)
|
||||
if err != nil {
|
||||
log.Printf("Error sending Telegram notification: %v", err)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue