Advertisement
Guest User

Untitled

a guest
Aug 12th, 2018
884
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. const SteamUser = require('steam-user');
  2. const SteamTotp = require('steam-totp');
  3. const SteamCommunity = require('steamcommunity');
  4. const TradeOfferManager = require('steam-tradeoffer-manager');
  5. const config = require('./config.json');
  6.  
  7. const client = new SteamUser();
  8. const community = new SteamCommunity();
  9. const manager = new TradeOfferManager ({
  10. steam: client,
  11. community: community,
  12. language: 'en'
  13. });
  14.  
  15. const logOnOptions = {
  16. accountName: config.username,
  17. password: config.password,
  18. twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret)
  19. }
  20. };
  21.  
  22. client.logOn(logOnOptions);
  23.  
  24. client.on('loggedOn', () => {
  25. console.log('succesfully logged on.');
  26. client.setPersona(SteamUser.Steam.EPersonaState.Online);
  27. client.gamesPlayed(["Custom Game",440]);
  28. });
  29.  
  30. client.on("friendMessage", function(steamID, message) {
  31. if (message == "!help") {
  32. client.chatMessage(steamID, "Jestem botem ktory skupuje itemy z CS:GO PUBG TF2 oraz H1Z1");
  33. }
  34. });
  35.  
  36. client.on('webSession', (sessionid, cookies) => {
  37. manager.setCookies(cookies);
  38.  
  39. community.setCookies(cookies);
  40. community.startConfirmationChecker(20000, config.identitySecret);
  41. });
  42.  
  43. function acceptOffer(offer) {
  44. offer.accept((err) => {
  45. community.checkConfirmations();
  46. console.log("We Accepted an offer");
  47. if (err) console.log("There was an error accepting the offer.");
  48. });
  49. }
  50.  
  51. function declineOffer( ) {
  52. offer.decline((err) => {
  53. console.log("We Declined an offer");
  54. if (err) console.log("There was an error declining the offer.");
  55. });
  56. }
  57.  
  58. client.setOption("promptSteamGuardCode", false);
  59.  
  60. manager.on('newOffer', (offer) => {
  61. if (offer.partner.getSteamID64() === config.ownerID) {
  62. acceptOffer(offer);
  63. } else {
  64. declineOffer(offer);
  65. }
  66.  
  67. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement