go-slack-sdk-experimental

command module
v0.0.0-...-6c70892 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2021 License: MIT Imports: 8 Imported by: 0

README

Experimental Slack SDK in Go

This is an experimental Slack API client library.

Getting Started

Start a New Project
go mod init example.com/hello-slack
go get github.com/seratch/go-slack-sdk-experimental/webapi
Place main.go
package main

import (
	"encoding/json"
	"fmt"
	"github.com/seratch/go-slack-sdk-experimental/webapi"
	"github.com/seratch/go-slack-sdk-experimental/webapi/chat_postMessage"
	"io/ioutil"
	"net/url"
	"os"
)

func main() {
	token := os.Getenv("SLACK_BOT_TOKEN")
	client := webapi.NewClient(&token)
	data := url.Values{}
	data.Set("text", "Hi there!")
	data.Set("channel", "#random")
	resp, err := client.CallApi(chat_postMessage.ApiMethod, data)
	if err != nil {
		fmt.Println(fmt.Sprintf("HTTP error: %s", err))
		return
	}
	bytes, _ := ioutil.ReadAll(resp.Body)
	body, _ := chat_postMessage.UnmarshalChatPostMessage(bytes)
	bytesAgain, _ := json.Marshal(body)
	fmt.Println(string(bytesAgain))
	if !*body.Ok {
		fmt.Println(fmt.Sprintf("Slack error: %s", *body.Error))
	}
}
Run the App
export SLACK_BOT_TOKEN=xoxb-***
go run main.go

License

The MIT License

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
webapi module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL