Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- username = 'Katjabot'; // Bot's Steam Username
- password = 'yunogasai1611'; // Bot's Steam Password
- // Define all our included variables
- var steam = require('steam');
- var winston = require('winston');
- //These are included node modules that don't require installation via npm
- var readline = require('readline');
- var fs = require('fs');
- // Setup readline to read from console. This is used for Steam Guard codes.
- var rl = readline.createInterface({
- input: process.stdin,
- output: process.stdout
- });
- // Setup logging to file and console
- var logger = new (winston.Logger)({
- transports: [
- new (winston.transports.Console)({
- colorize: true,
- level: 'debug'
- }),
- new (winston.transports.File)({
- level: 'info',
- timestamp: true,
- filename: 'katjadump.log',
- json: false
- })
- ]
- });
- // Initialize the Steam client
- var client = new steam.SteamClient();
- // Now we can finally start doing stuff! Let's try logging in.
- client.logOn({
- accountName: username,
- password: password
- });
- // After successful login...
- client.on('loggedOn', function() {
- logger.info('Logged on to Steam');
- // Optional: Rename the bot on login.
- client.setPersonaName("Katjabot");
- // Make sure we're not displaying as online until we're ready
- client.setPersonaState(steam.EPersonaState.Offline);
- });
- // If a user adds me...
- client.on('friend', function(steamID, relationship) {
- if (relationship == steam.EFriendRelationship.RequestRecipient) {
- logger.info('[' + steamID + '] Accepted friend request');
- client.addFriend(steamID);
- }
- else if (relationship == steam.EFriendRelationship.None) {
- logger.info('[' + steamID + '] Un-friended');
- }
- });
- // If a user messages me through Steam...
- client.on('friendMsg', function(steamID, message, type) {
- if (type == steam.EChatEntryType.ChatMsg) { // Regular chat message
- logger.info('[' + steamID + '] MSG: ' + message); // Log it
- client.sendMessage(steamID, 'Hello, I\'m Katjabot, a chatbot and your new friend. I can\'t do much at the moment, so I apologise. Have a hug. \*hugs\*');
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement