Skip to content

Instantly share code, notes, and snippets.

@trevorstarick
Created April 24, 2013 19:34
Show Gist options
  • Save trevorstarick/5454896 to your computer and use it in GitHub Desktop.
Save trevorstarick/5454896 to your computer and use it in GitHub Desktop.
var steam = require("steam");
var fs = require('fs');
if (fs.existsSync('servers')) {
steam.servers = JSON.parse(fs.readFileSync('servers'));
}
var bot = new steam.SteamClient();
bot.logOn('traderbot', 'Batman12345');
bot.on('loggedOn', function(){
console.log("Logged on...");
bot.setPersonaState(steam.EPersonaState.Online);
});
bot.on('servers', function(servers) {
fs.writeFile('servers', JSON.stringify(servers));
});
bot.on('sentry', function(sentry) {
fs.writeFile('sentry', JSON.stringify(sentry));
});
bot.on('chatInvite', function(chatRoomID, chatRoomName, patronID) {
console.log('Got an invite to ' + chatRoomName + ' from ' + bot.users[patronID].playerName);
bot.joinChat(chatRoomID); // autojoin on invite
});
bot.on('message', function(source, message, type, chatter) {
// respond to both chat room and private messages
console.log('Received message: ' + message);
if (message == 'ping') {
bot.sendMessage(source, 'pong', steam.EChatEntryType.ChatMsg); // ChatMsg by default
}
if (message == '/whoami') {
bot.sendMessage(source, 'You are steam user '+source, steam.EChatEntryType.ChatMsg);
}
if (message == '/admin') {
bot.sendMessage(source, 'Admin features not enabled yet!',steam.EChatEntryType.ChatMsg);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment