client

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BotUserID = ""

BotUserID is filled with the slack user id of the bot

View Source
var Channels map[string]string

Channels is a map of each channelsId and the name

View Source
var HTTPClient = &http.Client{
	Timeout: time.Second * 10,
}

default http client for this bot to use the default go-client with a Timeout

View Source
var InternalMessages = make(chan msg.Message, 50)

InternalMessages is internal queue of internal messages

View Source
var Users map[string]string

Users is a lookup from user-id to user-name

Functions

func GetBitbucketClient added in v1.6.0

func GetBitbucketClient(cfg config.Bitbucket) (*bitbucket.DefaultApiService, error)

GetBitbucketClient initialized a API client based on the given config

func GetChannel

func GetChannel(identifier string) (id string, name string)

GetChannel returns channel-id and channel-name by an identifier which can be an id or a name

func GetInteraction added in v1.3.0

func GetInteraction(ref msg.Ref, text string, command string, args ...string) *slack.ActionBlock

func GetJiraClient

func GetJiraClient(cfg *config.Jira) (*jira.Client, error)

GetJiraClient created a jira client based on github.com/andygrunwald/go-jira"

func GetSlackLink(name string, url string, args ...string) slack.AttachmentAction

func GetUser

func GetUser(identifier string) (id string, name string)

Types

type Slack

type Slack struct {
	*slack.Client
	RTM *slack.RTM
	// contains filtered or unexported fields
}

wrapper to the Slack client which also holds the RTM connection (optional) and all needed config

func GetSlackClient

func GetSlackClient(cfg config.Slack) *Slack

GetSlackClient establishes a RTM connection to the slack server

func (*Slack) AddReaction

func (s *Slack) AddReaction(reaction string, ref msg.Ref)

func (*Slack) RemoveReaction

func (s *Slack) RemoveReaction(reaction string, ref msg.Ref)

func (*Slack) ReplyError

func (s *Slack) ReplyError(ref msg.Ref, err error)

func (*Slack) SendMessage

func (s *Slack) SendMessage(ref msg.Ref, text string, options ...slack.MsgOption) string

SendMessage is the "slow" reply via POST request, needed for Attachment or MsgRef

func (*Slack) SendToUser

func (s *Slack) SendToUser(user string, text string)

SendToUser sends a message to any user via IM channel

type SlackClient

type SlackClient interface {
	// ReplyError Replies a error to the current channel/user/thread + log it!
	ReplyError(ref msg.Ref, err error)

	// SendMessage is the extended version of Reply and accepts any slack.MsgOption
	SendMessage(ref msg.Ref, text string, options ...slack.MsgOption) string

	// send a message to a user, using "@username or @U12334"
	SendToUser(user string, text string)

	RemoveReaction(reaction string, ref msg.Ref)
	AddReaction(reaction string, ref msg.Ref)
	GetReactions(item slack.ItemRef, params slack.GetReactionsParameters) ([]slack.ItemReaction, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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