types

package
v1.9.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ReactionActionTypeReminderRequest = ReactionActionType(string(database.MessageTypeReminderRequest))
	ReactionActionTypeReminder        = ReactionActionType(string(database.MessageTypeReminder))
	ReactionActionTypeReminderSuccess = ReactionActionType(string(database.MessageTypeReminderSuccess))
	ReactionActionTypeDailyReminder   = ReactionActionType(string(database.MessageTypeDailyReminder))
	ReactionActionTypeAll             = ReactionActionType("")
)

Variables

View Source
var ReactionsReminder = []string{"✅", "🔄", "➕", "1️⃣", "4️⃣", "🔟"}
View Source
var ReactionsReminderRequest = []string{"❌", "➕", "1️⃣", "4️⃣"}

Functions

This section is empty.

Types

type Action

type Action struct {
	Name     string         // Name of the action just for displaying
	Examples []string       // Example commands to trigger the action
	Regex    *regexp.Regexp // Regex the message must match to trigger the action
	Action   func(evt *MessageEvent, channel *database.Channel) error
}

Action defines an action the user can perform

type BotInfo

type BotInfo struct {
	BotName string
}

BotInfo holds general information about the bot account

type DataResponse

type DataResponse struct {
	Status string      `json:"status" example:"success"`
	Data   interface{} `json:"data"`
}

DataResponse is the default response for data

type Database

type Database interface {
	// Reminders
	GetPendingReminders(channel *database.Channel) ([]database.Reminder, error)
	GetReminderForChannelIDByID(channelID string, reminderID int) (*database.Reminder, error)

	AddReminder(remindTime time.Time, message string, active bool, repeatInterval uint64, channel *database.Channel) (*database.Reminder, error)
	AddOrUpdateThirdPartyResourceReminder(remindTime time.Time, message string, channelID uint, thirdPartyResourceID uint, thirdPartyResourceIdentifier string) (*database.Reminder, error)

	UpdateReminder(reminderID uint, remindTime time.Time, repeatInterval uint64, repeatTimes uint64) (*database.Reminder, error)

	DeleteReminder(reminderID uint) (*database.Reminder, error)
	// Messages
	AddMessage(message *database.Message) (*database.Message, error)

	GetMessageByExternalID(externalID string) (*database.Message, error)
	GetMessagesByReminderID(id uint) ([]*database.Message, error)
	GetLastMessageByTypeForReminder(msgType database.MessageType, reminderID uint) (*database.Message, error)

	AddMessageFromMatrix(id string, timestamp int64, content *event.MessageEventContent, reminder *database.Reminder, msgType database.MessageType, channel *database.Channel) (*database.Message, error)

	// Channels
	GetChannel(id uint) (*database.Channel, error)
	GetChannelByUserIdentifier(userID string) (*database.Channel, error)
	GetChannelsByUserIdentifier(userID string) ([]database.Channel, error)
	GetChannelsByChannelIdentifier(channelID string) ([]database.Channel, error)
	GetChannelByUserAndChannelIdentifier(userID string, channelID string) (*database.Channel, error)
	GetChannelList() ([]database.Channel, error)
	ChannelCount() (int64, error)

	GenerateNewCalendarSecret(channel *database.Channel) error
	UpdateChannel(channelID uint, timeZone string, dailyReminder *uint, role *roles.Role) (*database.Channel, error)
	ChannelSaveChanges(channel *database.Channel) error

	AddChannel(userID, channelID string, role roles.Role) (*database.Channel, error)

	CleanAdminChannels(keep []*database.Channel) error
	DeleteChannel(channel *database.Channel) error
	DeleteChannelsFromUser(userID string) error

	// Events
	IsEventKnown(externalID string) (bool, error)

	AddEvent(event *database.Event) (*database.Event, error)

	// Blocklist
	IsUserBlocked(userID string) (bool, error)
	GetBlockedUserList() ([]database.Blocklist, error)

	AddUserToBlocklist(userID string, reason string) error

	RemoveUserFromBlocklist(userID string) error

	SQLDB() (*sql.DB, error)

	// ThirdPartyResources
	GetThirdPartyResources(resourceType database.ThirdPartyResourceType) ([]database.ThirdPartyResource, error)
	GetThirdPartyResourcesByChannel(channelID uint) ([]database.ThirdPartyResource, error)
	AddThirdPartyResource(resource *database.ThirdPartyResource) (*database.ThirdPartyResource, error)
	DeleteThirdPartyResource(id uint) error
}

Database defines an interface for a data storage provider

type MessageErrorResponse

type MessageErrorResponse struct {
	Message string `json:"message" example:"Unauthenticated"`
	Status  string `json:"status" example:"error"`

} // @name ErrorResponse

MessageErrorResponse is a default response

type MessageEvent

type MessageEvent struct {
	Event       *event.Event
	Content     *event.MessageEventContent
	IsEncrypted bool
}

MessageEvent holds data from a message event

type MessageSuccessResponse

type MessageSuccessResponse struct {
	Message string `json:"message" example:"Inserted new reminder"`
	Status  string `json:"status" example:"success"`

} // @name SuccessResponse

MessageSuccessResponse is a default response

type Messenger

type Messenger interface {
	SendReplyToEvent(msg string, replyEvent *MessageEvent, channel *database.Channel, msgType database.MessageType) (resp *mautrix.RespSendEvent, err error)
	CreateChannel(userID string) (*mautrix.RespCreateRoom, error)
	SendFormattedMessage(msg, msgFormatted string, channel *database.Channel, msgType database.MessageType, relatedReminderID uint) (resp *mautrix.RespSendEvent, err error)
	DeleteMessage(messageID, roomID string) error
	SendNotice(msg, roomID string) (resp *mautrix.RespSendEvent, err error)
	SendReaction(reaction string, toMessage string, channel *database.Channel) (resp *mautrix.RespSendEvent, err error)
}

Messenger defines an interface for interacting with matrix messages

type ReactionAction

type ReactionAction struct {
	Name   string   // Name of the action just for displaying
	Keys   []string // The key the reaction must match
	Type   ReactionActionType
	Action func(message *database.Message, content *event.ReactionEventContent, evt *event.Event, channel *database.Channel) error
}

ReactionAction defines an action performed on receiving a reaction

type ReactionActionType

type ReactionActionType string

ReactionActionType defines types of reaction actions

func (*ReactionActionType) HumanReadable

func (reactionActionType *ReactionActionType) HumanReadable() string

type ReplyAction

type ReplyAction struct {
	Name         string                 // Name of the action just for displaying
	Examples     []string               // Example commands to trigger the action
	Regex        *regexp.Regexp         // Regex the message must match to trigger the action
	ReplyToTypes []database.MessageType // Kind of message the reply is for
	Action       func(evt *MessageEvent, channel *database.Channel, replyMessage *database.Message) error
}

ReplyAction defines actions that are performed on replies

Jump to

Keyboard shortcuts

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