Documentation
ΒΆ
Index ΒΆ
- Constants
- Variables
- func FormatTestError(expect, have any) string
- func IsURL(str string) bool
- func ParseTemplate(texts []string) string
- func RunAction(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- func RunActionButton(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- func RunActionFile(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- func RunActionInput(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- func RunActionRoom(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- func RunActionText(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- func RunActionWait(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- func SendInteraction(channel IChannel, interaction *Interaction) error
- func SetCustomActions(custom ActionsMap)
- func StartConsumer(consumer IConsumer, channels []IChannel)
- type ActionsMap
- type Broadcast
- type Channel
- type ChatGPTAssistantConsumer
- type ChatGPTConsumer
- type Consumer
- type DiscordChannel
- func (channel *DiscordChannel) Close() error
- func (channel *DiscordChannel) GetChannel() *Channel
- func (channel *DiscordChannel) Next()
- func (channel *DiscordChannel) RespondInteraction(in *discordgo.Interaction)
- func (channel *DiscordChannel) SendAudio(interaction *Interaction) error
- func (channel *DiscordChannel) SendButton(interaction *Interaction) error
- func (channel *DiscordChannel) SendDocument(interaction *Interaction) error
- func (channel *DiscordChannel) SendFile(sessionID, text, path string) error
- func (channel *DiscordChannel) SendImage(interaction *Interaction) error
- func (channel *DiscordChannel) SendText(interaction *Interaction) error
- func (channel *DiscordChannel) SendVideo(interaction *Interaction) error
- type File
- type FileType
- type Flow
- func (flow *Flow) AddResponse(interaction *Interaction)
- func (flow *Flow) Ended() bool
- func (flow *Flow) GetLastResponse() *Interaction
- func (flow *Flow) GetLastResponseText() string
- func (flow *Flow) Next(interaction *Interaction) error
- func (flow *Flow) NoHasNext() bool
- func (flow *Flow) Start() error
- type FlowPersist
- type Guest
- type GuestRoomRelation
- type IChannel
- type IConsumer
- type IFile
- type Interaction
- func NewInteractionMessageButton(channel IChannel, destination *Who, sender *Who, buttons []string, text string) *Interaction
- func NewInteractionMessageFile(channel IChannel, destination *Who, sender *Who, path string, text string) *Interaction
- func NewInteractionMessageText(channel IChannel, destination *Who, sender *Who, text string) *Interaction
- type InteractionParameters
- type InteractionType
- type JourneyConsumer
- type MemoryFlowPersist
- type Room
- type RoomGuests
- type RoomManager
- func (manager *RoomManager) AddChannel(channel IChannel) uuid.UUID
- func (manager *RoomManager) AddGuest(roomID uuid.UUID, guest *Guest) error
- func (manager *RoomManager) AddInteraction(interaction *Interaction) error
- func (manager *RoomManager) AddRoom(room *Room) error
- func (manager *RoomManager) GetRoom(roomID uuid.UUID) *Room
- func (manager *RoomManager) ListenChannel(channel IChannel)
- type Step
- type StepParameters
- type Steps
- type TelegramChannel
- func (channel *TelegramChannel) Close() error
- func (channel *TelegramChannel) GetChannel() *Channel
- func (channel *TelegramChannel) Next()
- func (channel *TelegramChannel) SendAudio(interaction *Interaction) error
- func (channel *TelegramChannel) SendButton(interaction *Interaction) error
- func (channel *TelegramChannel) SendDocument(interaction *Interaction) error
- func (channel *TelegramChannel) SendImage(interaction *Interaction) error
- func (channel *TelegramChannel) SendText(interaction *Interaction) error
- func (channel *TelegramChannel) SendVideo(interaction *Interaction) error
- type Who
Constants ΒΆ
View Source
const ( CHANNEL_TELEGRAM_NAME = "telegram" CHANNEL_DISCORD_NAME = "discord" CONSUMER_JOURNEY_NAME = "journey" CONSUMER_CHATGPT_NAME = "chatgpt" FLOW_INIT_STEP_NAME = "init" FLOW_END_STEP_NAME = "end" FLOW_DEFAULT_STEP_NAME = "default" )
Variables ΒΆ
View Source
var ( DEBUG = false ERR_UNKNOWN_TELEGRAM_TOKEN = errors.New("unknown telegram token") ERR_UNKNOWN_DISCORD_TOKEN = errors.New("unknown discord token") ERR_UNKNOWN_CHATGPT_TOKEN = errors.New("unknown chatgpt token") ERR_CONNECT_CHATGPT = errors.New("connect to chatgpt failed") ERR_UNDEFINED_CHATGPT_ASSISTANT = errors.New("undefined chatgpt assistant") ERR_UNKNOWN_ACTION = errors.New("unknown action") ERR_UNKNOWN_ROOM = errors.New("unknown room") ERR_NIL_FLOW = errors.New("nil flow") ERR_NIL_STEP = errors.New("nil step") ERR_NIL_CHANNEL = errors.New("nil channel") ERR_UNKNOWN_DEFAULT_STEP = errors.New("unknown step: default") ERR_UNKNOWN_INIT_STEP = errors.New("unknown step: init") ERR_UNKNOWN_NEXT_STEP = errors.New("unknown next step") ERR_PATTERN_NEXT_STEP = errors.New("step pattern invalid") ERR_ENDED_FLOW = errors.New("flow ended") ERR_ROOM_STOPPED_FLOW = errors.New("flow finished by room") ERR_FEATURE_UNIMPLEMENTED = errors.New("feature unimplemented") )
View Source
var ( FILETYPE_AUDIO_EXT = []string{".aac", ".mp3", ".oga", ".opus", ".wav", ".weba", ".cda"} FILETYPE_IMAGE_EXT = []string{".apng", ".avif", ".gif", ".jpg", ".jpeg", ".png", ".svg", ".webp"} FILETYPE_VIDEO_EXT = []string{".avi", ".mp4", ".mpeg", ".ogv", ".webm"} )
Functions ΒΆ
func FormatTestError ΒΆ
func ParseTemplate ΒΆ
func RunAction ΒΆ
func RunAction(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func RunActionButton ΒΆ added in v1.10.0
func RunActionButton(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func RunActionFile ΒΆ added in v1.10.0
func RunActionFile(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func RunActionInput ΒΆ added in v1.10.0
func RunActionInput(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func RunActionRoom ΒΆ added in v1.10.0
func RunActionRoom(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func RunActionText ΒΆ added in v1.10.0
func RunActionText(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func RunActionWait ΒΆ added in v1.10.0
func RunActionWait(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func SendInteraction ΒΆ added in v1.10.0
func SendInteraction(channel IChannel, interaction *Interaction) error
func SetCustomActions ΒΆ added in v1.1.0
func SetCustomActions(custom ActionsMap)
func StartConsumer ΒΆ added in v1.7.1
Types ΒΆ
type ActionsMap ΒΆ
type Broadcast ΒΆ added in v1.10.0
type Broadcast[T any] struct { // contains filtered or unexported fields }
func NewBroadcast ΒΆ added in v1.10.0
type Channel ΒΆ
type Channel struct {
ChannelID uuid.UUID
Name string
Broadcast *Broadcast[*Interaction]
Context context.Context
Cancel context.CancelFunc
}
type ChatGPTAssistantConsumer ΒΆ added in v1.8.0
type ChatGPTAssistantConsumer struct {
*Consumer
// contains filtered or unexported fields
}
func (*ChatGPTAssistantConsumer) GetConsumer ΒΆ added in v1.9.5
func (consumer *ChatGPTAssistantConsumer) GetConsumer() *Consumer
func (*ChatGPTAssistantConsumer) Run ΒΆ added in v1.8.0
func (consumer *ChatGPTAssistantConsumer) Run(interaction *Interaction, channel IChannel) error
type ChatGPTConsumer ΒΆ added in v1.7.1
type ChatGPTConsumer struct {
*Consumer
// contains filtered or unexported fields
}
func (*ChatGPTConsumer) GetConsumer ΒΆ added in v1.9.5
func (consumer *ChatGPTConsumer) GetConsumer() *Consumer
func (*ChatGPTConsumer) Run ΒΆ added in v1.7.1
func (consumer *ChatGPTConsumer) Run(interaction *Interaction, channel IChannel) error
type DiscordChannel ΒΆ added in v1.7.1
type DiscordChannel struct {
*Channel
// contains filtered or unexported fields
}
func (*DiscordChannel) Close ΒΆ added in v1.10.0
func (channel *DiscordChannel) Close() error
func (*DiscordChannel) GetChannel ΒΆ added in v1.7.1
func (channel *DiscordChannel) GetChannel() *Channel
func (*DiscordChannel) Next ΒΆ added in v1.7.1
func (channel *DiscordChannel) Next()
func (*DiscordChannel) RespondInteraction ΒΆ added in v1.7.1
func (channel *DiscordChannel) RespondInteraction(in *discordgo.Interaction)
func (*DiscordChannel) SendAudio ΒΆ added in v1.7.1
func (channel *DiscordChannel) SendAudio(interaction *Interaction) error
func (*DiscordChannel) SendButton ΒΆ added in v1.7.1
func (channel *DiscordChannel) SendButton(interaction *Interaction) error
func (*DiscordChannel) SendDocument ΒΆ added in v1.7.1
func (channel *DiscordChannel) SendDocument(interaction *Interaction) error
func (*DiscordChannel) SendFile ΒΆ added in v1.7.1
func (channel *DiscordChannel) SendFile(sessionID, text, path string) error
func (*DiscordChannel) SendImage ΒΆ added in v1.7.1
func (channel *DiscordChannel) SendImage(interaction *Interaction) error
func (*DiscordChannel) SendText ΒΆ added in v1.7.1
func (channel *DiscordChannel) SendText(interaction *Interaction) error
func (*DiscordChannel) SendVideo ΒΆ added in v1.7.1
func (channel *DiscordChannel) SendVideo(interaction *Interaction) error
type File ΒΆ added in v1.7.1
type File struct {
FileID uuid.UUID
FileType FileType
Bytes []byte
Path string
Extension string
Err error
}
func (*File) IsDocument ΒΆ added in v1.7.1
func (*File) SetFilePath ΒΆ added in v1.7.1
func (*File) SetFileType ΒΆ added in v1.7.1
func (file *File) SetFileType()
type Flow ΒΆ
type Flow struct {
FlowID uuid.UUID
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
Steps Steps `yaml:"steps" json:"steps"`
CurrentStep *Step
CurrentStepName string
Responses []*Interaction
}
func NewFlowByJSON ΒΆ added in v1.10.0
func NewFlowByJSONFile ΒΆ added in v1.10.0
func (*Flow) AddResponse ΒΆ added in v1.10.0
func (flow *Flow) AddResponse(interaction *Interaction)
func (*Flow) GetLastResponse ΒΆ added in v1.10.0
func (flow *Flow) GetLastResponse() *Interaction
func (*Flow) GetLastResponseText ΒΆ added in v1.10.0
func (*Flow) Next ΒΆ
func (flow *Flow) Next(interaction *Interaction) error
type FlowPersist ΒΆ added in v1.7.1
func NewMemoryFlowPersist ΒΆ added in v1.7.1
func NewMemoryFlowPersist() (FlowPersist, error)
type GuestRoomRelation ΒΆ added in v1.10.0
type IChannel ΒΆ added in v1.7.1
type IChannel interface {
GetChannel() *Channel
Next()
Close() error
SendAudio(*Interaction) error
SendButton(*Interaction) error
SendDocument(*Interaction) error
SendImage(*Interaction) error
SendText(*Interaction) error
SendVideo(*Interaction) error
}
func NewDiscordChannel ΒΆ added in v1.7.1
func NewTelegramChannel ΒΆ added in v1.7.1
type IConsumer ΒΆ added in v1.7.1
type IConsumer interface {
Run(*Interaction, IChannel) error
GetConsumer() *Consumer
}
func NewChatGPTAssistantConsumer ΒΆ added in v1.8.0
func NewChatGPTConsumer ΒΆ added in v1.7.1
func NewJourneyConsumer ΒΆ added in v1.7.1
func NewJourneyConsumer(flow *Flow, persist FlowPersist) IConsumer
type IFile ΒΆ added in v1.7.1
type Interaction ΒΆ
type Interaction struct {
Channel *Channel
Destination *Who
Sender *Who
Replier *Who
Type InteractionType
Parameters InteractionParameters
Custom map[string]any
}
func NewInteractionMessageFile ΒΆ added in v1.7.1
func NewInteractionMessageText ΒΆ
func NewInteractionMessageText(channel IChannel, destination *Who, sender *Who, text string) *Interaction
func (*Interaction) SetDestination ΒΆ added in v1.10.0
func (interaction *Interaction) SetDestination(destination *Who) *Interaction
func (*Interaction) SetReplier ΒΆ added in v1.7.1
func (interaction *Interaction) SetReplier(replier *Who) *Interaction
type InteractionParameters ΒΆ
type InteractionType ΒΆ
type InteractionType string
const ( MESSAGE_BUTTON InteractionType = "MESSAGE_BUTTON" MESSAGE_FILE InteractionType = "MESSAGE_FILE" MESSAGE_TEXT InteractionType = "MESSAGE_TEXT" EVENT_TYPING InteractionType = "EVENT_TYPING" )
type JourneyConsumer ΒΆ added in v1.7.1
type JourneyConsumer struct {
*Consumer
Flow *Flow
Persist FlowPersist
}
func (*JourneyConsumer) GetConsumer ΒΆ added in v1.9.5
func (consumer *JourneyConsumer) GetConsumer() *Consumer
func (*JourneyConsumer) Run ΒΆ added in v1.7.1
func (consumer *JourneyConsumer) Run(interaction *Interaction, channel IChannel) error
type MemoryFlowPersist ΒΆ added in v1.7.1
type Room ΒΆ added in v1.7.1
type Room struct {
RoomID uuid.UUID
Guests RoomGuests
Interactions []*Interaction
}
func NewRoom ΒΆ added in v1.10.0
func NewRoom(guests RoomGuests) *Room
func (*Room) AddInteraction ΒΆ added in v1.10.0
func (room *Room) AddInteraction(interaction *Interaction) error
func (*Room) SendInteractionExcludingSender ΒΆ added in v1.10.0
func (room *Room) SendInteractionExcludingSender(interaction *Interaction) (errs []error)
type RoomGuests ΒΆ added in v1.10.0
type RoomManager ΒΆ added in v1.10.0
type RoomManager struct {
ChannelGuestRoomRelation map[uuid.UUID]GuestRoomRelation
Rooms map[uuid.UUID]*Room
Err error
}
func GetRoomManager ΒΆ added in v1.10.0
func GetRoomManager() *RoomManager
func NewRoomManager ΒΆ added in v1.10.0
func NewRoomManager() *RoomManager
func (*RoomManager) AddChannel ΒΆ added in v1.10.0
func (manager *RoomManager) AddChannel(channel IChannel) uuid.UUID
func (*RoomManager) AddGuest ΒΆ added in v1.10.0
func (manager *RoomManager) AddGuest(roomID uuid.UUID, guest *Guest) error
func (*RoomManager) AddInteraction ΒΆ added in v1.10.0
func (manager *RoomManager) AddInteraction(interaction *Interaction) error
func (*RoomManager) AddRoom ΒΆ added in v1.10.0
func (manager *RoomManager) AddRoom(room *Room) error
func (*RoomManager) GetRoom ΒΆ added in v1.10.0
func (manager *RoomManager) GetRoom(roomID uuid.UUID) *Room
func (*RoomManager) ListenChannel ΒΆ added in v1.10.0
func (manager *RoomManager) ListenChannel(channel IChannel)
type Step ΒΆ
type Step struct {
Action string `yaml:"action" json:"action"`
Next map[string]string `yaml:"next" json:"next"`
Parameters StepParameters `yaml:"parameters" json:"parameters"`
}
type StepParameters ΒΆ
type TelegramChannel ΒΆ added in v1.7.1
type TelegramChannel struct {
*Channel
// contains filtered or unexported fields
}
func (*TelegramChannel) Close ΒΆ added in v1.10.0
func (channel *TelegramChannel) Close() error
func (*TelegramChannel) GetChannel ΒΆ added in v1.7.1
func (channel *TelegramChannel) GetChannel() *Channel
func (*TelegramChannel) Next ΒΆ added in v1.7.1
func (channel *TelegramChannel) Next()
func (*TelegramChannel) SendAudio ΒΆ added in v1.7.1
func (channel *TelegramChannel) SendAudio(interaction *Interaction) error
func (*TelegramChannel) SendButton ΒΆ added in v1.7.1
func (channel *TelegramChannel) SendButton(interaction *Interaction) error
func (*TelegramChannel) SendDocument ΒΆ added in v1.7.1
func (channel *TelegramChannel) SendDocument(interaction *Interaction) error
func (*TelegramChannel) SendImage ΒΆ added in v1.7.1
func (channel *TelegramChannel) SendImage(interaction *Interaction) error
func (*TelegramChannel) SendText ΒΆ added in v1.7.1
func (channel *TelegramChannel) SendText(interaction *Interaction) error
func (*TelegramChannel) SendVideo ΒΆ added in v1.7.1
func (channel *TelegramChannel) SendVideo(interaction *Interaction) error
Source Files
ΒΆ
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
docs
|
|
|
examples/chagpt_assistant
command
|
|
|
examples/chatgpt
command
|
|
|
examples/dungeon
command
|
|
|
examples/hello
command
|
|
|
examples/pingpong
command
|
|
|
examples/room
command
|
|
|
examples/tabnews
command
|
Click to show internal directories.
Click to hide internal directories.