-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (35 loc) · 891 Bytes
/
main.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
42
43
44
45
package main
import (
"context"
"log"
"os"
"os/signal"
"github.com/Evas1oN/inuecobot/commands"
"github.com/Evas1oN/inuecobot/db"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
)
func init() {
db.Init()
}
func main() {
log.Print("weeee ha")
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()
opts := []bot.Option{
bot.WithDefaultHandler(handler),
}
b, err := bot.New("V", opts...)
if err != nil {
panic(err)
}
b.RegisterHandler(bot.HandlerTypeMessageText, "/create", bot.MatchTypePrefix, commands.CreateHandler)
b.RegisterHandler(bot.HandlerTypeMessageText, "/list", bot.MatchTypePrefix, commands.List)
b.Start(ctx)
}
func handler(ctx context.Context, b *bot.Bot, update *models.Update) {
b.SendMessage(ctx, &bot.SendMessageParams{
ChatID: update.Message.Chat.ID,
Text: update.Message.Text,
})
}