-
Notifications
You must be signed in to change notification settings - Fork 9
Plugin API, Events and FAQ
Plugins are self-contained code snippets. Through plugins, one can define bots behaviour whether it is chat messaging, trading or friends list management.
There are two types of plugins:
- built-in plugins
- external plugins
Built-in plugins are part of this repo, they are universal, very short and provide only very simple functionality - something that doesn't necessarily need to be external.
The list of built-in plugins including their descriptions can be found in docs/BUILT-IN-PLUGINS.md.
External plugins provide advanced functionality - friends list management, trade offer management, website interaction. These may or may not be specific to your own needs but they are certainly large enough to be separate from this repo.
Every Vapor plugin has full access to following:
- complete access to all node-steam's enums, properties, methods and events
- access to node-steam-groups' methods
- custom Vapor API methods
For more information regarding node-steam and node-steam-groups, you should read their respective README files.
Vapor provides simple API for plugins. This API gives you access to active Steam client and Steam enums as well as let's you emit custom events or register handlers for other events.
Latest API docs can be found in the docs/API.md file which is included in this repo.
There are several event emitters in Vapor:
-
vapor
- active Vapor instance -
client
- active Steam client -
steamUser
,steamFriends
,steamTrading
- active Steam handlers -
plugin
- custom plugin
To register a callback for the any of the events, use the API.registerHandler(options, callback) method.
Internal Vapor events are documented in docs/EVENTS.md
Active Steam client and handlers also emits events. These are described in node-steam's repository.
Any plugin may emit their own events. This is done using the API.emitEvent(event, ...args) method.
Other plugins may listen to these events using the API.registerHandler(options, callback) method.
This is especially useful if you want to write two or more plugins which have to be coordinated.
An example of this functionality is provided in examples.
Can your code benefit from Vapor events and/or Vapor API? Make it a Vapor plugin.
Can your code work on its own? Make it a regular node.js module.
E.g. If you want to make a wrapper for, let's say third party API, make it a regular node.js module. If your code adjusts bot's behaviour, write a plugin. In many cases, you will most likely combine these 2 approaches.
Ideally, all publically released Vapor plugins should be prefixed with "vapor-" to make it clear that this is indeed a Vapor plugin.