model

package
v1.4.22 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEndSchedule          = errors.New("end of schedule")
	ErrInvalidSchedulerType = errors.New("invalid scheduler type")
)
View Source
var ErrConversationStatusValidationFailed = errors.New("conversation status validation failed")

Functions

This section is empty.

Types

type ActionType

type ActionType int
const (
	ActionTypeUnknown ActionType = iota
	ActionTypeDelete
)

type ConversationID

type ConversationID string

func NewConversationID

func NewConversationID(prefix, sourceID string) ConversationID

func (ConversationID) SourceID

func (c ConversationID) SourceID() string

func (ConversationID) String

func (c ConversationID) String() string

type ConversationStatus

type ConversationStatus struct {
	ConversationID ConversationID
	Type           ConversationStatusType
}

func (*ConversationStatus) Validate

func (m *ConversationStatus) Validate() error

type ConversationStatusType

type ConversationStatusType int
const (
	ConversationStatusTypeNeutral ConversationStatusType = iota
	ConversationStatusTypeShopping
	ConversationStatusTypeShoppingAdd
	ConversationStatusTypeReminderAdd
)

type DailyScheduler added in v1.1.0

type DailyScheduler struct {
	Time time.Time
}

func (*DailyScheduler) Next added in v1.1.0

func (s *DailyScheduler) Next(t time.Time) (time.Time, error)

func (*DailyScheduler) String added in v1.1.0

func (s *DailyScheduler) String() string

func (*DailyScheduler) UIText added in v1.1.0

func (s *DailyScheduler) UIText() string

type Event

type Event struct {
	*linebot.Event
	Status *ConversationStatus
}

func (*Event) ConversationID

func (e *Event) ConversationID() ConversationID

ConversationID returns conversation ID.

func (*Event) FilterText

func (e *Event) FilterText(target string) bool

FilterText returns true if Event.Message contains target text.

func (*Event) HandleTypeMessage

func (e *Event) HandleTypeMessage(ctx context.Context, f func(context.Context, *Event) error) error

func (*Event) HandleTypePostback

func (e *Event) HandleTypePostback(ctx context.Context, f func(context.Context, *Event) error) error

func (*Event) ReadTextLines

func (e *Event) ReadTextLines() []string

ReadTextLines reads text lines from Event.Message and trim spaces per line.

func (*Event) SetStatus added in v1.2.5

func (e *Event) SetStatus(st ConversationStatusType)

type Executor added in v1.1.0

type Executor struct {
	Type ExecutorType
}

type ExecutorType added in v1.1.0

type ExecutorType int
const (
	ExecutorTypeShoppingList ExecutorType = iota + 1
)

func (ExecutorType) String added in v1.1.0

func (t ExecutorType) String() string

func (ExecutorType) UIText added in v1.1.0

func (t ExecutorType) UIText() string

type Item

type Item struct {
	Indexes []int
	Name    []string
	Action  ActionType
}

func (*Item) UniqueIndexes

func (i *Item) UniqueIndexes() []int

type ListType

type ListType int
const (
	ListTypeDotted ListType = iota
	ListTypeOrdered
)

type OneshotScheduler added in v1.1.0

type OneshotScheduler struct {
	Time time.Time
}

func (*OneshotScheduler) Next added in v1.1.0

func (s *OneshotScheduler) Next(t time.Time) (time.Time, error)

func (*OneshotScheduler) String added in v1.1.0

func (s *OneshotScheduler) String() string

func (*OneshotScheduler) UIText added in v1.1.0

func (s *OneshotScheduler) UIText() string

type ReminderItem added in v1.1.0

type ReminderItem struct {
	ID             ReminderItemID
	ConversationID ConversationID
	Scheduler      Scheduler
	Executor       *Executor
}

func NewReminderItem added in v1.2.6

func NewReminderItem(conversationID ConversationID, scheduler Scheduler, executor *Executor) *ReminderItem

func (ReminderItem) IDJSON added in v1.1.0

func (r ReminderItem) IDJSON() *ReminderItemIDJSON

type ReminderItemID added in v1.1.0

type ReminderItemID string

type ReminderItemIDJSON added in v1.1.0

type ReminderItemIDJSON struct {
	ConversationID string `json:"conversation_id"`
	ItemID         string `json:"item_id"`
}

type ReminderItems added in v1.1.0

type ReminderItems []*ReminderItem

func (ReminderItems) FilterNextSchedule added in v1.1.0

func (l ReminderItems) FilterNextSchedule(t time.Time, d time.Duration) ReminderItems

func (ReminderItems) Print added in v1.1.0

func (l ReminderItems) Print(typ ListType) string

type ReminderReplyType added in v1.1.0

type ReminderReplyType int
const (
	ReminderReplyTypeAll ReminderReplyType = iota
	ReminderReplyTypeEmptyList
)

type Scheduler added in v1.1.0

type Scheduler interface {
	// String returns a serialized schedule settings.
	String() string
	// UIText returns a text for UI.
	UIText() string
	// Next returns next scheduled time or ErrEndSchedule.
	Next(t time.Time) (time.Time, error)
}

func ParseScheduler added in v1.1.0

func ParseScheduler(serialized string) (Scheduler, error)

type ShoppingItem

type ShoppingItem struct {
	ID             string
	Name           string
	Quantity       int
	ConversationID ConversationID
	CreatedAt      int64
	Order          int
}

func NewShoppingItem added in v1.2.11

func NewShoppingItem(conversationID ConversationID, name string, quantity, order int, createdAt time.Time) *ShoppingItem

func (*ShoppingItem) Validate

func (m *ShoppingItem) Validate() error

type ShoppingItems

type ShoppingItems []*ShoppingItem

func (ShoppingItems) FilterByNames

func (l ShoppingItems) FilterByNames(names []string) ShoppingItems

func (ShoppingItems) Print

func (l ShoppingItems) Print(typ ListType) string

type ShoppingReplyType

type ShoppingReplyType int
const (
	ShoppingReplyTypeAll ShoppingReplyType = iota
	ShoppingReplyTypeEmptyList
	ShoppingReplyTypeWithoutView
)

Jump to

Keyboard shortcuts

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