-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathmain.go
42 lines (35 loc) · 1.07 KB
/
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
package main
import (
"context"
"fmt"
"os"
"github.com/mymmrac/telego"
)
// Using bots in the test environment:
// https://core.telegram.org/bots/webapps#using-bots-in-the-test-environment
func main() {
// Get test Bot token from environment variables
botToken := os.Getenv("TEST_TOKEN")
// Create bot and enable debugging info
// (more on configuration in /examples/configuration/main.go)
bot, err := telego.NewBot(
botToken,
// Use the test server API path instead of the regular API path
telego.WithTestServerPath(),
// Set default logger with debug
// Note: Please keep in mind that default logger may expose sensitive information, use in development only
telego.WithDefaultDebugLogger(),
)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// Call method getMe (https://core.telegram.org/bots/api#getme).
// Note: Bot will call the test server: https://api.telegram.org/bot<token>/test/getMe
botUser, err := bot.GetMe(context.Background())
if err != nil {
fmt.Println("Error:", err)
}
// Print Bot information
fmt.Printf("Bot user: %+v\n", botUser)
}