Advertisement
KimeSnSOMs

Untitled

Jul 23rd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. 'use strict'
  2.  
  3.  
  4. const config = require("./config.js");
  5. const Config = require('config-js');
  6. const SteamUser = require('steam-user');
  7. const SteamTotp = require('steam-totp');
  8. const SteamCommunity = require('steamcommunity');
  9. const TradeofferManager = require('steam-tradeoffer-manager');
  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. // Вход в аккаунт с использованием config.js
  19.  
  20. const logOnOptions = {
  21. "accountName": config.steam.username,
  22. "password": config.steam.password,
  23. "twoFactorCode": SteamTotp.generateAuthCode(config.steam.twoFactorCode)
  24. };
  25.  
  26. client.logOn(logOnOptions);
  27.  
  28. // События которые происходят при успешном логине бота
  29.  
  30. client.on('loggedOn', () => {
  31. console.log('[!]Бот авторизовался!');
  32.  
  33. client.setPersona(SteamUser.Steam.EPersonaState.Online, config.steam.botname);
  34. client.gamesPlayed(730);
  35.  
  36. console.log('[!]Бот сейчас играет в CS:GO');
  37. });
  38.  
  39. // Функция проверки трейдов
  40.  
  41. client.on('webSession', (sessionid, cookies) => {
  42. manager.setCookies(cookies);
  43.  
  44. community.setCookies(cookies);
  45. community.startConfirmationChecker(config.steam.refreshInterval, config.steam.identity_secret);
  46. });
  47.  
  48. // Если кто-то добавил бота
  49.  
  50. client.on('friendRelationship', (steamid, relationship) => {
  51. if (relationship === 2) {
  52. console.log('[!]Кто-то добавил бота!');
  53. }
  54. });
  55.  
  56. // Принятие/отклонение трейдов
  57.  
  58. manager.on('newOffer', (offer) => {
  59. if (offer.itemsToGive.length === 0) {
  60. offer.accept((err, status) => {
  61. if (err) {
  62. console.log(err);
  63. } else {
  64. console.log(`[!]Трейд принят! Статус: ${status}.`);
  65.  
  66. }
  67. });
  68. } else {
  69. offer.decline((err) => {
  70. if (err) {
  71. console.log(err);
  72. } else {
  73. console.log(`[!]Трейд отклонён! (Попытка вывода предметов бота).`)
  74. }
  75. });
  76.  
  77. }
  78. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement