Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
pokemon-showdown-api
Advanced tools
A low-level library for connecting to and interacting with the Pokemon Showdown server
pokemon-showdown-api
is a low-level library for connecting to and interacting
with the Pokemon Showdown server.
This package is under development. Its documentation is not complete and there remain additional events to be added, but it is mostly API-stable.
This package presents a low-level API for interacting with Pokemon Showdown servers, and tries to avoid making any assumptions about the consumer's goals. In particular, this API is designed so that other APIs can be built on top of it (for example, to add logic for handling rooms or battles).
Explicit goals:
(Goal 1 implies that no O(n) logs can be stored, precluding the storing of messages or rooms. If a consumer needs these features, they should implement this on their own.)
These lead to two explicit non-goals:
Instead, this API is built to enable additional libraries to provide such functionality.
To install, run npm install pokemon-showdown-api
.
(If you want to use a REPL to try and interact with Pokemon Showdown from the
command line, try out npm install --global pokemon-showdown-api
and use
pokerepl
.)
In order to instantiate a client, pass the server websocket URL and login server URL. Both are optional, defaulting to the official Pokemon Showdown servers.
var PokeClient = require('pokemon-showdown-api');
var client = new PokeClient();
// By default, this is equivalent to:
// var client = new PokeClient('ws://sim.smogon.com:8000/showdown/websocket', 'https://play.pokemonshowdown.com/action.php');
The client will emit events for consumers to listen on. The client does not store any messages, instead delegating this responsibility to consumers. (Storing messages uses memory over time, and not all consumers may need this.)
client.connect();
// Websocket has connected.
client.on('ready', function() {
client.login('username', 'password');
});
// Successful login.
client.on('login', function(user) {
console.log('Logged in as:', user);
});
// A battle challenge from another user has been received.
client.on('challenge', function(user) {
console.log(user, 'would like to battle!');
});
// Login failed.
client.on('error:login', function(err) {
console.log('Error encountered while logging in:', err.message);
});
In general, any sort of message can be sent using client.send
. This package
also provides a convenience method authentication using
client.login(username, password)
.
For more details, see the API docs.
For notes on protocol specifics, see Pokemon Showdown Protocol, command parsing source code, and socket message parsing source code.
Pokemon Showdown is effectively implemented as a fancy chat room. Some of these are considered regular "chat" rooms, and others are considered "battle" rooms. Within battle rooms, a battle is conducted by sending special chat messages back and forth, with the server validating each message.
Authentication occurs by talking to a separate authentication server. The process is as follows:
challstr
) upon connecting to the main serverchallstr
along with a proposed username (and password, if needed)
to the login serverassertion
, which is passed to the main server
to prove ownership of a username.stdin
and emitting output
on stdout
to allow this library to be embedded in other projects.FAQs
A low-level library for connecting to and interacting with the Pokemon Showdown server
We found that pokemon-showdown-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.