-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (32 loc) · 836 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
// main.go
package main
import (
"context"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
"hanacore/utils/console"
"os"
"os/signal"
"hanacore/config"
"hanacore/module"
)
func main() {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()
opts := []bot.Option{
bot.WithDefaultHandler(handler),
bot.WithCallbackQueryDataHandler("button", bot.MatchTypePrefix, callbackHandler),
}
b, err := bot.New(config.BotToken, opts...) // Update with your bot token
if err != nil {
panic(err)
}
console.ShowBotInfo(b)
b.Start(ctx)
}
func handler(ctx context.Context, b *bot.Bot, update *models.Update) {
module.DispatchMessage(ctx, b, update)
}
func callbackHandler(ctx context.Context, b *bot.Bot, update *models.Update) {
module.Dispatchcallback(ctx, b, update)
}