Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
990
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. username = 'Katjabot'; // Bot's Steam Username
  2. password = 'yunogasai1611'; // Bot's Steam Password
  3.  
  4. // Define all our included variables
  5. var steam = require('steam');
  6. var winston = require('winston');
  7.  
  8. //These are included node modules that don't require installation via npm
  9. var readline = require('readline');
  10. var fs = require('fs');
  11.  
  12. // Setup readline to read from console. This is used for Steam Guard codes.
  13. var rl = readline.createInterface({
  14. input: process.stdin,
  15. output: process.stdout
  16. });
  17.  
  18. // Setup logging to file and console
  19. var logger = new (winston.Logger)({
  20. transports: [
  21. new (winston.transports.Console)({
  22. colorize: true,
  23. level: 'debug'
  24. }),
  25. new (winston.transports.File)({
  26. level: 'info',
  27. timestamp: true,
  28. filename: 'katjadump.log',
  29. json: false
  30. })
  31. ]
  32. });
  33.  
  34. // Initialize the Steam client
  35. var client = new steam.SteamClient();
  36.  
  37. // Now we can finally start doing stuff! Let's try logging in.
  38. client.logOn({
  39. accountName: username,
  40. password: password
  41. });
  42.  
  43. // After successful login...
  44. client.on('loggedOn', function() {
  45. logger.info('Logged on to Steam');
  46. // Optional: Rename the bot on login.
  47. client.setPersonaName("Katjabot");
  48. // Make sure we're not displaying as online until we're ready
  49. client.setPersonaState(steam.EPersonaState.Offline);
  50. });
  51.  
  52. // If a user adds me...
  53. client.on('friend', function(steamID, relationship) {
  54. if (relationship == steam.EFriendRelationship.RequestRecipient) {
  55. logger.info('[' + steamID + '] Accepted friend request');
  56. client.addFriend(steamID);
  57. }
  58. else if (relationship == steam.EFriendRelationship.None) {
  59. logger.info('[' + steamID + '] Un-friended');
  60. }
  61. });
  62.  
  63. // If a user messages me through Steam...
  64. client.on('friendMsg', function(steamID, message, type) {
  65. if (type == steam.EChatEntryType.ChatMsg) { // Regular chat message
  66. logger.info('[' + steamID + '] MSG: ' + message); // Log it
  67. 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\*');
  68. }
  69. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement