forked from mail-ru-im/bot-golang
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mail-ru-im/master
Update from upstream
- Loading branch information
Showing
11 changed files
with
168 additions
and
68 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Go | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
|
||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
|
||
- name: Lint | ||
run: make lint | ||
|
||
- name: Test | ||
run: make test | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
files: cover.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Contribute | ||
## Pull request | ||
Если вы решили впервые стать контрибьютером и помочь развитию open-source проекта, этот пункт для вас. | ||
1) Делается fork основного репозитория | ||
2) git clone https://github.com/ваш-логин/bot-golang.git | ||
3) Локальное изменение | ||
4) Сделайте ребейз на remote master ветку | ||
5) git push origin <ваш-логин> | ||
6) В удаленном репозитории нажать _compare&pull request_ | ||
|
||
Также рекомендуем ознакомиться с подробной инструкцией для контрибьютеров - <a href="https://github.com/firstcontributions/first-contributions">README.md</a> | ||
|
||
## Tests | ||
1) Если добавляется новая функциональность, то покрывайте ее тестами | ||
2) Следите за тем, чтобы тесты успешно выполнялись в PR перед мержем. | ||
|
||
## Merge | ||
Ветка будет смержена в мастер, когда: | ||
1) Все пайплайны пройдут успешно | ||
2) Новая функциональность будет покрыта тестами | ||
|
||
После выполнения всех пунктов один из сотрудников проверит в ближайшее время PR и смержит его. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
<img src="https://github.com/mail-ru-im/bot-python/blob/master/logo.png" width="100" height="100"> | ||
<img src="logo_bot.png" width="100" height="100"> | ||
|
||
# Golang interface for Mail.ru Instant Messengers bot API | ||
![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg) | ||
[![CircleCI](https://circleci.com/gh/mail-ru-im/bot-golang.svg?style=svg)](https://circleci.com/gh/mail-ru-im/bot-golang) | ||
# VK Teams Bot API for Golang | ||
[![Go](https://github.com/mail-ru-im/bot-golang/actions/workflows/go.yml/badge.svg)](https://github.com/mail-ru-im/bot-golang/actions/workflows/go.yml) | ||
[![codecov](https://codecov.io/github/mail-ru-im/bot-golang/graph/badge.svg?token=0HX8DY24SR)](https://codecov.io/github/mail-ru-im/bot-golang) | ||
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/mail-ru-im/bot-golang) | ||
![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg) | ||
|
||
- *Brand new Bot API!* | ||
|
||
- *Zero-configuration library* | ||
|
||
- *Simple and clear interface* | ||
### [<img src="logo_msg.png" width="16"> VK Teams API Specification](https://teams.vk.com/botapi/) | ||
|
||
## API specification: | ||
### [<img src="https://icq.com/cached/img/landing/icon_and_192.png" width="15"> ICQ New ](https://icq.com/botapi/) | ||
### [<img src="https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/e8/4f/1b/e84f1b57-206f-7750-ac5a-27f93ff4a0d8/icons-bundle.png/460x0w.png" width="16"> Myteam ](https://myteam.mail.ru/botapi/) | ||
## Getting started | ||
|
||
### [<img src="https://agent.mail.ru/img/agent2014/common/2x/button_logo.png" width="16"> Agent Mail.ru](https://agent.mail.ru/botapi/) | ||
* 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 | ||
|
@@ -24,8 +22,7 @@ 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. | ||
|
||
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 | ||
|
@@ -41,7 +38,7 @@ func main() { | |
log.Println("wrong token") | ||
} | ||
|
||
message := bot.NewTextMessage("[email protected]", "text") | ||
message := bot.NewTextMessage("[email protected]", "text") | ||
message.Send() | ||
} | ||
``` | ||
|
@@ -51,18 +48,13 @@ func main() { | |
You can create, edit and reply to messages like a piece of cake. | ||
|
||
```go | ||
message := bot.NewTextMessage("[email protected]", "text") | ||
message := bot.NewTextMessage("[email protected]", "text") | ||
message.Send() | ||
|
||
fmt.Println(message.MsgID) | ||
|
||
message.Text = "new text" | ||
|
||
message.Edit() | ||
// AWESOME! | ||
|
||
message.Reply("hey, what did you write before???") | ||
// SO HOT! | ||
message.Reply("I changed my text") | ||
``` | ||
|
||
### Subscribe events | ||
|
@@ -73,7 +65,7 @@ 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 awesome logic here | ||
// your logic here | ||
} | ||
``` | ||
|
||
|
@@ -83,7 +75,7 @@ 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://agent.mail.ru/bot/v1")) | ||
bot := botgolang.NewBot(BOT_TOKEN, botgolang.BotApiURL("https://vkteams.com/bot/v1")) | ||
``` | ||
And debug all api requests and responses: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
module github.com/gldmtr/bot-golang | ||
|
||
go 1.13 | ||
go 1.20 | ||
|
||
require ( | ||
github.com/hako/durafmt v0.0.0-20190612201238-650ed9f29a84 | ||
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b | ||
github.com/mailru/easyjson v0.7.7 | ||
github.com/sirupsen/logrus v1.9.3 | ||
github.com/stretchr/testify v1.7.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e | ||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect | ||
github.com/sirupsen/logrus v1.8.1 | ||
github.com/stretchr/testify v1.7.0 | ||
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
golang.org/x/sys v0.18.0 // indirect | ||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||
gopkg.in/yaml.v3 v3.0.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.