bots

package
v0.0.0-...-0d5d2da Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	MessageBotIncomingBehavior   = "message_bot_incoming"
	MessageGroupIncomingBehavior = "message_group_incoming"
)

Variables

This section is empty.

Functions

func ActionMsg

func ActionMsg(_ types.Context, id string) types.MsgPayload

func AppURL

func AppURL(ctx types.Context, name string, param types.KV) string

func Behavior

func Behavior(uid types.Uid, flag string, number int)

func Bootstrap

func Bootstrap() error

func CreateShortUrl

func CreateShortUrl(text string) (string, error)

func Cron

func Cron(send func(rcptTo string, uid types.Uid, out types.MsgPayload, option ...interface{})) ([]*cron.Ruleset, error)

Cron registered handlers

func FormMsg

func FormMsg(ctx types.Context, id string) types.MsgPayload

func Help

func Help(rules []interface{}) (map[string][]string, error)

func HelpPipeline

func HelpPipeline(pipelineRules []pipeline.Rule, _ types.Context, _ types.KV, content interface{}) (types.MsgPayload, error)

func Init

func Init(jsonconf json.RawMessage) error

Init initializes registered handlers.

func InstructMsg

func InstructMsg(ctx types.Context, id string, data types.KV) types.MsgPayload

func List

func List() map[string]Handler

func PageURL

func PageURL(ctx types.Context, pageRuleId string, param types.KV, expiredDuration time.Duration) (string, error)

func ProcessPipeline

func ProcessPipeline(ctx types.Context, pipelineRule pipeline.Rule, index int) (types.MsgPayload, error)

func Register

func Register(name string, bot Handler)

func RunAction

func RunAction(actionRules []action.Rule, ctx types.Context, option string) (types.MsgPayload, error)

func RunAgent

func RunAgent(agentVersion int, agentRules []agent.Rule, ctx types.Context, content types.KV) (types.MsgPayload, error)

func RunCommand

func RunCommand(commandRules []command.Rule, ctx types.Context, content interface{}) (types.MsgPayload, error)

func RunCondition

func RunCondition(conditionRules []condition.Rule, ctx types.Context, forwarded types.MsgPayload) (types.MsgPayload, error)

func RunCron

func RunCron(cronRules []cron.Rule, name string, send types.SendFunc) (*cron.Ruleset, error)

func RunForm

func RunForm(formRules []form.Rule, ctx types.Context, values types.KV) (types.MsgPayload, error)

func RunGroup

func RunGroup(eventRules []event.Rule, ctx types.Context, head types.KV, content interface{}) (types.MsgPayload, error)

func RunPage

func RunPage(pageRules []page.Rule, ctx types.Context, flag string) (string, error)

func RunPipeline

func RunPipeline(pipelineRules []pipeline.Rule, ctx types.Context, head types.KV, content interface{}, operate types.PipelineOperate) (types.MsgPayload, string, int, error)

func RunSession

func RunSession(sessionRules []session.Rule, ctx types.Context, content interface{}) (types.MsgPayload, error)

func RunWebhook

func RunWebhook(webhookRules []webhook.Rule, ctx types.Context, content types.KV) (types.MsgPayload, error)

func RunWorkflow

func RunWorkflow(workflowRules []workflow.Rule, ctx types.Context, input types.KV) (types.KV, error)

func ServeFile

func ServeFile(rw http.ResponseWriter, req *http.Request, dist embed.FS, dir string)

func ServiceURL

func ServiceURL(ctx types.Context, group, path string, param types.KV) string

func SessionDone

func SessionDone(ctx types.Context)

func SessionMsg

func SessionMsg(ctx types.Context, id string, data types.KV) types.MsgPayload

func SessionStart

func SessionStart(ctx types.Context, initValues types.KV) error

func SetPipelineState

func SetPipelineState(ctx types.Context, flag string, state model.PipelineState) error

func SetPipelineStep

func SetPipelineStep(ctx types.Context, flag string, index int) error

func SettingCovertForm

func SettingCovertForm(id string, rule setting.Rule) form.Rule

func SettingGet

func SettingGet(ctx types.Context, id string, key string) (types.KV, error)

func SettingMsg

func SettingMsg(ctx types.Context, id string) types.MsgPayload

func StoreForm

func StoreForm(ctx types.Context, payload types.MsgPayload) types.MsgPayload

func StoreInstruct

func StoreInstruct(ctx types.Context, payload types.MsgPayload) types.MsgPayload

func StorePage

func StorePage(ctx types.Context, category model.PageType, title string, payload types.MsgPayload) types.MsgPayload

func StoreParameter

func StoreParameter(params types.KV, expiredAt time.Time) (string, error)

func StorePipeline

