-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (29 loc) · 808 Bytes
/
main.go
File metadata and controls
35 lines (29 loc) · 808 Bytes
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
package main
import (
"context"
"time"
"github.com/rs/zerolog/log"
"github.com/green-api/maxbot-api-client-go/pkg/api"
"github.com/green-api/maxbot-api-client-go/pkg/client"
"github.com/green-api/maxbot-api-client-go/pkg/models"
)
func main() {
bot, err := api.New(client.Config{
BaseURL: "https://platform-api.max.ru",
Token: "YOUR_BOT_TOKEN",
RateLimiter: 25,
Timeout: 30 * time.Second,
})
if err != nil {
log.Fatal().Err(err).Msg("failed to init MAX API")
}
const exampleUserID int64 = 123456789 // recipient user ID
_, err = bot.Messages.SendMessage(context.Background(), models.SendMessageReq{
UserID: exampleUserID,
Text: "Hello world!",
})
if err != nil {
log.Error().Msgf("SendMessage error: %v", err)
}
log.Info().Msgf("SendMessage success!")
}