-
Notifications
You must be signed in to change notification settings - Fork 25
/
handle_telegram.go
41 lines (35 loc) · 971 Bytes
/
handle_telegram.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"context"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
)
func handle(upd tgbotapi.Update) {
ctx := context.WithValue(context.Background(), "origin", "telegram")
switch {
case upd.Message != nil:
// // people joining
// if upd.Message.NewChatMembers != nil {
// for _, newmember := range *upd.Message.NewChatMembers {
// handleTelegramNewMember(ctx, upd.Message, newmember)
// }
// return
// }
// // people leaving
// if upd.Message.LeftChatMember != nil {
// return
// }
// // normal message
// proceed := interceptMessage(upd.Message)
// if proceed {
handleTelegramMessage(ctx, upd.Message)
// } else {
// go deleteMessage(upd.Message)
// }
case upd.ChannelPost != nil:
// handleTelegramMessage(ctx, upd.ChannelPost)
case upd.CallbackQuery != nil:
handleTelegramCallback(ctx, upd.CallbackQuery)
case upd.InlineQuery != nil:
// go handleInlineQuery(ctx, upd.InlineQuery)
}
}