func StorePipeline(ctx types.Context, pipelineRule pipeline.Rule, index int) (string, error)

func TriggerPipeline

func TriggerPipeline(pipelineRules []pipeline.Rule, ctx types.Context, _ types.KV, content interface{}, trigger types.TriggerType) (string, pipeline.Rule, error)

func Webservice

func Webservice(app *fiber.App, name string, ruleset webservice.Ruleset)

Types

type Base

type Base struct{}

func (Base) Action

func (Base) Action(_ types.Context, _ string) (types.MsgPayload, error)

func (Base) Agent

func (Base) Agent(_ types.Context, _ types.KV) (types.MsgPayload, error)

func (Base) Bootstrap

func (Base) Bootstrap() error

func (Base) Command

func (Base) Command(_ types.Context, _ interface{}) (types.MsgPayload, error)

func (Base) Condition

func (Base) Condition(_ types.Context, _ types.MsgPayload) (types.MsgPayload, error)

func (Base) Cron

func (Base) Cron(_ types.SendFunc) (*cron.Ruleset, error)

func (Base) Form

func (Base) Form(_ types.Context, _ types.KV) (types.MsgPayload, error)

func (Base) Group

func (Base) Group(_ types.Context, _ types.KV, _ interface{}) (types.MsgPayload, error)

func (Base) Help

func (b Base) Help() (map[string][]string, error)

func (Base) Input

func (Base) Input(_ types.Context, _ types.KV, _ interface{}) (types.MsgPayload, error)

func (Base) Instruct

func (Base) Instruct() (instruct.Ruleset, error)

func (Base) OnEvent

func (Base) OnEvent() error

func (Base) Page

func (Base) Page(_ types.Context, _ string) (string, error)

func (Base) Pipeline

func (Base) Pipeline(_ types.Context, _ types.KV, _ interface{}, _ types.PipelineOperate) (types.MsgPayload, string, int, error)

func (Base) Rules

func (Base) Rules() []interface{}

func (Base) Session

func (Base) Session(_ types.Context, _ interface{}) (types.MsgPayload, error)

func (Base) WebService

func (Base) WebService() *restful.WebService

func (Base) Webapp

func (Base) Webapp() func(rw http.ResponseWriter, req *http.Request)

func (Base) Webhook

func (Base) Webhook(_ types.Context, _ types.KV) (types.MsgPayload, error)

func (Base) Webservice

func (Base) Webservice(_ *fiber.App)

func (Base) Workflow

func (Base) Workflow(_ types.Context, _ types.KV) (types.KV, error)

type Handler

type Handler interface {
	// Init initializes the bot.
	Init(jsonconf json.RawMessage) error

	// IsReady сhecks if the bot is initialized.
	IsReady() bool

	// Bootstrap Lifecycle hook
	Bootstrap() error

	// OnEvent event
	OnEvent() error

	// Help return bot help
	Help() (map[string][]string, error)

	// Rules return bot ruleset
	Rules() []interface{}

	// Input return input result
	Input(ctx types.Context, head types.KV, content interface{}) (types.MsgPayload, error)

	// Command return bot result
	Command(ctx types.Context, content interface{}) (types.MsgPayload, error)

	// Form return bot form result
	Form(ctx types.Context, values types.KV) (types.MsgPayload, error)

	// Action return bot action result
	Action(ctx types.Context, option string) (types.MsgPayload, error)

	// Session return bot session result
	Session(ctx types.Context, content interface{}) (types.MsgPayload, error)

	// Cron cron script daemon
	Cron(send types.SendFunc) (*cron.Ruleset, error)

	// Condition run conditional process
	Condition(ctx types.Context, forwarded types.MsgPayload) (types.MsgPayload, error)

	// Group return group result
	Group(ctx types.Context, head types.KV, content interface{}) (types.MsgPayload, error)

	// Pipeline return pipeline result
	Pipeline(ctx types.Context, head types.KV, content interface{}, operate types.PipelineOperate) (types.MsgPayload, string, int, error)

	// Agent return group result
	Agent(ctx types.Context, content types.KV) (types.MsgPayload, error)

	// Instruct return instruct list
	Instruct() (instruct.Ruleset, error)

	// Page return page
	Page(ctx types.Context, flag string) (string, error)

	// Webservice return webservice routes
	Webservice(app *fiber.App)

	// Webapp return webapp
	Webapp() func(rw http.ResponseWriter, req *http.Request)

	// Workflow return workflow result
	Workflow(ctx types.Context, input types.KV) (types.KV, error)

	// Webhook return webhook result
	Webhook(ctx types.Context, content types.KV) (types.MsgPayload, error)
}

Jump to

Keyboard shortcuts

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