https://github.com/spyzhov/tg
Telegram Bot API
https://github.com/spyzhov/tg
golang golang-library golang-package telegram telegram-bot telegram-bot-api
Last synced: 5 months ago
JSON representation
Telegram Bot API
- Host: GitHub
- URL: https://github.com/spyzhov/tg
- Owner: spyzhov
- License: mit
- Created: 2019-06-21T10:59:42.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-06T08:19:41.000Z (almost 7 years ago)
- Last Synced: 2024-06-20T17:37:52.891Z (about 2 years ago)
- Topics: golang, golang-library, golang-package, telegram, telegram-bot, telegram-bot-api
- Language: Go
- Homepage:
- Size: 287 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Telegram bot API on Golang
[](https://godoc.org/github.com/spyzhov/tg)
Implement golang interface for [Telegram Bot API](https://core.telegram.org/bots/api).
Implemented all methods up to: May 31, 2019 Bot API 4.3
# API
All documentation about Bot.API you can find at [API.md](API.md)
# Examples
All examples are at: [example](example/) dir.
# Generator
Generates API using [`generator.py`](generator.py): [requirements](requirements.txt) listed at file, Python3.7 required.
## Simple use
```go
package main
import (
"context"
"fmt"
. "github.com/spyzhov/tg"
"os"
"strconv"
)
func main() {
bot := New(os.Getenv("TOKEN"))
chatId, err := strconv.Atoi(os.Getenv("CHAT_ID"))
if err != nil {
panic(err)
}
user, err := bot.GetMe(context.Background())
if err != nil {
panic(err)
}
result, err := bot.SendMessage(context.Background(), &SendMessageRequest{
ChatId: chatId,
Text: "Hello, my name is " + user.Username,
})
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", result)
if result.From != nil {
fmt.Printf("From: %#v\n", result.From)
}
fmt.Printf("Chat: %#v\n", result.Chat)
}
```