Documentation
ΒΆ
Index ΒΆ
- Constants
- Variables
- func ActionButton(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- func ActionFile(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- func ActionInput(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- func ActionText(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- func ActionWait(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
- 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 SetCustomActions(custom ActionsMap)
- func StartConsumer(consumer IConsumer, channels []IChannel)
- type ActionsMap
- type Channel
- type ChatGPTAssistantConsumer
- type ChatGPTConsumer
- type Consumer
- type DiscordChannel
- func (channel *DiscordChannel) GetChannel() *Channel
- func (channel *DiscordChannel) Next(interaction chan *Interaction)
- 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
- type FlowPersist
- type IChannel
- type IConsumer
- type IFile
- type Interaction
- type InteractionParameters
- type InteractionType
- type JourneyConsumer
- type MemoryFlowPersist
- type Room
- type Step
- type StepParameters
- type Steps
- type TelegramChannel
- func (channel *TelegramChannel) GetChannel() *Channel
- func (channel *TelegramChannel) Next(interaction chan *Interaction)
- 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" )
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_NIL_FLOW = errors.New("nil flow") ERR_NIL_STEP = errors.New("nil step") 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") )
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 ActionButton ΒΆ
func ActionButton(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func ActionFile ΒΆ added in v1.7.1
func ActionFile(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func ActionInput ΒΆ
func ActionInput(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func ActionText ΒΆ
func ActionText(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func ActionWait ΒΆ added in v1.5.2
func ActionWait(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func FormatTestError ΒΆ
func ParseTemplate ΒΆ
func RunAction ΒΆ
func RunAction(flow *Flow, interaction *Interaction, channel IChannel) (bool, error)
func SetCustomActions ΒΆ added in v1.1.0
func SetCustomActions(custom ActionsMap)
func StartConsumer ΒΆ added in v1.7.1
Types ΒΆ
type ActionsMap ΒΆ
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) GetChannel ΒΆ added in v1.7.1
func (channel *DiscordChannel) GetChannel() *Channel
func (*DiscordChannel) Next ΒΆ added in v1.7.1
func (channel *DiscordChannel) Next(interaction chan *Interaction)
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"`
Steps Steps `yaml:"steps"`
Current *Step
}
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 IChannel ΒΆ added in v1.7.1
type IChannel interface {
GetChannel() *Channel
Next(chan *Interaction)
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
Sender *Who
Replier *Who
Type InteractionType
Parameters InteractionParameters
Custom map[string]any
}
func NewInteractionMessageButton ΒΆ
func NewInteractionMessageButton(channel IChannel, sender *Who, buttons []string, text string) *Interaction
func NewInteractionMessageFile ΒΆ added in v1.7.1
func NewInteractionMessageFile(channel IChannel, sender *Who, path string, text string) *Interaction
func NewInteractionMessageText ΒΆ
func NewInteractionMessageText(channel IChannel, sender *Who, text string) *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
Interactions []*Interaction
}
type Step ΒΆ
type Step struct {
Action string `yaml:"action"`
Next map[string]string `yaml:"next"`
Parameters StepParameters `yaml:"parameters"`
Responses []*Interaction
}
func (*Step) AddResponse ΒΆ added in v1.4.0
func (step *Step) AddResponse(interaction *Interaction)
func (*Step) GetLastResponse ΒΆ added in v1.4.2
func (step *Step) GetLastResponse() *Interaction
func (*Step) GetLastResponseText ΒΆ added in v1.4.2
type StepParameters ΒΆ
type TelegramChannel ΒΆ added in v1.7.1
type TelegramChannel struct {
*Channel
// contains filtered or unexported fields
}
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(interaction chan *Interaction)
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/tabnews
command
|
Click to show internal directories.
Click to hide internal directories.