https://github.com/mail-ru-im/bot-golang
Golang library for Bot API
https://github.com/mail-ru-im/bot-golang
agent bot bot-api go golang icq icqnew myteam
Last synced: 4 months ago
JSON representation
Golang library for Bot API
- Host: GitHub
- URL: https://github.com/mail-ru-im/bot-golang
- Owner: mail-ru-im
- License: mit
- Created: 2019-08-08T05:40:45.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-09-04T14:53:37.000Z (9 months ago)
- Last Synced: 2025-09-04T16:37:00.182Z (9 months ago)
- Topics: agent, bot, bot-api, go, golang, icq, icqnew, myteam
- Language: Go
- Homepage:
- Size: 777 KB
- Stars: 64
- Watchers: 11
- Forks: 32
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README

# VK Teams Bot API for Golang
[](https://github.com/mail-ru-im/bot-golang/actions/workflows/go.yml)
[](https://codecov.io/github/mail-ru-im/bot-golang)
[](https://pkg.go.dev/github.com/mail-ru-im/bot-golang)

### [
VK Teams API Specification](https://teams.vk.com/botapi/)
## Getting started
* Create your own bot by sending the _/newbot_ command to _Metabot_ and follow the instructions.
>Note: a bot can only reply after the user has added it to his contact list, or if the user was the first to start a dialogue.
* You can configure the domain that hosts your VK Teams server. When instantiating the Bot class, add the address of your domain.
* An example of how to use the framework can be seen in _example/main.go_
## Install
```bash
go get github.com/mail-ru-im/bot-golang
```
## Usage
Create your own bot by sending the /newbot command to _Metabot_ and follow the instructions.
Note a bot can only reply after the user has added it to his contacts list, or if the user was the first to start a dialogue.
### Create your bot
```go
package main
import "github.com/mail-ru-im/bot-golang"
func main() {
bot, err := botgolang.NewBot(BOT_TOKEN)
if err != nil {
log.Println("wrong token")
}
message := bot.NewTextMessage("some@mail.com", "text")
message.Send()
}
```
### Send and edit messages
You can create, edit and reply to messages like a piece of cake.
```go
message := bot.NewTextMessage("some@mail.com", "text")
message.Send()
message.Text = "new text"
message.Edit()
message.Reply("I changed my text")
```
### Subscribe events
Get all updates from the channel. Use context for cancellation.
```go
ctx, finish := context.WithCancel(context.Background())
updates := bot.GetUpdatesChannel(ctx)
for update := range updates {
// your logic here
}
```
### Passing options
You don't need this.
But if you do, you can override bot's API URL:
```go
bot := botgolang.NewBot(BOT_TOKEN, botgolang.BotApiURL("https://vkteams.com/bot/v1"))
```
And debug all api requests and responses:
```go
bot := botgolang.NewBot(BOT_TOKEN, botgolang.BotDebug(true))
```