Documentation
¶
Index ¶
Constants ¶
const ( Manifest = "HOOK.yaml" Root = "hooks" )
File a hook folder declares its hook in, and the folder of hook folders inside a profile's folder and inside the folder every profile shares
const ( Timeout = 60 MaxTimeout = 300 )
Seconds the command of a folder may take when its HOOK.yaml gives none, and the most it may take
const ( GatewayStartup = "gateway:startup" SessionStart = "session:start" SessionEnd = "session:end" SessionReset = "session:reset" AgentStart = "agent:start" AgentStep = "agent:step" AgentEnd = "agent:end" ReactionAdded = "reaction:added" ReactionRemoved = "reaction:removed" SessionCompress = "session:compress" LoginExhausted = "login:exhausted" // Start of the event of a slash command, the command's name after it CommandOf = "command:" )
Events of a hook folder as its HOOK.yaml names them
const ( Deny = "deny" Handled = "handled" Rewrite = "rewrite" )
What the hook of a slash command may answer
Variables ¶
var ErrNone = errors.New("The folder holds no " + Manifest + ".")
A folder of hook folders holds no HOOK.yaml there, so it is no hook folder
Functions ¶
func Context ¶
The context the event of hook folders carries, made from the fields of the point's event as JSON and the chat the session talks in
Types ¶
type Chat ¶
type Chat struct {
Platform, User, ID, Thread string
// Direct, Group or Channel, as icebath names the kinds of chats
Kind string
}
Where the session a firing names talks, as the events of hook folders tell it: the app, who last wrote there, the chat and its thread and kind; empty for a session no chat talks to
type Decision ¶
type Decision struct {
// Deny, Handled or Rewrite; empty for an answer that decides nothing
Verb string
// What the person is told, empty when the hook said nothing
Message string
// Command and the words after it a rewrite turns the command into, the command without its slash
Command, Args string
}
What the hook of a slash command answered, as hook folders answer it
type Event ¶
type Event struct {
// As its HOOK.yaml names it: an event of hook folders, one that stands for every event of a part such as agent:*, or a hook point of
// icebath by its own name
Name string
// Hook points it is heard on
Points []string
// An event of hook folders, whose command reads the event as hook folders write it and answers as they do; false for a hook point named
// by its own name, whose command reads and answers as a shell hook of the settings does
Folder bool
}
One event a folder's hook runs on
type Folder ¶
type Folder struct {
// The folder, and the name it goes by: HOOK.yaml's name, else the folder's
Dir, Name string
Description string
Events []Event
// Command as HOOK.yaml writes it, and the words that run, the first a file of the folder made whole where the command names one
Command string
Argv []string
// Seconds the command may take
Timeout int
// Files whose change asks for consent again: HOOK.yaml, then each file the command names; and the digest of them all, which consent is
// given to
Files []string
Digest string
// What was read otherwise than written, such as a time limit out of bounds, each a sentence
Notes []string
}
A hook folder as its HOOK.yaml declares it: what runs, on which events, for how long
func Read ¶
Reads a hook folder: its HOOK.yaml, the events it names, each heard on the hook points it stands for, and the command that runs, a file of the folder named by its own name taken from the folder. Known says whether a name is a hook point a shell hook may run on. ErrNone for a folder with no HOOK.yaml; any other error says in a sentence why HOOK.yaml declares no hook a person can use