From 319c091fce1f277acd919c6b8f9ca50b180221ae Mon Sep 17 00:00:00 2001 From: shoopea Date: Sun, 21 Jun 2020 19:51:33 +0200 Subject: [PATCH] tet --- bot.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 bot.go diff --git a/bot.go b/bot.go new file mode 100644 index 0000000..67c851a --- /dev/null +++ b/bot.go @@ -0,0 +1,48 @@ +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) +}