slack

package
v0.0.0-...-5eac97b Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DMChannelList is a collection of the individual DM channels that Slab
	// has access to
	DMChannelList []Channel
	// ChannelList is a collectoin of the individual channels that Slab has
	// access to
	ChannelList []Channel
)
View Source
var (

	// Sent represents the NotifySent from the zendesk package
	Sent interface{}
	// NumTickets is the number of tickets processed on the last loop
	NumTickets int
	// LastProcessed is a timestamp of when the last loop was ran
	LastProcessed time.Time
)
View Source
var (

	// ChannelSelect represents if the configuration wizard user is currently
	// selecting a channel
	ChannelSelect bool
	// ZenAPI is the Zendesk API key received in the configuration wizard
	ZenAPI string
	// ZenUser is the Zendesk Username used to access the Zendesk API in the
	// configuration wizard
	ZenUser string
	// ZenURL is the Zendesk URL used to access the Zendesk API in the
	// configuration wizard
	ZenURL string
)
View Source
var (

	// Triager holds the User ID of the current person set as "Triager"
	Triager string
)

Functions

func AcknowledgeNewTicket

func AcknowledgeNewTicket(payload *slack.InteractionCallback)

AcknowledgeNewTicket generates a new Slack attachment to state that a user has acknowledged a ticket.

func AcknowledgeSLA

func AcknowledgeSLA(payload *slack.InteractionCallback)

AcknowledgeSLA generates a new Slack attachment to state that a user has acknowledged a ticket.

func AddChannel

func AddChannel(channel string, chantype int)

AddChannel takes a channel and a channel type and adds it to the corresponding list. Types: 1 = DM Channel, 2 = Channel

func AddChannelCallback

func AddChannelCallback(payload *slack.InteractionCallback)

AddChannelCallback takes the response from the `@slab add channel` command and adds a channel to the ChannelList variable

func ChannelSelectMessage

func ChannelSelectMessage()

ChannelSelectMessage takes a user string and sends that user a direct message asking for a channel to be selected that Slab will monitor/send alerts to.

func ChatUpdate

func ChatUpdate(
	payload *slack.InteractionCallback,
	attachment slack.Attachment,
)

ChatUpdate takes a channel ID, a timestamp and message text and updated the message in the given Slack channel at the given timestamp with the given message text. Currently, it also updates the attachment specifically for the Set message output.

func ConfigInProgressMessage

func ConfigInProgressMessage(user string)

ConfigInProgressMessage takes a user ID string and sends a message to that user letting them know that there's already a configuration wizard in progress to avoid overlap.

func ConfirmWizard

func ConfirmWizard()

ConfirmWizard sends a confirmation message to the user letting them know that the changes made will overwrite the current configuration.

func CreateTagDialog

func CreateTagDialog(payload *slack.InteractionCallback)

CreateTagDialog receives the payload from the incoming callback and opens a dialog box allowing the user to create a tag they want to be notified on.

func CreateTagMessage

func CreateTagMessage(user *slack.User)

CreateTagMessage responds to @slab tag create, taking the tag name provided and responds with the first step in the create tag config wizard

func DMAddChannel

func DMAddChannel(user string)

DMAddChannel shows a list of channels to the user that can be added to the ChannelList for Slab to operate in.,

func DeleteTag

func DeleteTag(payload *slack.InteractionCallback)

DeleteTag deletes a tag based on the tag ID provided

func DeleteTagMessage

func DeleteTagMessage(user *slack.User, id string)

DeleteTagMessage takes an id and deletes the corresponding tag in the database

func DiagMessage

func DiagMessage(user *slack.User)

DiagMessage sends a DM to requestor with the current state of SLA notifications for tickets

func GetChannel

func GetChannel(channel string) (chantype int)

GetChannel takes the event from RTM and determines if the channel is part of a DM with a user that just initiated Slab, or if it's in a Slab monitored channel.

func GetZendeskAPIKey

func GetZendeskAPIKey()

GetZendeskAPIKey is a step in the configuration wizard that asks the user to provide the API key to access Zendesk with.

func GetZendeskURL

func GetZendeskURL()

GetZendeskURL is a step in the configuration wizard that asks the user to provide a URL to their Zendesk instance.

func GetZendeskUser

func GetZendeskUser()

GetZendeskUser is a step in the configuration wizard that asks the user to provide the username to access Zendesk with.

func HelpMessage

func HelpMessage(user *slack.User) (message string)

HelpMessage responds to @slab help with a help message outlining all available commands

func HistoryMessage

func HistoryMessage(user *slack.User) (attachments []slack.Attachment)

HistoryMessage responds to @slab history with the last 10 commands that were run

func ListChannels

func ListChannels(user string)

ListChannels gets a list of every channel in the ChannelList and sends a DM to the user with that list

func ListTagMessage

func ListTagMessage(user *slack.User)

ListTagMessage grabs the tags stored in the database and outputs them to Slack in a DM

func LoadPrivateChannels

func LoadPrivateChannels()

LoadPrivateChannels asks the datastore for all channels marked private and adds those channels to the DMChannelList

