3.3 KiB
title | weight |
---|---|
EventClient | 10000 |
Classes
- EventClient
EventClient abstracts the connection to the bot websocket for events
Typedefs
- Options :
Object
Options to pass to the EventClient constructor
EventClient
EventClient abstracts the connection to the bot websocket for events
Kind: global class
- EventClient
- new EventClient(opts)
- .apiBase() ⇒
string
- .paramOptionFallback(key, [fallback]) ⇒
*
- .renderTemplate(template) ⇒
Promise
new EventClient(opts)
Creates, initializes and connects the EventClient
Param | Type | Description |
---|---|---|
opts | Options |
Options for the EventClient |
eventClient.apiBase() ⇒ string
Returns the API base URL without trailing slash
Kind: instance method of EventClient
Returns: string
- API base URL
eventClient.paramOptionFallback(key, [fallback]) ⇒ *
Resolves the given key through url hash parameters with fallback to constructor options
Kind: instance method of EventClient
Returns: *
- Value of the key or null
Param | Type | Default | Description |
---|---|---|---|
key | string |
The key to resolve | |
[fallback] | * |
|
Fallback to return if neither params nor options contained that key |
eventClient.renderTemplate(template) ⇒ Promise
Renders a given template using the bots msgformat API (supports all templating you can use in bot messages). To use this function the token passed through the constructor or the URL hash must have the msgformat
permission in addition to the overlays
permission.
Kind: instance method of EventClient
Returns: Promise
- Promise resolving to the rendered output of the template
Param | Type | Description |
---|---|---|
template | string |
The template to render |
Options : Object
Options to pass to the EventClient constructor
Kind: global typedef
Properties
Name | Type | Default | Description |
---|---|---|---|
[channel] | string |
Filter for specific channel events (format: #channel ) |
|
[handlers] | Object |
{} |
Map event types to callback functions (event, fields, time, live) => {...} |
[maxReplayAge] | number |
-1 |
Number of hours to replay the events for (-1 = infinite) |
[replay] | boolean |
false |
Request a replay at connect (requires channel to be set to a channel name) |
[token] | string |
API access token to use to connect to the WebSocket (if not set, must be provided through URL hash) |