app

package
v0.0.0-...-f22367a Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IGNORECASE = "(?i)"
	F1         = regexp.MustCompile(IGNORECASE + "^\\.f1")
	LUNCH      = regexp.MustCompile(IGNORECASE + "^\\.lunch (.*)")
	LUNCHES    = regexp.MustCompile(IGNORECASE + "^\\.lunches")
	TACOS      = regexp.MustCompile(IGNORECASE + "^\\.tacos")
	QUESTION   = regexp.MustCompile(IGNORECASE + "^leif(.*)\\?")
	INSULT     = regexp.MustCompile(IGNORECASE + "^\\.insult (.*)")
	HELP       = regexp.MustCompile(IGNORECASE + "^\\.help")
	DECIDE     = regexp.MustCompile(IGNORECASE + "^\\.decide")
	FLIP       = regexp.MustCompile(IGNORECASE + "^\\.flip")
	TLDR       = regexp.MustCompile(IGNORECASE + "^\\.tldr (.*)")
	LOG        = regexp.MustCompile(IGNORECASE + "^\\.log (.*)")
	GITLAB     = regexp.MustCompile(IGNORECASE + "^\\.gitlab (.*)")
	POSTMORD   = regexp.MustCompile(IGNORECASE + "^\\.postmord (.*)")
	CORONA     = regexp.MustCompile(IGNORECASE + "^\\.corona (.*)")
	SUGGEST    = regexp.MustCompile(IGNORECASE + "^\\.suggest")
	JIRA       = regexp.MustCompile(IGNORECASE + "^\\.jira (.*)")
)

Functions

func GetLogRecords

func GetLogRecords(level string) string

GetLogRecords collects all logs for a specific log level

func HandleResponse

func HandleResponse(message interface{}, event *slack.MessageEvent, client *slack.Client, logger *logrus.Logger)

HandleResponse type checks the input message and sends the response to specified slack channel

func InitLogger

func InitLogger() *logrus.Logger

InitLogger creates a new logrus logger using a multiwriter and returns it

func Run

func Run()

Run loads configs, initializes handlers and starts Leif

Types

type Config

type Config struct {
	SlackToken    string `env:"SLACK_TOKEN,required"`
	GitLabToken   string `env:"GITLAB_TOKEN"`
	GitLabURL     string `env:"GITLAB_BASE_URL"`
	PostMordToken string `env:"POSTMORD_TOKEN"`
	JIRAURL       string `env:"JIRA_URL"`
	JIRAUsername  string `env:"JIRA_USERNAME"`
	JIRAToken     string `env:"JIRA_TOKEN"`
}

Config app configuration

func NewConfig

func NewConfig(logger *logrus.Logger) Config

NewConfig returns a new app configuration with ENVs loaded

type EventHandler

type EventHandler struct {
	Client *slack.Client
	Cache  cache.Cache
	Logger *logrus.Logger
	Config Config
}

EventHandler provides methods to handle slack events

func (EventHandler) Handle

func (e EventHandler) Handle(msg slack.RTMEvent)

Handle filters bot events and passes events to respective sub handler

type LogRecord

type LogRecord struct{ Time, Level, MSG string }

LogRecord holds a log record line from the logging file

Jump to

Keyboard shortcuts

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