models

package
v0.0.0-...-38c0829 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateMessageID

func GenerateMessageID() string

GenerateMessageID generates a random ID for a message.

func MessageTimestamp

func MessageTimestamp() int64

MessageTimestamp timestamps the message.

Types

type Action

type Action struct {
	Name             string            `mapstructure:"name" binding:"required"`
	Type             string            `mapstructure:"type" binding:"required"`
	URL              string            `mapstructure:"url"`
	Cmd              string            `mapstructure:"cmd"`
	Timeout          int               `mapstructure:"timeout"`
	QueryData        map[string]any    `mapstructure:"query_data"`
	CustomHeaders    map[string]string `mapstructure:"custom_headers"`
	Auth             []Auth            `mapstructure:"auth"`
	ExposeJSONFields map[string]string `mapstructure:"expose_json_fields"`
	Response         string            `mapstructure:"response"`
	LimitToRooms     []string          `mapstructure:"limit_to_rooms"` // deprecated
	OutputToRooms    []string          `mapstructure:"output_to_rooms"`
	Message          string            `mapstructure:"message"`
	Reaction         string            `mapstructure:"update_reaction" binding:"omitempty"`
}

Action defines the structure for Actions used within Rules.

type Auth

type Auth struct {
	Type string `mapstructure:"type"`
	User string `mapstructure:"user"`
	Pass string `mapstructure:"pass"`
}

Auth is a basic Auth data structure.

type Bot

type Bot struct {
	// Bot fields
	ID                            string            `mapstructure:"id"`
	Name                          string            `mapstructure:"name" binding:"required"`
	SlackToken                    string            `mapstructure:"slack_token"`
	SlackAppToken                 string            `mapstructure:"slack_app_token"`
	SlackSigningSecret            string            `mapstructure:"slack_signing_secret"`
	SlackEventsCallbackPath       string            `mapstructure:"slack_events_callback_path"`
	SlackInteractionsCallbackPath string            `mapstructure:"slack_interactions_callback_path"`
	SlackListenerPort             string            `mapstructure:"slack_listener_port"`
	DiscordToken                  string            `mapstructure:"discord_token"`
	DiscordServerID               string            `mapstructure:"discord_server_id"`
	GoogleChatProjectID           string            `mapstructure:"google_chat_project_id"`
	GoogleChatSubscriptionID      string            `mapstructure:"google_chat_subscription_id"`
	GoogleChatCredentials         string            `mapstructure:"google_chat_credentials"`
	GoogleChatForceReplyToThread  bool              `mapstructure:"google_chat_force_reply_to_thread"`
	TelegramToken                 string            `mapstructure:"telegram_token"`
	Users                         map[string]string `mapstructure:"slack_users"`
	UserGroups                    map[string]string `mapstructure:"slack_usergroups"`
	Rooms                         map[string]string `mapstructure:"slack_channels"`
	CLI                           bool              `mapstructure:"cli,omitempty"`
	CLIUser                       string            `mapstructure:"cli_user,omitempty"`
	Scheduler                     bool              `mapstructure:"scheduler,omitempty"`
	ChatApplication               string            `mapstructure:"chat_application" binding:"required"`
	Debug                         bool              `mapstructure:"debug,omitempty"`
	Metrics                       bool              `mapstructure:"metrics,omitempty"`
	CustomHelpText                string            `mapstructure:"custom_help_text,omitempty"`
	CustomHelpTextPrefix          string            `mapstructure:"custom_help_text_prefix,omitempty"`
	DisableNoMatchHelp            bool              `mapstructure:"disable_no_match_help,omitempty"`
	RespondToBots                 bool              `mapstructure:"respond_to_bots,omitempty"`
	// System
	RunChat      bool
	RunCLI       bool
	RunScheduler bool
}

Bot is a struct representation of bot.yml.

func NewBot

func NewBot() *Bot

NewBot creates a new Bot instance.

type DiscordConfig

type DiscordConfig struct {
}

DiscordConfig is a support struct that holds DiscordConfig specific data.

type HTTPResponse

