summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/SevereCloud/vksdk/v2/api/execute.go
diff options
context:
space:
mode:
authorIvanik <ivan170102@gmail.com>2021-01-29 04:25:14 +0500
committerGitHub <noreply@github.com>2021-01-29 00:25:14 +0100
commit8764be74616bde87bbbf6c32901cd9f43264d1e0 (patch)
tree88902ba17d6a6d245cadb7e0b277bee7ef424f99 /vendor/github.com/SevereCloud/vksdk/v2/api/execute.go
parent5dd15ef8e716c65accb6cd021095c0e19913d55f (diff)
downloadmatterbridge-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/execute.go')
-rw-r--r--vendor/github.com/SevereCloud/vksdk/v2/api/execute.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/github.com/SevereCloud/vksdk/v2/api/execute.go b/vendor/github.com/SevereCloud/vksdk/v2/api/execute.go
new file mode 100644
index 00000000..5bee205a
--- /dev/null
+++ b/vendor/github.com/SevereCloud/vksdk/v2/api/execute.go
@@ -0,0 +1,52 @@
+package api
+
+import "encoding/json"
+
+// ExecuteWithArgs a universal method for calling a sequence of other methods
+// while saving and filtering interim results.
+//
+// The Args map variable allows you to retrieve the parameters passed during
+// the request and avoids code formatting.
+//
+// return Args.code; // return parameter "code"
+// return Args.v; // return parameter "v"
+//
+// https://vk.com/dev/execute
+func (vk *VK) ExecuteWithArgs(code string, params Params, obj interface{}) error {
+ token := vk.getToken()
+
+ reqParams := Params{
+ "code": code,
+ "access_token": token,
+ "v": vk.Version,
+ }
+
+ resp, err := vk.Handler("execute", params, reqParams)
+
+ jsonErr := json.Unmarshal(resp.Response, &obj)
+ if jsonErr != nil {
+ return jsonErr
+ }
+
+ if resp.ExecuteErrors != nil {
+ return &resp.ExecuteErrors
+ }
+
+ return err
+}
+
+// Execute a universal method for calling a sequence of other methods while
+// saving and filtering interim results.
+//
+// https://vk.com/dev/execute
+func (vk *VK) Execute(code string, obj interface{}) error {
+ return vk.ExecuteWithArgs(code, Params{}, obj)
+}
+
+func fmtBool(value bool) string {
+ if value {
+ return "1"
+ }
+
+ return "0"
+}