diff options
author | Ivanik <ivan170102@gmail.com> | 2021-01-29 04:25:14 +0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-29 00:25:14 +0100 |
commit | 8764be74616bde87bbbf6c32901cd9f43264d1e0 (patch) | |
tree | 88902ba17d6a6d245cadb7e0b277bee7ef424f99 /vendor/github.com/SevereCloud/vksdk/v2/api/utils.go | |
parent | 5dd15ef8e716c65accb6cd021095c0e19913d55f (diff) | |
download | matterbridge-msglm-8764be74616bde87bbbf6c32901cd9f43264d1e0.tar.gz matterbridge-msglm-8764be74616bde87bbbf6c32901cd9f43264d1e0.tar.bz2 matterbridge-msglm-8764be74616bde87bbbf6c32901cd9f43264d1e0.zip |
Add vk bridge (#1372)
* Add vk bridge
* Vk bridge attachments
* Vk bridge forwarded messages
* Vk bridge sample config and code cleanup
* Vk bridge add vendor
* Vk bridge message edit
* Vk bridge: fix fetching names of other bots
* Vk bridge: code cleanup
* Vk bridge: fix shadows declaration
* Vk bridge: remove UseFileURL
Diffstat (limited to 'vendor/github.com/SevereCloud/vksdk/v2/api/utils.go')
-rw-r--r-- | vendor/github.com/SevereCloud/vksdk/v2/api/utils.go | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/vendor/github.com/SevereCloud/vksdk/v2/api/utils.go b/vendor/github.com/SevereCloud/vksdk/v2/api/utils.go new file mode 100644 index 00000000..63508fe2 --- /dev/null +++ b/vendor/github.com/SevereCloud/vksdk/v2/api/utils.go @@ -0,0 +1,105 @@ +package api // import "github.com/SevereCloud/vksdk/v2/api" + +import ( + "encoding/json" + + "github.com/SevereCloud/vksdk/v2/object" +) + +// UtilsCheckLinkResponse struct. +type UtilsCheckLinkResponse object.UtilsLinkChecked + +// UtilsCheckLink checks whether a link is blocked in VK. +// +// https://vk.com/dev/utils.checkLink +func (vk *VK) UtilsCheckLink(params Params) (response UtilsCheckLinkResponse, err error) { + err = vk.RequestUnmarshal("utils.checkLink", &response, params) + return +} + +// UtilsDeleteFromLastShortened deletes shortened link from user's list. +// +// https://vk.com/dev/utils.deleteFromLastShortened +func (vk *VK) UtilsDeleteFromLastShortened(params Params) (response int, err error) { + err = vk.RequestUnmarshal("utils.deleteFromLastShortened", &response, params) + return +} + +// UtilsGetLastShortenedLinksResponse struct. +type UtilsGetLastShortenedLinksResponse struct { + Count int `json:"count"` + Items []object.UtilsLastShortenedLink `json:"items"` +} + +// UtilsGetLastShortenedLinks returns a list of user's shortened links. +// +// https://vk.com/dev/utils.getLastShortenedLinks +func (vk *VK) UtilsGetLastShortenedLinks(params Params) (response UtilsGetLastShortenedLinksResponse, err error) { + err = vk.RequestUnmarshal("utils.getLastShortenedLinks", &response, params) + return +} + +// UtilsGetLinkStatsResponse struct. +type UtilsGetLinkStatsResponse object.UtilsLinkStats + +// UtilsGetLinkStats returns stats data for shortened link. +// +// extended=0 +// +// https://vk.com/dev/utils.getLinkStats +func (vk *VK) UtilsGetLinkStats(params Params) (response UtilsGetLinkStatsResponse, err error) { + err = vk.RequestUnmarshal("utils.getLinkStats", &response, params, Params{"extended": false}) + + return +} + +// UtilsGetLinkStatsExtendedResponse struct. +type UtilsGetLinkStatsExtendedResponse object.UtilsLinkStatsExtended + +// UtilsGetLinkStatsExtended returns stats data for shortened link. +// +// extended=1 +// +// https://vk.com/dev/utils.getLinkStats +func (vk *VK) UtilsGetLinkStatsExtended(params Params) (response UtilsGetLinkStatsExtendedResponse, err error) { + err = vk.RequestUnmarshal("utils.getLinkStats", &response, params, Params{"extended": true}) + + return +} + +// UtilsGetServerTime returns the current time of the VK server. +// +// https://vk.com/dev/utils.getServerTime +func (vk *VK) UtilsGetServerTime(params Params) (response int, err error) { + err = vk.RequestUnmarshal("utils.getServerTime", &response, params) + return +} + +// UtilsGetShortLinkResponse struct. +type UtilsGetShortLinkResponse object.UtilsShortLink + +// UtilsGetShortLink allows to receive a link shortened via vk.cc. +// +// https://vk.com/dev/utils.getShortLink +func (vk *VK) UtilsGetShortLink(params Params) (response UtilsGetShortLinkResponse, err error) { + err = vk.RequestUnmarshal("utils.getShortLink", &response, params) + return +} + +// UtilsResolveScreenNameResponse struct. +type UtilsResolveScreenNameResponse object.UtilsDomainResolved + +// UtilsResolveScreenName detects a type of object (e.g., user, community, application) and its ID by screen name. +// +// https://vk.com/dev/utils.resolveScreenName +func (vk *VK) UtilsResolveScreenName(params Params) (response UtilsResolveScreenNameResponse, err error) { + rawResponse, err := vk.Request("utils.resolveScreenName", params) + // Если короткое имя screen_name не занято, то будет возвращён пустой объект. + if err != nil || string(rawResponse) == "[]" { + return + } + + err = json.Unmarshal(rawResponse, &response) + + return +} |