type HTTPResponse struct {
	Status int
	Raw    string
	Data   any
}

HTTPResponse base HTTP response data structure.

type Message

type Message struct {
	ID                string
	Type              MessageType
	Service           MessageService
	ChannelID         string
	ChannelName       string
	Input             string
	Output            string
	Error             string
	Timestamp         string
	ThreadID          string
	ThreadTimestamp   string
	BotMentioned      bool
	DirectMessageOnly bool
	Debug             bool
	IsEphemeral       bool
	StartTime         int64
	EndTime           int64
	Attributes        map[string]string
	Vars              map[string]string
	OutputToRooms     []string
	OutputToUsers     []string
	Remotes           Remotes
	SourceLink        string
}

Message is the struct of the main data structure being passed around for each message generated.

func NewMessage

func NewMessage() Message

NewMessage creates a new message with initialized fields.

type MessageService

type MessageService int

MessageService is used to differentiate between different message services.

const (
	MsgServiceUnknown MessageService = iota
	MsgServiceChat
	MsgServiceCLI
	MsgServiceScheduler
)

Supported MessageServices.

type MessageType

type MessageType int

MessageType is used to differentiate between different message types.

const (
	MsgTypeUnknown MessageType = iota
	MsgTypeDirect
	MsgTypeChannel
	MsgTypePrivateChannel
)

Supported MessageTypes.

type Remotes

type Remotes struct {
	Slack   SlackConfig   `mapstructure:"slack" binding:"omitempty"`
	Discord DiscordConfig `mapstructure:"discord" binding:"omitempty"`
}

Remotes is a struct that holds data for various remotes.

type Rule

type Rule struct {
	Name               string   `mapstructure:"name" binding:"required"`
	Respond            string   `mapstructure:"respond" binding:"omitempty"`
	Hear               string   `mapstructure:"hear" binding:"omitempty"`
	Schedule           string   `mapstructure:"schedule"`
	Args               []string `mapstructure:"args" binding:"required"`
	DirectMessageOnly  bool     `mapstructure:"direct_message_only" binding:"required"`
	OutputToRooms      []string `mapstructure:"output_to_rooms" binding:"omitempty"`
	OutputToUsers      []string `mapstructure:"output_to_users" binding:"omitempty"`
	AllowUsers         []string `mapstructure:"allow_users" binding:"omitempty"`
	AllowUserIDs       []string `mapstructure:"allow_userids" binding:"omitempty"`
	AllowUserGroups    []string `mapstructure:"allow_usergroups" binding:"omitempty"`
	IgnoreUsers        []string `mapstructure:"ignore_users" binding:"omitempty"`
	IgnoreUserGroups   []string `mapstructure:"ignore_usergroups" binding:"omitempty"`
	StartMessageThread bool     `mapstructure:"start_message_thread" binding:"omitempty"`
	IgnoreThreads      bool     `mapstructure:"ignore_threads" binding:"omitempty"`
	FormatOutput       string   `mapstructure:"format_output"`
	HelpText           string   `mapstructure:"help_text"`
	IncludeInHelp      bool     `mapstructure:"include_in_help" binding:"required"`
	Active             bool     `mapstructure:"active" binding:"required"`
	Debug              bool     `mapstructure:"debug" binding:"required"`
	Actions            []Action `mapstructure:"actions" binding:"required"`
	Remotes            Remotes  `mapstructure:"remotes" binding:"omitempty"`
	Reaction           string   `mapstructure:"reaction" binding:"omitempty"`
	LimitToRooms       []string `mapstructure:"limit_to_rooms" binding:"omitempty"`
	// The following fields are not included in rule file
	RemoveReaction string
}

Rule is a struct representation of the .yml rules.

type ScriptResponse

type ScriptResponse struct {
	Status int
	Output string
}

ScriptResponse is the base response data type for Scripts.

type SlackConfig

type SlackConfig struct {
	Attachments []slack.Attachment `mapstructure:"attachments"`
}

SlackConfig is a support struct that holds Slack specific data.

Jump to

Keyboard shortcuts

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