db

package
v0.0.0-...-17582f3 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

DB is the Mongo database

Functions

func AddInstallation

func AddInstallation(installation Installation) error

AddInstallation adds an installation to the database

func AddUser

func AddUser(user User) error

AddUser adds a user

func Connect

func Connect()

Connect to the database

func GetConversationLastPostedOn

func GetConversationLastPostedOn(conversationID, userID string) time.Time

GetConversationLastPostedOn gets the Time that the conversation was last autoreplied to.

func SetConversationLastPostedOn

func SetConversationLastPostedOn(conversationID, userID string, lastPostedOn time.Time) error

SetConversationLastPostedOn sets the Time above ^

func SetReplyMode

func SetReplyMode(userID string, mode ReplyMode) error

SetReplyMode sets a user's reply mode

func SetUserDates

func SetUserDates(start, end time.Time, userID string) error

SetUserDates sets a user's start/end dates

func SetUserMessage

func SetUserMessage(userID string, message string) error

SetUserMessage sets a users message

func SetUserWhitelist

func SetUserWhitelist(userID string, whitelist []string) error

SetUserWhitelist sets a user's whitelist

func ToggleReplyActive

func ToggleReplyActive(userID string)

ToggleReplyActive toggle's the activity of a user's autoreply

Types

type Conversation

type Conversation struct {
	UserID         string `bson:"user_id"`
	ConversationID string `bson:"conversation_id"`
	LastPostedOn   int64  `bson:"last_posted_on"`
}

Conversation represents a single DM or channel.

type Installation

type Installation struct {
	TeamID string   `bson:"team_id"`
	Scopes []string `bson:"scopes"`
	Token  string   `bson:"token"`
	BotID  string   `bson:"bot_id"`
}

Installation represents an app installation

func GetInstallation

func GetInstallation(teamID string) (*Installation, error)

GetInstallation gets an installation

type ReplyMode

type ReplyMode string
const (
	ReplyModeManual   ReplyMode = "manual"
	ReplyModeDate     ReplyMode = "date"
	ReplyModePresence ReplyMode = "presence"
)

type User

type User struct {
	Token  string    `bson:"token"`
	UserID string    `bson:"user_id"`
	Reply  UserReply `bson:"reply"`
	Scopes []string  `bson:"scopes"`
	TeamID string    `bson:"team_id"`
}

User represents a DB user.

func GetUser

func GetUser(userID string) (*User, error)

GetUser gets a user based off of a user_id

func (User) ReplyShouldSend

func (user User) ReplyShouldSend() bool

ReplyShouldSend figures out whether or not the configured autoreply should be sent

type UserReply

type UserReply struct {
	Message   string    `bson:"message"`
	Active    bool      `bson:"active"`
	Whitelist []string  `bson:"whitelist"`
	Start     time.Time `bson:"start"`
	End       time.Time `bson:"end"`
	Mode      ReplyMode `bson:"mode"`
}

UserReply represents a user's chosen auto reply

Jump to

Keyboard shortcuts

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