Kind: global class
Properties
Name | Type | Description |
---|---|---|
pluginName | string |
Name of the plugin which uses this specific API instance. |
data | Object |
Data object that is passed to API instance via Vapor.use method. |
- API
- new API(vapor, pluginName, data)
- .connect(codes)
- .disconnect()
- .getClient() ⇒
SteamClient
- .getHandler(handler) ⇒
Object
- .getUtils() ⇒
Utils
- .getSteam() ⇒
Steam
- .getConfig() ⇒
Object
- .getPlugins() ⇒
Array.<string>
- .emitEvent(event, ...args)
- .registerHandler(options, callback)
- .hasHandler(options)
- .removeAllHandlers(options)
- .getLogger() ⇒
Object
- .webLogOn()
API class constructor.
Instance of this class is passed to plugins exported function as the only argument.
Param | Type | Description |
---|---|---|
vapor | Vapor |
Vapor instance. |
pluginName | string |
Specific plugin name which uses this API instance. |
data | Object |
Data object that is passed to API instance. |
Connect to Steam network.
You can provide optional authentication codes.
Kind: instance method of API
Param | Type | Description |
---|---|---|
codes | Object |
Optional object with authentication codes. |
codes.authCode | string |
Auth code received by e-mail. |
codes.twoFactorCode | string |
Auth code from mobile app. |
Disconnect from Steam network.
Kind: instance method of API
Returns active Steam client used by Vapor.
Kind: instance method of API
Returns: SteamClient
- Active Steam client.
Returns active Steam handler used by Vapor.
Kind: instance method of API
Returns: Object
- Active Steam handler.
Param | Type | Description |
---|---|---|
handler | string |
Can be either steamUser , steamFriends , steamTrading or steamGroups . |
api.getUtils() ⇒ Utils
Returns instance of Utils class.
Kind: instance method of API
Returns: Utils
- Instantiated Utils class.
Returns Steam object.
This is especially useful for all the ESomething enums.
Kind: instance method of API
Returns: Steam
- Steam.
Returns Vapor config object.
Kind: instance method of API
Returns: Object
- Config object.
Returns array of names of loaded plugins.
Kind: instance method of API
Returns: Array.<string>
- Array of plugin names.
Allows plugin to emit custom events via Vapor's event emitter.
This function allows to pass multiple data arguments.
Also see registerHandler.
Kind: instance method of API
Param | Type | Description |
---|---|---|
event | string |
Event name. |
...args | * |
Data arguments. |
Example
API.emitEvent('myCustomPluginEvent', someString, someObject);
Allows plugin to register custom handler for any event.
Also see emitEvent.
Kind: instance method of API
Param | Type | Description |
---|---|---|
options | Object |
Options object. |
options.emitter | string |
Can be either vapor , client , steamUser , steamFriends , steamTrading , plugin or * (which stands for 'any'). |
options.plugin | string |
If emitter is plugin , this is plugin's name. Use * for any. |
options.event | string |
Event name. |
callback | function |
Callback function. |
Example
// Listen to 'friendMsg' event emitted by 'steamFriends'
API.registerHandler({
emitter: 'steamFriends',
event: 'friendMsg'
}, function(user, message, type) {
if(type === Steam.EChatEntryType.ChatMsg) {
console.log(user + " says: " + message);
}
});
// Listen to another plugin's custom event
API.registerHandler({
emitter: 'plugin',
plugin: 'another-plugin-name'
event: 'myCustomPluginEvent'
}, function(someString, someObject) {
console.log(someString, someObject);
});
// Listen to 'debug' event emitted by anything
API.registerHandler({
emitter: '*',
event: 'debug'
}, function() {
console.log(arguments);
});
// Listen to 'debug' event emitted by any plugin
API.registerHandler({
emitter: 'plugin',
plugin: '*',
event: 'debug'
}, function() {
console.log(arguments);
});
Returns true if there is at least one handler for the given event, false otherwise.
Kind: instance method of API
Param | Type | Description |
---|---|---|
options | Object | string |
Options object or event name. |
options.emitter | string |
Can be either vapor , client , steamUser , steamFriends , steamTrading , plugin or * (which stands for 'any'). |
options.plugin | string |
If emitter is plugin , this is plugin's name. Use * for any. |
options.event | string |
Event name. |
Example
if(API.hasHandler({emitter: 'steamFriends', event: 'friendMsg'})) {
// do something ...
}
if(API.hasHandler('readFile')) {
// we can safely emit this event to read a file
}
Allows plugin to remove all handlers for a specific event.
Kind: instance method of API
Param | Type | Description |
---|---|---|
options | Object |
Options object. |
options.emitter | string |
Can be either vapor , client , steamUser , steamFriends , steamTrading , plugin or * (which stands for 'any'). |
options.plugin | string |
If emitter is plugin , this is plugin's name. Use * for any. |
options.event | string |
Event name. |
Returns wrapper for emitting 'message:*' events prefixed with plugin's name.
Available levels:
- log.debug
- log.info
- log.warn
- log.error
Kind: instance method of API
Returns: Object
- Logger.
Example
var log = VaporAPI.getLogger();
log.info('This is a regular info message...');
log.warn('...and this is a warning message.');
log.debug('String %s works too!', 'formatting');
Calls Vapor's internal webLogOn method.
Listen to cookies
event to receive new array of cookies and sessionid.
You should call this function ONLY if you believe cookies have expired, e.g. you logged into your account from another IP / browser and you are getting HTTP 403 etc.
You do NOT have to call this method on startup as it's automatically called by Vapor after successfully logging in.
Kind: instance method of API
Kind: global class
- Utils
- new Utils(Vapor)
.isAdmin(steamID) ⇒Boolean
- .getUserDescription(steamID, format) ⇒
string
- .stringToEnum(string, enumList) ⇒
number
- .enumToString(value, enumList) ⇒
string
- .accountIDToSteamID(accountID) ⇒
string
- .steamIDToAccountID(steamID) ⇒
number
- .getTimestamp(unixTimestamp, format) ⇒
string
Utils class constructor. Instance of this class is available via getUtils.
Param | Type | Description |
---|---|---|
Vapor | Object |
Vapor instance. |
Deprecated
Returns whether a user is admin or not.
This method will be removed in the next major version. Use built-in plugin 'admins' instead.
Kind: instance method of Utils
Returns: Boolean
- Result.
Param | Type | Description |
---|---|---|
steamID | string |
User's Steam ID. |
Returns easy-to-read user description.
Format allows placeholders:
%username
- for Steam username%steamid64
- for 64 bit SteamID%accountid
- for account ID
Kind: instance method of Utils
Returns: string
- User's description.
Param | Type | Description |
---|---|---|
steamID | string |
User's Steam ID. |
format | string |
Format string. |
Returns first enum value that contains the given string.
Kind: instance method of Utils
Returns: number
- Enum value or null if not found.
Param | Type | Description |
---|---|---|
string | string |
Enum name. |
enumList | Object |
List of enums from the Steam object. |
Example
// returns 5, which is equal to Steam.EPersonaState.LookingToTrade
var tradeState = utils.stringToEnum("trade", Steam.EPersonaState);
steamFriends.setPersonaState(tradeState);
Returns string description for the given enum value.
Kind: instance method of Utils
Returns: string
- Enum string description or null if not found.
Param | Type | Description |
---|---|---|
value | number |
Enum value. |
enumList | Object |
List of enums from the Steam object. |
Example
// returns "LookingToTrade"
var stateDescription = utils.stringToEnum(5, Steam.EPersonaState);
Converts account ID to 64 bit SteamID string.
Kind: instance method of Utils
Returns: string
- Converted 64 bit SteamID.
Param | Type | Description |
---|---|---|
accountID | number |
User's account ID. |
Converts 64 bit SteamID string to account ID.
Kind: instance method of Utils
Returns: number
- Account ID.
Param | Type | Description |
---|---|---|
steamID | string |
64 bit SteamID. |
Converts unix timestamp into formatted timestamp.
Kind: instance method of Utils
Returns: string
- Formatted timestamp.
Param | Type | Description |
---|---|---|
unixTimestamp | number |
Unix timestamp. |
format | string |
Timestamp format. |