-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.go
More file actions
54 lines (43 loc) · 1.26 KB
/
handler.go
File metadata and controls
54 lines (43 loc) · 1.26 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"context"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
"github.com/zexk/mercurylampe/internal/cat"
)
func defaultHandler(ctx context.Context, b *bot.Bot, update *models.Update) {
if update.Message != nil {
b.SendMessage(ctx, &bot.SendMessageParams{
ChatID: update.Message.Chat.ID,
Text: update.Message.Text,
})
}
}
func catHandler(ctx context.Context, b *bot.Bot, update *models.Update) {
data := cat.GetCat()
params := &bot.SendPhotoParams{
ChatID: update.Message.Chat.ID,
Photo: &models.InputFileUpload{Data: data},
}
b.SendPhoto(ctx, params)
}
func gcatHandler(ctx context.Context, b *bot.Bot, update *models.Update) {
data := cat.GetGifCat()
params := &bot.SendAnimationParams{
ChatID: update.Message.Chat.ID,
Animation: &models.InputFileUpload{Filename: "file.gif", Data: data},
}
b.SendAnimation(ctx, params)
}
func tcatHandler(ctx context.Context, b *bot.Bot, update *models.Update) {
b.SendMessage(ctx, &bot.SendMessageParams{
ChatID: update.Message.Chat.ID,
Text: "what should the cat say?",
})
data := cat.GetTextCat(update.Message.Text)
params := &bot.SendPhotoParams{
ChatID: update.Message.Chat.ID,
Photo: &models.InputFileUpload{Data: data},
}
b.SendPhoto(ctx, params)
}