func LoadPublicChannels

func LoadPublicChannels()

LoadPublicChannels asks the datastore for all channels not marked private and adds those channels to the ChannelList

func MoreInfoSLA

func MoreInfoSLA(payload *slack.InteractionCallback)

MoreInfoSLA grabs additional information from Zendesk using the information from the More Info button. It then sends an ephemeral message to the requester with additional Zendesk information.

func NewTicketMessage

func NewTicketMessage(tickets []Ticket, tag string) (newTickets []slack.Attachment, message string)

NewTicketMessage takes a slice of tickets that have been created in the last loop interval and sends the IDs and links to the tickets to the user currently set as triager.

func NextStep

func NextStep(msg string)

NextStep processes the current configuration wizard step and prepares the actions for the next step in the wizard.

func PrepSLANotification

func PrepSLANotification(ticket Ticket, notify int64, tag string, group string) (notification string, color string)

PrepSLANotification takes a given ticket and what notification level and returns a string to be sent to Slack.

func SLAMessage

func SLAMessage(ticket Ticket, color string, user string, uid int64, org string) (attachment slack.Attachment)

SLAMessage sends off the SLA notification to Slack using the configured API key

func SaveDialog

func SaveDialog(payload *slack.InteractionCallback)

SaveDialog takes the input collected from the Create Tag Dialog and sends the data to Postgres to be saved

func SendDirectMessage

func SendDirectMessage(message string, attachments []slack.Attachment, user string)

SendDirectMessage takes a message, an attachment and a user and sends a direct message to the user.

func SendEphemeralMessage

func SendEphemeralMessage(message string, attachment slack.Attachment, user string)

SendEphemeralMessage takes a message, attachment and a user ID and sends a message to that user ID.

func SendMessage

func SendMessage(message string, channel string, attachments []slack.Attachment)

SendMessage takes an attachment and message and composes a message to be sent to the configured Slack channel ID

func SetMessage

func SetMessage(user *slack.User) (attachment slack.Attachment)

SetMessage creates and sends a message to Slack with a menu attachment, allowing users to set the triager staff member.

func ShowConfigMessage

func ShowConfigMessage(user string)

ShowConfigMessage takes a user string and sends that user the value of the config.toml configuration file. Used for identifying configuration issues.

func StartSlack

func StartSlack(v string, key string)

StartSlack initializes a connection with the given slack instance, gets team information, and starts a Go channel with the Real Time Messaging API watcher.

func StartWizard

func StartWizard(user string)

StartWizard takes the user ID, sets the configUser and starts the ConfigSetupMessage function

func StatusMessage

func StatusMessage(user *slack.User) (attachments []slack.Attachment)

StatusMessage responds to @slab status with the version hash and current uptime for the Slab process

func UnknownCommandMessage

func UnknownCommandMessage(text string, user string)

UnknownCommandMessage sends a direct message to the user provided indicating that the command that they attempted is not a valid command.

func UnsetMessage

func UnsetMessage(user *slack.User) (attachment slack.Attachment)

UnsetMessage resets the Triager role to the slab bot.

func UpdateMessage

func UpdateMessage(ticket Ticket, user string, uid int64) (attachment slack.Attachment)

UpdateMessage sends a message to the channel indicating a ticket with a premium SLA tag associated with it has received an update. This functionality is a mirror of the official Zendesk > Slack integration.

func UpdateTag

func UpdateTag(payload *slack.InteractionCallback)

UpdateTag takes the input collected from the user and updates a tag based on the tag ID provided

func UpdateTagDialog

func UpdateTagDialog(payload *slack.InteractionCallback)

UpdateTagDialog receives the payload from the incoming callback and opens a dialog box allowing the user to update a tag they want to be notified on.

func UpdateTagMessage

func UpdateTagMessage(user *slack.User, id string)

UpdateTagMessage takes the id for a given tag and opens a dialog for updating the entry

func VerifyUser

func VerifyUser(user string) bool

VerifyUser takes a User ID string and runs the Slack GetUserInfo request. If the user exists, the function returns true.

func ViewConfig

func ViewConfig()

ViewConfig returns a direct message with the current configuration of Slab to the current active user.

func WhoIsMessage

func WhoIsMessage(user *slack.User) (attachment slack.Attachment)

WhoIsMessage creates and sends a Slack message that sends out the value of Triager.

Types

type Channel

type Channel struct {
	ID string
}

Channel represents an individual Slack channel, used either for DMs or public usage, in which Slab has access to.

type NotifySent

type NotifySent struct {
	ID     int
	Type   int64
	Expire time.Time
}

NotifySent is represetative of an individual ticket, what kind of notification was last sent for that ticket, and when the SLA breach time is.

type Ticket

type Ticket struct {
	ID          int
	Requester   int64
	Subject     string
	SLA         []interface{}
	Tags        []string
	Level       string
	Priority    interface{}
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Description string
}

Ticket represents an individual ticket to be used in SLAMessage and NewTicketMessage

Jump to

Keyboard shortcuts

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