package main import ( tb "gopkg.in/tucnak/telebot.v2" ) func BotHandlers(b *tb.Bot) { b.Handle(tb.OnPhoto, botPhoto) b.Handle(tb.OnChannelPost, botChannelPost) b.Handle(tb.OnQuery, botQuery) b.Handle(tb.OnText, botText) b.Handle(tb.OnDocument, botDocument) b.Start() } func PrintText(m *tb.Message) { logInfoDebug("[%d] %s(%d) | %s(%d) : %s\n", m.ID, m.Chat.Title, m.Chat.ID, m.Sender.Username, m.Sender.ID, m.Text) return } func botPhoto(m *tb.Message) { logInfoDebug("botPhoto :", m.Text) // photos only } func botDocument(m *tb.Message) { logInfoDebug("botDocument : %s (%d bytes)\n", m.Document.FileName, m.Document.File.FileSize) // documents only } func botChannelPost(m *tb.Message) { PrintText(m) b, _ := json.Marshal(m) llogInfoDebug("botChannelPost : %s\n", string(b)) // channel posts only } func botQuery(q *tb.Query) { logInfoDebug("botQuery") // incoming inline queries } func botText(m *tb.Message) { PrintText(m) }