simba

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

README

samba

Kona like application made with <3 in Paris

Documentation

Overview

*

  • File : config.go
  • Author : Alexandre Saison <alexandre.saison@inarix.com>
  • Date : 08.11.2021
  • Last Modified Date: 14.11.2021
  • Last Modified By : Alexandre Saison <alexandre.saison@inarix.com>

*

  • File : db.go
  • Author : Alexandre Saison <alexandre.saison@inarix.com>
  • Date : 14.11.2021
  • Last Modified Date: 16.11.2021
  • Last Modified By : Alexandre Saison <alexandre.saison@inarix.com>

*

  • File : scheduler.go
  • Author : Alexandre Saison <alexandre.saison@inarix.com>
  • Date : 08.11.2021
  • Last Modified Date: 14.11.2021
  • Last Modified By : Alexandre Saison <alexandre.saison@inarix.com>

*

  • File : slack.go
  • Author : Alexandre Saison <alexandre.saison@inarix.com>
  • Date : 08.11.2021
  • Last Modified Date: 14.11.2021
  • Last Modified By : Alexandre Saison <alexandre.saison@inarix.com>

*

  • File : structs.go
  • Author : Alexandre Saison <alexandre.saison@inarix.com>
  • Date : 14.11.2021
  • Last Modified Date: 14.11.2021
  • Last Modified By : Alexandre Saison <alexandre.saison@inarix.com>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddingContextAuthor

func AddingContextAuthor(authorName string) *slack.ContextBlock

func ContextInputText

func ContextInputText() *slack.InputBlock

func DownloadFile

func DownloadFile(filepath string, url string, overide bool) error

DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory.

func FetchRelatedGif

func FetchRelatedGif(buzzWord string) (string, string, error)

@params buzzWord: string @returns title:string, url:string, err:error

func FetchUserById

func FetchUserById(slackClient *slack.Client, userId string) (*slack.User, error)

func FetchUsersFromChannel

func FetchUsersFromChannel(slackClient *slack.Client, channelId string) (*slack.Channel, []*slack.User, error)

func GenerateBuzzWords

func GenerateBuzzWords() []string

func GenerateRandomIndexBuzzWord

func GenerateRandomIndexBuzzWord(words []string) int

func HasAlreadySetMood

func HasAlreadySetMood(dbClient *gorm.DB, slackClient *slack.Client, userID, threadTS string) (bool, error)

func InitDbClient

func InitDbClient(dbHost, dbUser, dbPassword, dbName string, migrate bool) *gorm.DB

func InitScheduler

func InitScheduler(dbClient *gorm.DB, client *slack.Client, config *Config, threadTS string) (*gocron.Scheduler, *gocron.Job, error)

func IsUserAdmin

func IsUserAdmin(dbClient *gorm.DB, userId string) (bool, error)

func SendImage

func SendImage(client *slack.Client, channelId, filePath, title, comment string) error

func SendSlackBlocks

func SendSlackBlocks(client *slack.Client, config *Config, dbClient *gorm.DB, threadTS string, firstPrint bool) (string, error)

func SendSlackMessage

func SendSlackMessage(client *slack.Client, config *Config, message string) (string, error)

func SendSlackMessageToUser

func SendSlackMessageToUser(client *slack.Client, userId, message string) (string, error)

func SendSlackTSMessage

func SendSlackTSMessage(client *slack.Client, config *Config, message string, ts string) (string, error)

func UpdateMessage

func UpdateMessage(client *slack.Client, config *Config, dbClient *gorm.DB, threadTS string, firstPrint bool) (string, error)

Types

type Config

type Config struct {
	CHANNEL_ID            string
	SLACK_API_TOKEN       string
	APP_PORT              string
	CRON_EXPRESSION       string
	SLACK_MESSAGE_CHANNEL chan string
	DB                    *DbConfig
}

func InitConfig

func InitConfig(isTesting bool) (*Config, error)

type DailyMood

type DailyMood struct {
	gorm.Model
	CreatedAt time.Time
	UserID    uint
	Mood      string
	Feeling   string
	ThreadTS  string
	Context   string
}

func FetchMoodFromThreadTS

func FetchMoodFromThreadTS(dbClient *gorm.DB, threadTS string, userId uint) (*DailyMood, error)

func HandleAddDailyMood

func HandleAddDailyMood(dbClient *gorm.DB, slackClient *slack.Client, channelId, userId, userName, mood, threadTS string) (*DailyMood, error)

func UpdateMood

func UpdateMood(dbClient *gorm.DB, sourceMood *DailyMood, feeling *string, context *string) (*DailyMood, error)

func UpdateMoodById

func UpdateMoodById(dbClient *gorm.DB, moodId string, feeling *string, context *string) (*DailyMood, error)

type DbConfig

type DbConfig struct {
	Username string
	Password string
	Host     string
	Name     string
}

type ErrMoodAlreadySet

type ErrMoodAlreadySet struct {
	UserId string
}

func NewErrMoodAlreadySet

func NewErrMoodAlreadySet(userId string) *ErrMoodAlreadySet

func (*ErrMoodAlreadySet) Error

func (err *ErrMoodAlreadySet) Error() string

type ErrNoActionFound

type ErrNoActionFound struct {
	ActionID    string
	ActionValue string
}

------------------------------//

func NewErrNoActionFound

func NewErrNoActionFound(actionId, actionValue string) *ErrNoActionFound

func (*ErrNoActionFound) Error

func (err *ErrNoActionFound) Error() string

type GiphyResponse

type GiphyResponse struct {
	Meta       giphyResponseMeta       `json:"meta"`
	Pagination giphyResponsePagination `json:"pagination,omitempty"`
	Data       []giphyResponseData     `json:"data,omitempty"`
}

type SlackVerificationStruct

type SlackVerificationStruct struct {
	Type      string `json:"type"`
	Token     string `json:"token"`
	Challenge string `json:"challenge"`
}

type User

type User struct {
	gorm.Model
	SlackUserID    string
	SlackChannelId string
	IsManager      bool
	Username       string      `gorm:"unique"`
	Moods          []DailyMood `gorm:"many2many:has_moods"`
}

func FechCurrent

func FechCurrent(dbClient *gorm.DB, slackClient *slack.Client, slackUserId string) (*User, *slack.User, error)

func FetchAllDailyMoodsByThreadTS

func FetchAllDailyMoodsByThreadTS(dbClient *gorm.DB, threadTS string) ([]*User, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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