Extension side of the library that allows easy communication among Chaturbate apps & bots and Fappurbate extensions.
Represents a channel between a Chaturbate bot (app) and a Fappurbate extension. Allows communication with events and requests.
options.name
string
Name of the channel. Must not clash with channel names of others instances (including other apps & bots in the same chat).
subject
string
Name of the event to listen to.callback
any => void
Callback will be called on a given event with attached data as the first argument.
Add a listener for a given event subject.
subject
string
Name of the event.callback
any => void
The same callback that was passed toonEvent.addListener
.
Remove an event listener.
subject
string
Name of the request.handler
any => void|any|Promise
Handler will be called on a given request.
Add a handler for a given request subject. It will be called with the data attached as the first argument. All handlers are called, but only the first received response is used. If throws an error, it is sent back to the bot (app) as an error response. May also return a Promise.
subject
string
Name of the request.handler
any => void|any|Promise
The same handler that was passed toonRequest.addHandler
.
Remove a request handler.
Unregister all event listeners. After this the channel is usable no more. Do it before you try to open a new channel with the same name.
string
The name of the channel. Read-only.
subject
string
Name of the event.data
any?
Data to send with the event. Must be serializable.
Send an event to the bot (app).
subject
string
Name of the request.data
any?
Data to send with the request. Must be serializable.
Send a request to the bot (app). If an error response is received, returns a promise that rejects with a Failure
that contains attached data. It is to distinguish an error response from other errors like network errors, timeout, etc.
A subclass of fb.Error
that represents an error response from request(subject, data)
.
data
any?
default: {}
Data to attach.
string
=== 'Failure'
string
=== 'ERR_FAILURE'