all repos — escarbot @ 661438f9080f348c334f56cc65014c5288474afb

Earthbound Café's custom Telegram bot, with lots of cool utilities built-in.

telegram/forward.go (view raw)

 1package telegram
 2
 3import (
 4	"log"
 5
 6	tgbotapi "github.com/BiRabittoh/telegram-bot-api/v5"
 7)
 8
 9func channelPostHandler(escarbot *EscarBot, message *tgbotapi.Message) {
10	chatId := message.Chat.ID
11	if chatId != escarbot.ChannelID {
12		log.Println("Ignoring message since it did not come from the correct chat_id.")
13		return
14	}
15
16	msg := tgbotapi.NewForward(escarbot.GroupID, chatId, message.MessageID)
17	_, err := escarbot.Bot.Send(msg)
18	if err != nil {
19		log.Println("Error forwarding message to group:", err)
20	}
21}
22
23func forwardToAdmin(escarbot *EscarBot, message *tgbotapi.Message) {
24	if !message.Chat.IsPrivate() {
25		return
26	}
27	msg := tgbotapi.NewForward(escarbot.AdminID, message.Chat.ID, message.MessageID)
28	_, err := escarbot.Bot.Send(msg)
29	if err != nil {
30		log.Println("Error forwarding message to admin:", err)
31	}
32}