Documentation
ΒΆ
Index ΒΆ
- Constants
- Variables
- func FormatTestError(expect, have any) string
- func InitWhatsappMeowChannel(ctx context.Context, db *sql.DB, dialect string, log waLog.Logger) error
- func InitWhatsappTwilioChannel(webhook *gin.Engine, path string)
- func IsURL(str string) bool
- func ParseTemplate(texts []string) string
- func PrintLog(msg string)
- func SendInteraction(channel IChannel, interaction *Interaction) error
- func SetCustomActions(custom ActionsMap)
- type ActionFunc
- type ActionsMap
- type Bot
- type Broadcast
- type Channel
- type ChatGPTAssistantConsumer
- type ChatGPTConsumer
- type Consumer
- type DiscordChannel
- func (channel *DiscordChannel) GetChannel() *Channel
- 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
- func (channel *DiscordChannel) Start() error
- func (channel *DiscordChannel) Stop() error
- type File
- type FileType
- type Flow
- type FlowPersist
- type IChannel
- func NewDiscordChannel(token string) (IChannel, error)
- func NewTelegramChannel(token string) (IChannel, error)
- func NewWhatsappMeowChannel(ctx context.Context, JID types.JID, qrcodeChan chan WhatsappMeowUpdate) (IChannel, error)
- func NewWhatsappTwilioChannel(number, token, SID string) (IChannel, error)
- type IConsumer
- type IFile
- type Interaction
- func NewInteractionMessageButton(buttons []string, text string) *Interaction
- func NewInteractionMessageFile(path string, text string) *Interaction
- func NewInteractionMessageText(text string) *Interaction
- func RunActionButton(interaction *Interaction) (*Interaction, bool)
- func RunActionFile(interaction *Interaction) (*Interaction, bool)
- func RunActionInput(interaction *Interaction) (*Interaction, bool)
- func RunActionText(interaction *Interaction) (*Interaction, bool)
- type InteractionParameters
- type InteractionType
- type JourneyConsumer
- type MemoryFlowPersist
- type Step
- type StepParameters
- type Steps
- type TelegramChannel
- func (channel *TelegramChannel) GetChannel() *Channel
- 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
- func (channel *TelegramChannel) Start() error
- func (channel *TelegramChannel) Stop() error
- type WebhookChannel
- type WhatsappMeowChannel
- func (channel *WhatsappMeowChannel) GetChannel() *Channel
- func (channel *WhatsappMeowChannel) SendAudio(interaction *Interaction) error
- func (channel *WhatsappMeowChannel) SendButton(interaction *Interaction) error
- func (channel *WhatsappMeowChannel) SendDocument(interaction *Interaction) error
- func (channel *WhatsappMeowChannel) SendImage(interaction *Interaction) error
- func (channel *WhatsappMeowChannel) SendText(interaction *Interaction) error
- func (channel *WhatsappMeowChannel) SendVideo(interaction *Interaction) error
- func (channel *WhatsappMeowChannel) Start() error
- func (channel *WhatsappMeowChannel) Stop() error
- type WhatsappMeowUpdate
- type WhatsappTwilioChannel
- func (channel *WhatsappTwilioChannel) GetChannel() *Channel
- func (channel *WhatsappTwilioChannel) SendAudio(interaction *Interaction) error
- func (channel *WhatsappTwilioChannel) SendButton(interaction *Interaction) error
- func (channel *WhatsappTwilioChannel) SendDocument(interaction *Interaction) error
- func (channel *WhatsappTwilioChannel) SendImage(interaction *Interaction) error
- func (channel *WhatsappTwilioChannel) SendText(interaction *Interaction) error
- func (channel *WhatsappTwilioChannel) SendVideo(interaction *Interaction) error
- func (channel *WhatsappTwilioChannel) Start() error
- func (channel *WhatsappTwilioChannel) Stop() error
- type Who
Constants ΒΆ
View Source
const ( CHANNEL_TELEGRAM_NAME = "telegram" CHANNEL_WHATSAPP_TWILIO_NAME = "whatsapp-twilio" CHANNEL_WHATSAPP_DEVICE_NAME = "whatsapp-meow" 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_CHANNEL_RUNNING = fmt.Errorf("channel is running") ERR_CHANNEL_NOT_RUNNING = fmt.Errorf("channel is not running") ERR_UNKNOWN_TELEGRAM_TOKEN = fmt.Errorf("unknown telegram token") ERR_UNKNOWN_DISCORD_TOKEN = fmt.Errorf("unknown discord token") ERR_UNKNOWN_CHATGPT_TOKEN = fmt.Errorf("unknown chatgpt token") ERR_CONNECT_CHATGPT = fmt.Errorf("connect to chatgpt failed") ERR_UNDEFINED_CHATGPT_ASSISTANT = fmt.Errorf("undefined chatgpt assistant") ERR_UNKNOWN_ACTION = fmt.Errorf("unknown action") ERR_UNKNOWN_ROOM = fmt.Errorf("unknown room") ERR_NIL_FLOW = fmt.Errorf("nil flow") ERR_NIL_STEP = fmt.Errorf("nil step") ERR_NIL_CHANNEL = fmt.Errorf("nil channel") ERR_UNKNOWN_DEFAULT_STEP = fmt.Errorf("unknown step: default") ERR_UNKNOWN_INIT_STEP = fmt.Errorf("unknown step: init") ERR_UNKNOWN_NEXT_STEP = fmt.Errorf("unknown next step") ERR_PATTERN_NEXT_STEP = fmt.Errorf("step pattern invalid") ERR_ENDED_FLOW = fmt.Errorf("flow ended") ERR_ROOM_STOPPED_FLOW = fmt.Errorf("flow finished by room") ERR_FILE_NOT_PUBLIC = fmt.Errorf("file is not public") ERR_FEATURE_UNIMPLEMENTED = fmt.Errorf("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"} )
View Source
var WhatsMeowReplyDuration time.Duration = 2 * time.Second
Functions ΒΆ
func FormatTestError ΒΆ
func InitWhatsappMeowChannel ΒΆ added in v1.13.2
func InitWhatsappTwilioChannel ΒΆ added in v1.13.1
func ParseTemplate ΒΆ
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)
Types ΒΆ
type ActionFunc ΒΆ added in v1.11.0
type ActionFunc func(*Interaction) (*Interaction, bool)
func GetAction ΒΆ added in v1.11.0
func GetAction(flow *Flow) (ActionFunc, error)
type ActionsMap ΒΆ
type ActionsMap map[string]ActionFunc
type Bot ΒΆ added in v1.11.0
func (*Bot) StartChannel ΒΆ added in v1.11.0
func (*Bot) StartConsumerChannel ΒΆ added in v1.11.0
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 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) ([]*Interaction, 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) ([]*Interaction, 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) 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
func (*DiscordChannel) Start ΒΆ added in v1.11.0
func (channel *DiscordChannel) Start() error
func (*DiscordChannel) Stop ΒΆ added in v1.11.0
func (channel *DiscordChannel) Stop() error
type File ΒΆ added in v1.7.1
type File struct {
FileID uuid.UUID
FileType FileType
Name string
Bytes []byte
Path string
Extension string
Mime 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
}
func NewFlowByJSON ΒΆ added in v1.10.0
func NewFlowByJSONFile ΒΆ 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 IChannel ΒΆ added in v1.7.1
type IChannel interface {
GetChannel() *Channel
Stop() error
Start() 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
func NewWhatsappMeowChannel ΒΆ added in v1.13.2
func NewWhatsappTwilioChannel ΒΆ added in v1.11.0
type IConsumer ΒΆ added in v1.7.1
type IConsumer interface {
Run(*Interaction) ([]*Interaction, 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 {
To *Who
From *Who
Replier *Who
Type InteractionType
Parameters InteractionParameters
Step Step
Custom map[string]any
}
func NewInteractionMessageButton ΒΆ
func NewInteractionMessageButton(buttons []string, text string) *Interaction
func NewInteractionMessageFile ΒΆ added in v1.7.1
func NewInteractionMessageFile(path string, text string) *Interaction
func NewInteractionMessageText ΒΆ
func NewInteractionMessageText(text string) *Interaction
func RunActionButton ΒΆ added in v1.10.0
func RunActionButton(interaction *Interaction) (*Interaction, bool)
func RunActionFile ΒΆ added in v1.10.0
func RunActionFile(interaction *Interaction) (*Interaction, bool)
func RunActionInput ΒΆ added in v1.10.0
func RunActionInput(interaction *Interaction) (*Interaction, bool)
func RunActionText ΒΆ added in v1.10.0
func RunActionText(interaction *Interaction) (*Interaction, bool)
func (*Interaction) SetFrom ΒΆ added in v1.11.0
func (interaction *Interaction) SetFrom(from *Who) *Interaction
func (*Interaction) SetReplier ΒΆ added in v1.7.1
func (interaction *Interaction) SetReplier(replier *Who) *Interaction
func (*Interaction) SetStep ΒΆ added in v1.11.0
func (interaction *Interaction) SetStep(step Step) *Interaction
func (*Interaction) SetTo ΒΆ added in v1.11.0
func (interaction *Interaction) SetTo(to *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) ([]*Interaction, error)
type MemoryFlowPersist ΒΆ added in v1.7.1
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) GetChannel ΒΆ added in v1.7.1
func (channel *TelegramChannel) GetChannel() *Channel
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
func (*TelegramChannel) Start ΒΆ added in v1.11.0
func (channel *TelegramChannel) Start() error
func (*TelegramChannel) Stop ΒΆ added in v1.11.0
func (channel *TelegramChannel) Stop() error
type WebhookChannel ΒΆ added in v1.13.2
type WebhookChannel struct {
*Channel
}
type WhatsappMeowChannel ΒΆ added in v1.13.2
type WhatsappMeowChannel struct {
*Channel
JID *types.JID
// contains filtered or unexported fields
}
func (*WhatsappMeowChannel) GetChannel ΒΆ added in v1.13.2
func (channel *WhatsappMeowChannel) GetChannel() *Channel
func (*WhatsappMeowChannel) SendAudio ΒΆ added in v1.13.2
func (channel *WhatsappMeowChannel) SendAudio(interaction *Interaction) error
func (*WhatsappMeowChannel) SendButton ΒΆ added in v1.13.2
func (channel *WhatsappMeowChannel) SendButton(interaction *Interaction) error
func (*WhatsappMeowChannel) SendDocument ΒΆ added in v1.13.2
func (channel *WhatsappMeowChannel) SendDocument(interaction *Interaction) error
func (*WhatsappMeowChannel) SendImage ΒΆ added in v1.13.2
func (channel *WhatsappMeowChannel) SendImage(interaction *Interaction) error
func (*WhatsappMeowChannel) SendText ΒΆ added in v1.13.2
func (channel *WhatsappMeowChannel) SendText(interaction *Interaction) error
func (*WhatsappMeowChannel) SendVideo ΒΆ added in v1.13.2
func (channel *WhatsappMeowChannel) SendVideo(interaction *Interaction) error
func (*WhatsappMeowChannel) Start ΒΆ added in v1.13.2
func (channel *WhatsappMeowChannel) Start() error
func (*WhatsappMeowChannel) Stop ΒΆ added in v1.13.2
func (channel *WhatsappMeowChannel) Stop() error
type WhatsappMeowUpdate ΒΆ added in v1.13.4
type WhatsappMeowUpdate struct {
QR whatsmeow.QRChannelItem
JID types.JID
}
type WhatsappTwilioChannel ΒΆ added in v1.11.0
type WhatsappTwilioChannel struct {
*Channel
// contains filtered or unexported fields
}
func (*WhatsappTwilioChannel) GetChannel ΒΆ added in v1.11.0
func (channel *WhatsappTwilioChannel) GetChannel() *Channel
func (*WhatsappTwilioChannel) SendAudio ΒΆ added in v1.11.0
func (channel *WhatsappTwilioChannel) SendAudio(interaction *Interaction) error
func (*WhatsappTwilioChannel) SendButton ΒΆ added in v1.11.0
func (channel *WhatsappTwilioChannel) SendButton(interaction *Interaction) error
func (*WhatsappTwilioChannel) SendDocument ΒΆ added in v1.11.0
func (channel *WhatsappTwilioChannel) SendDocument(interaction *Interaction) error
func (*WhatsappTwilioChannel) SendImage ΒΆ added in v1.11.0
func (channel *WhatsappTwilioChannel) SendImage(interaction *Interaction) error
func (*WhatsappTwilioChannel) SendText ΒΆ added in v1.11.0
func (channel *WhatsappTwilioChannel) SendText(interaction *Interaction) error
func (*WhatsappTwilioChannel) SendVideo ΒΆ added in v1.11.0
func (channel *WhatsappTwilioChannel) SendVideo(interaction *Interaction) error
func (*WhatsappTwilioChannel) Start ΒΆ added in v1.11.0
func (channel *WhatsappTwilioChannel) Start() error
func (*WhatsappTwilioChannel) Stop ΒΆ added in v1.11.0
func (channel *WhatsappTwilioChannel) Stop() error
Source Files
ΒΆ
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
docs
|
|
|
examples/chatgpt
command
|
|
|
examples/chatgpt_assistant
command
|
|
|
examples/dungeon
command
|
|
|
examples/hello
command
|
|
|
examples/pingpong
command
|
|
|
examples/tabnews
command
|
|
|
examples/types
command
|
Click to show internal directories.
Click to hide internal directories.