modulepackage
0.0.0-20240409115736-4d4de6bc690e
Repository: https://github.com/mail-ru-im/bot-golang.git
Documentation: pkg.go.dev
# README

VK Teams Bot API for Golang
VK Teams API Specification
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
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
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("[email protected]", "text")
message.Send()
}
Send and edit messages
You can create, edit and reply to messages like a piece of cake.
message := bot.NewTextMessage("[email protected]", "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.
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:
bot := botgolang.NewBot(BOT_TOKEN, botgolang.BotApiURL("https://vkteams.com/bot/v1"))
And debug all api requests and responses:
bot := botgolang.NewBot(BOT_TOKEN, botgolang.BotDebug(true))
# Packages
No description provided by the author
# Functions
NewBot returns new bot object.
NewCallbackButton returns new button with CallbackData field.
No description provided by the author
No description provided by the author
NewKeyboard returns a new keyboard instance.
No description provided by the author
NewURLButton returns new button with URL field.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
Bot is the main structure for interaction with API.
No description provided by the author
Button represents a button in inline keyboard Make sure you have URL or CallbackData in your Button.
ButtonResponse represents a data that is returned when a button is clicked.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Keyboard represents an inline keyboard markup Call the NewKeyboard() func to get a keyboard instance.
No description provided by the author
Message represents a text message.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author
ButtonStyle represent a style of a Button.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ParseMode represent a type of text formatting.
No description provided by the author