Added VK part

This commit is contained in:
Artyom Belousov 2019-05-11 14:01:40 +03:00
parent 69d6808cd0
commit 657f967a49
5 changed files with 65 additions and 0 deletions

24
vk/message.go Normal file
View file

@ -0,0 +1,24 @@
package vk
import (
"math/rand"
"net/http"
"net/url"
"strconv"
"strings"
)
const VKURL = "https://api.vk.com/method/messages.send"
func Message(userId int64, message string) {
randomId := rand.Int31()
params := []string{
"access_token=" + TOKEN,
"peer_id=" + strconv.FormatInt(userId, 10),
"message=" + url.QueryEscape(message),
"v=5.95",
"random_id=" + strconv.FormatInt(int64(randomId), 10),
}
paramString := strings.Join(params, "&")
http.Get(VKURL + "?" + paramString)
}