Surface
in package
Which chat an action was invoked from, and what that chat can take.
Actions are written once and registered into every chat the bot is in, so the handful of places that genuinely must differ — how long an answer may be, whether markdown renders, whether a name is worth linking — ask the surface rather than being written twice.
Deliberately a value object rather than an enum. An enum would mean the core has to grow a case before anyone can write a connector for a fourth network, which is exactly the coupling the connector model exists to avoid: a connector declares its own surface and the core has never heard of it.
Discord is the exception, and the one case the core does own — every installation has it, and it is the surface slash commands and panels live on.
Tags
Table of Contents
Constants
- DISCORD : mixed = 'discord'
- The name of the one surface every installation has.
Properties
Methods
- __construct() : mixed
- discord() : self
- is() : bool
- isDiscord() : bool
Constants
DISCORD
The name of the one surface every installation has.
public
mixed
DISCORD
= 'discord'
Properties
$label read-only
public
string
$label
$limit read-only
public
int
$limit
$lines read-only
public
bool
$lines
= true
$markdown read-only
public
bool
$markdown
= false
$name read-only
public
string
$name
$prefix read-only
public
string
$prefix
= '!'
Methods
__construct()
public
__construct(string $name, string $label, int $limit[, bool $markdown = false ][, bool $lines = true ][, string $prefix = '!' ]) : mixed
Parameters
- $name : string
-
Matches the connector's Connector::name().
- $label : string
-
What to call it in front of a human.
- $limit : int
-
The longest message body the surface accepts.
- $markdown : bool = false
-
Whether it renders Discord-style markdown.
- $lines : bool = true
-
Whether a message can contain a line break at all.
- $prefix : string = '!'
-
What a command typed there starts with.
discord()
public
static discord([string $prefix = '!' ]) : self
Parameters
- $prefix : string = '!'
-
What prefix commands start with; slash commands need none.
Return values
selfis()
public
is(string $name) : bool
Parameters
- $name : string
Return values
boolisDiscord()
public
isDiscord() : bool