upd
This commit is contained in:
parent
c986f1559f
commit
70952f7f9b
48
bot.go
48
bot.go
|
@ -25,32 +25,19 @@ func StartBot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Handle("/hello", botHello)
|
b.Handle("/hello", botHello)
|
||||||
|
b.Handle(tb.OnPhoto, botPhoto)
|
||||||
b.Handle(tb.OnPhoto, func(m *tb.Message) {
|
b.Handle(tb.OnChannelPost, botChannel)
|
||||||
fmt.Println("OnPhoto :", m.Text)
|
b.Handle(tb.OnQuery, botQuery)
|
||||||
// photos only
|
b.Handle(tb.OnText, botText)
|
||||||
})
|
|
||||||
|
|
||||||
b.Handle(tb.OnChannelPost, func (m *tb.Message) {
|
|
||||||
fmt.Println("OnChannelPost :", m.Text)
|
|
||||||
PrintText(m)
|
|
||||||
// channel posts only
|
|
||||||
})
|
|
||||||
|
|
||||||
b.Handle(tb.OnQuery, func (q *tb.Query) {
|
|
||||||
fmt.Println("Query ?")
|
|
||||||
// incoming inline queries
|
|
||||||
})
|
|
||||||
|
|
||||||
b.Handle(tb.OnText, func(m *tb.Message) {
|
|
||||||
PrintText(m)
|
|
||||||
// all the text messages that weren't
|
|
||||||
// captured by existing handlers
|
|
||||||
})
|
|
||||||
|
|
||||||
b.Start()
|
b.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func botPhoto(m *tb.Message) {
|
||||||
|
fmt.Println("OnPhoto :", m.Text)
|
||||||
|
// photos only
|
||||||
|
}
|
||||||
|
|
||||||
func botHello(m *tb.Message) {
|
func botHello(m *tb.Message) {
|
||||||
if !m.Private() {
|
if !m.Private() {
|
||||||
return
|
return
|
||||||
|
@ -59,3 +46,20 @@ func botHello(m *tb.Message) {
|
||||||
PrintText(m)
|
PrintText(m)
|
||||||
b.Send(m.Sender, "hello world")
|
b.Send(m.Sender, "hello world")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func botChannelPost(m *tb.Message) {
|
||||||
|
fmt.Println("OnChannelPost :", m.Text)
|
||||||
|
PrintText(m)
|
||||||
|
// channel posts only
|
||||||
|
}
|
||||||
|
|
||||||
|
func botQuery(q *tb.Query) {
|
||||||
|
fmt.Println("Query ?")
|
||||||
|
// incoming inline queries
|
||||||
|
}
|
||||||
|
|
||||||
|
func botText(m *tb.Message) {
|
||||||
|
PrintText(m)
|
||||||
|
// all the text messages that weren't
|
||||||
|
// captured by existing handlers
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user