I am trying to get a node.js script to simulate a keystroke, like an up arrow or a button. In particular, I am trying to make a clone of Twitch Plays Pokemon . In principle, whenever a command (up, down, left, right, a, b, select, start) is sent via IRC, the server simulates a keystroke, which, in turn, controls the game emulator itself. So far I have written this with the IRC module for node.js:
var config = {
channels: ["#tron"],
server: "irc.freenode.net",
botName: "wyatt"
};
var irc = require("irc");
var bot = new irc.Client(config.server, config.botName, {
channels: config.channels
});
var commandHandler = function(from, text) {
if(text.toLowerCase() === "up"||text.toLowerCase() === "down"||text.toLowerCase() === "left"||text.toLowerCase() === "right"||text.toLowerCase() === "a"||text.toLowerCase() === "b"||text.toLowerCase() === "select"||text.toLowerCase() === "start") {
bot.say(config.channels[0], from.toUpperCase() + " sent the " + text.toUpperCase() + " command!");
} else {
bot.say(config.channels[0], from.toUpperCase() + ", that wasn't a valid command!");
}
};
bot.addListener("message", function(from, to, text, message) {
commandHandler(from, text);
});
To run my script, I will enter node scriptName.js in the command line. I am using Windows 7.
This connects to the #tron freenode channel, which I use for testing purposes, since it seems to be mostly inactive.
, "NIMAID LEFT!", "NIMAID, !". , . , , , script - switch.
, , , node.js JQuery - . .
TL;DR: node.js script , Windows 7.
?