tet
This commit is contained in:
parent
8ba2557c43
commit
319c091fce
48
bot.go
Normal file
48
bot.go
Normal file
@ -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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user