Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 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. var SteamID = TradeOfferManager.SteamID;
  8.  
  9.  
  10. const client = new SteamUser();
  11. const community = new SteamCommunity();
  12. const manager = new TradeOfferManager ({
  13. steam: client,
  14. community: community,
  15. language: 'en'
  16. });
  17.  
  18. const logOnOptions = {
  19. accountName: config.username,
  20. password: config.password,
  21. twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret)
  22. };
  23.  
  24. client.logOn(logOnOptions);
  25.  
  26. client.on('loggedOn', () => {
  27. console.log('succesfully logged on.');
  28. client.setPersona(SteamUser.Steam.EPersonaState.Online);
  29. client.gamesPlayed(["Trading",730]);
  30. });
  31.  
  32. client.on("friendMessage", function(steamID, message) {
  33. if (message == "!help" || message == "!info") {
  34. client.chatMessage(steamID, "It's a donation bot. We are trading with CSGOTrash too. Bot Created buy TheMaster_07");
  35. } else {
  36. client.chatMessage(steamID, "Type !help if you need some,or type !info to get info. Bot Created buy TheMaster_07");
  37. }
  38. });
  39. client.on('webSession', (sessionid, cookies) => {
  40. manager.setCookies(cookies);
  41.  
  42. community.setCookies(cookies);
  43. community.startConfirmationChecker(20000, config.identitySecret);
  44. });
  45. function acceptOffer(offer) {
  46. offer.accept((err) => {
  47. community.checkConfirmations();
  48. console.log("We Accepted an offer from" + offer.partner.getSteamID64());
  49. if (err) console.log("There was an error accepting the offer.");
  50. });
  51. }
  52.  
  53. function declineOffer(offer) {
  54. offer.decline((err) => {
  55. console.log("We Declined an offer from" + offer.partner.getSteamID64());
  56. if (err) console.log("There was an error declining the offer.");
  57. });
  58. }
  59.  
  60. client.setOption("promptSteamGuardCode", false);
  61.  
  62. manager.on('newOffer', (offer) =>
  63. {
  64. if (offer.partner.getSteamID64() === config.ownerID)
  65. {
  66. acceptOffer(offer);
  67. }
  68. else
  69. {
  70. var myItems = offer.Items.GetMyItems();
  71. var theirItems = offer.Items.GetTheirItems();
  72.  
  73. if (myItems.Count > 0)
  74. {
  75. declineOffer(offer);
  76. }
  77. else if (myItems.Count == 0)
  78. {
  79. acceptOffer(offer);
  80. }
  81.  
  82. }
  83. };
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. client.on('friendRelationship', function(sid, relationship) {
  92. if (relationship == SteamUser.EFriendRelationship.RequestRecipient) {
  93. console.log("We recieved a friend request from "+sid);
  94. client.addFriend(sid, function (err, name) {
  95. if (err) {
  96. console.log(err);
  97. return;
  98. }
  99. console.log("Accepted user with the name of "+name)
  100. })
  101. }
  102.  
  103. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement