Debian Codegraph @

/

debian golang-github-slack-go-slack 0.11.3-3debian golang-github-slack-go-slack-dev gomod github.com/slack-go/slack debiangogoinimakemakefilemarkdownshellyaml 217 files · 4645 symbols
View dependency graph

Depends on

README (full)

Slack API in Go Go Reference

This is the original Slack library for Go created by Norberto Lopes, transferred to a GitHub organization.

You can also chat with us on the #slack-go, #slack-go-ja Slack channel on the Gophers Slack.

logo

This library supports most if not all of the api.slack.com REST calls, as well as the Real-Time Messaging protocol over websocket, in a fully managed way.

Project Status

There is currently no major version released. Therefore, minor version releases may include backward incompatible changes.

See CHANGELOG.md or Releases for more information about the changes.

Installing

go get

$ go get -u github.com/slack-go/slack

Example

Getting all groups

import (
	"fmt"

	"github.com/slack-go/slack"
)

func main() {
	api := slack.New("YOUR_TOKEN_HERE")
	// If you set debugging, it will log all requests to the console
	// Useful when encountering issues
	// slack.New("YOUR_TOKEN_HERE", slack.OptionDebug(true))
	groups, err := api.GetUserGroups(slack.GetUserGroupsOptionIncludeUsers(false))
	if err != nil {
		fmt.Printf("%s\n", err)
		return
	}
	for _, group := range groups {
		fmt.Printf("ID: %s, Name: %s\n", group.ID, group.Name)
	}
}

Getting User Information

import (
    "fmt"

    "github.com/slack-go/slack"
)

func main() {
    api := slack.New("YOUR_TOKEN_HERE")
    user, err := api.GetUserInfo("U023BECGF")
    if err != nil {
	    fmt.Printf("%s\n", err)
	    return
    }
    fmt.Printf("ID: %s, Fullname: %s, Email: %s\n", user.ID, user.Profile.RealName, user.Profile.Email)
}

Minimal Socket Mode usage:

See https://github.com/slack-go/slack/blob/master/examples/socketmode/socketmode.go

Minimal RTM usage:

As mentioned in https://api.slack.com/rtm - for most applications, Socket Mode is a better way to communicate with Slack.

See https://github.com/slack-go/slack/blob/master/examples/websocket/websocket.go

Minimal EventsAPI usage:

See https://github.com/slack-go/slack/blob/master/examples/eventsapi/events.go

Socketmode Event Handler (Experimental)

When using socket mode, dealing with an event can be pretty lengthy as it requires you to route the event to the right place.

Instead, you can use SocketmodeHandler much like you use an HTTP handler to register which event you would like to listen to and what callback function will process that event when it occurs.

See ./examples/socketmode_handler/socketmode_handler.go

Contributing

You are more than welcome to contribute to this project. Fork and make a Pull Request, or create an Issue if you see any problem.

Before making any Pull Request please run the following:

make pr-prep

This will check/update code formatting, linting and then run all tests

License

BSD 2 Clause license

dir .github/
dir debian/
dir examples/
dir internal/
dir slackevents/
dir slacktest/
dir slackutilsx/
dir socketmode/
file .gitignore
file .golangci.yml
file CHANGELOG.md
file LICENSE
file Makefile
file README.md
file TODO.txt
file admin.go
file apps.go
file apps_test.go
file attachments.go
file attachments_test.go
file audit.go
file audit_test.go
file auth.go
file block.go
file block_action.go
file block_action_test.go
file block_context.go
file block_context_test.go
file block_conv.go
file block_divider.go
file block_divider_test.go
file block_element.go
file block_element_test.go
file block_file.go
file block_file_test.go
file block_header.go
file block_header_test.go
file block_image.go
file block_image_test.go
file block_input.go
file block_input_test.go
file block_object.go
file block_object_test.go
file block_rich_text.go
file block_rich_text_test.go
file block_section.go
file block_section_test.go
file block_test.go
file block_unknown.go
file bookmarks.go
file bookmarks_test.go
file bots.go
file bots_test.go
file channels.go
file chat.go
file chat_test.go
file comment.go
file conversation.go
file conversation_test.go
file dialog.go
file dialog_select.go
file dialog_select_test.go
file dialog_test.go
file dialog_text.go
file dialog_text_test.go
file dnd.go
file dnd_test.go
file emoji.go
file emoji_test.go
file errors.go
file files.go
file files_test.go
file go.mod
file go.sum
file groups.go
file history.go
file im.go
file info.go
file info_test.go
file interactions.go
file interactions_test.go
file item.go
file item_test.go
file logger.go
file logger_test.go
file logo.png
file messageID.go
file messageID_test.go
file messages.go
file messages_test.go
file metadata.go
file misc.go
file misc_test.go
file oauth.go
file pagination.go
file pins.go
file pins_test.go
file reactions.go
file reactions_test.go
file reminders.go
file reminders_test.go
file remotefiles.go
file remotefiles_test.go
file rtm.go
file search.go
file security.go
file security_test.go
file slack.go
file slack_test.go
file slash.go
file slash_test.go
file socket_mode.go
file stars.go
file stars_test.go
file status_code_error.go
file team.go
file team_test.go
file usergroups.go
file usergroups_test.go
file users.go
file users_test.go
file views.go
file views_test.go
file webhooks.go
file webhooks_test.go
file websocket.go
file websocket_channels.go
file websocket_desktop_notification.go
file websocket_dm.go
file websocket_dnd.go
file websocket_files.go
file websocket_groups.go
file websocket_internals.go
file websocket_managed_conn.go
file websocket_managed_conn_test.go
file websocket_misc.go
file websocket_mobile_in_app_notification.go
file websocket_pins.go
file websocket_reactions.go
file websocket_stars.go
file websocket_subteam.go
file websocket_teams.go
file workflow_step.go
file workflow_step_execute.go
file workflow_step_execute_test.go
file workflow_step_test.go