· 10 years ago · Mar 22, 2016, 05:30 PM
1var fs = require('fs');
2var crypto = require('crypto');
3var config = require('./config.js');
4var Steam = require('steam');
5var SteamWebLogOn = require('steam-weblogon');
6var getSteamAPIKey = require('steam-web-api-key');
7var SteamTradeOffers = require('steam-tradeoffers');
8var SteamTotp = require('steam-totp');
9var SteamcommunityMobileConfirmations = require('steamcommunity-mobile-confirmations');
10var SteamCommunity = require('steamcommunity');
11var mysql = require('mysql');
12var url = require('url');
13var requestify = require('requestify');
14
15var details = {
16 account_name: config.bot.username,
17 password: config.bot.password,
18 two_factor_code: generatekey(config.bot.shared_secret)
19};
20
21var steamClient = new Steam.SteamClient();
22var steamUser = new Steam.SteamUser(steamClient);
23var steamFriends = new Steam.SteamFriends(steamClient);
24var steamWebLogOn = new SteamWebLogOn(steamClient, steamUser);
25var offers = new SteamTradeOffers();
26
27var status = false;
28
29var hash = require('crypto').createHash('sha1');
30hash.update(Math.random().toString());
31hash = hash.digest('hex');
32var device_id = 'android:' + hash;
33
34function steamBotLogger(log) {
35 console.log("[БОТ] "+log);
36}
37
38function EscrowLogger(log) {
39 console.info(log);
40}
41
42function generatekey(secret) {
43 code = SteamTotp.generateAuthCode(secret);
44 return code;
45}
46
47var db = mysql.createConnection({ //Создаём подключение к базе
48 supportBigNumbers: true,
49 bigNumberStrings: true,
50 host: '',
51 user: '',
52 password: '',
53 database: ''
54});
55
56db.connect(function(e) { //ЕÑли подключение уÑпешно пишем в конÑоль
57 if (e) {
58 console.log(e);
59 } else {
60 console.log("[Mysql] Соединение Ñ Ð±Ð°Ð·Ð¾Ð¹ уÑтановлено!");
61 }
62});
63
64steamClient.connect(); //Подключение к steam
65steamClient.on('debug', steamBotLogger);
66steamClient.on('connected', function () {
67 steamUser.logOn(details);
68});
69
70
71steamClient.on('logOnResponse', function (logonResp) { //Вход в аккаунт
72 if (logonResp.eresult === Steam.EResult.OK) {
73 steamBotLogger('ЗалогинилÑÑ!');
74 steamFriends.setPersonaState(Steam.EPersonaState.LookingToTrade);
75
76 steamWebLogOn.webLogOn(function (sessionID, newCookie) {
77 getSteamAPIKey({
78 sessionID: sessionID,
79 webCookie: newCookie
80 }, function (err, APIKey) {
81 offers.setup({
82 sessionID: sessionID,
83 webCookie: newCookie,
84 APIKey: APIKey
85 }, function (err) {
86 WebSession = true;
87 globalSession = sessionID;
88 WebCookies = newCookie;
89 steamBotLogger('Готов к принÑтию трÑйдов!');
90 var checkDeposite = setInterval(deposite, 10000);
91 var checkTrade2 = setInterval(checkTrade, 5000);
92 //Каждые 3000 Ð¼Ñ Ñ‡ÐµÐºÐ°ÐµÐ¼ новые депозиты
93 var checkWithdraw = setInterval(withdraw, 10000); //и на вывод вещей
94 AcceptMobileOffer(); //и на вывод вещей
95 });
96
97 });
98 });
99 }
100});
101function deposite() { //Отправка трейдов
102 if(!status){
103 db.query("SELECT * FROM botTask WHERE status = '1' && type = 'deposit' ORDER BY id DESC", function(err, items) { //ÑÑ‚Ð°Ñ‚ÑƒÑ 1 - нужно отправить, 3 - уÑпешно отправленно, 4 - ошибка
104 if (err){
105 steamBotLogger(err);
106 } //ЕÑли ошибка - выводим ошибку в конÑоль
107 if (items.length > 0) {
108 status = true;//ЕÑли вещей на отправку больше 0
109 items.forEach(function(item, i, items) { //Ðачинаем отправку
110 var user = db.query("SELECT * FROM steam_users WHERE steamid = '" + item.steamid + "'", function(err, data) { //Берём steamid Ð´Ð»Ñ Ð¾Ñ‚Ð¿Ñ€Ð°Ð²ÐºÑ‚
111 if (!err) { //ЕÑли нету ошибок продолжаем
112 data = data[0];
113 if (typeof data.tradeurl != "undefined" && data.tradeurl != "") { //ЕÑли еÑть ÑÑылка на обмен
114 var tradeurl = url.parse(data.tradeurl, true); //Берём в переменную ÑÑылку на обмен
115 if (tradeurl.query.partner != "" && tradeurl.query.token != "") { //ЕÑли Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ð°Ñ Ñ ÑÑылкой на обмен не пуÑта
116 var itemsFromMee = [],
117 classids = [];
118 classids = JSON.parse(item.weaponid);
119 for (var i = 0; i < classids.length; i++) {
120 itemsFromMee[i] = {
121 appid: 730, //Appid игры
122 contextid: 2,
123 amount: 1,
124 assetid: classids[i] //Id предмета
125 }
126 }
127 offers.makeOffer({ //ОтправлÑем обмен
128 partnerSteamId: item.steamid, //Patcher ÑÑылки на обмен
129 accessToken: tradeurl.query.token, //acessToken
130 itemsFromMe: [],
131 itemsFromThem: itemsFromMee,
132 message: 'Deposite on CSGO2x.ru [ID: '+item.id+' & Secter: '+item.secret+']' //Сообщение к трейду
133 }, function(err, response) { //ЕÑли ошибки Ñтавим ÑÑ‚Ð°Ñ‚ÑƒÑ Ð¾Ñ‚Ð¿Ñ€Ð°Ð²ÐºÐ¸ 4 (- ошибка)
134 if (err) {
135 console.log(err);
136 status = false;
137 db.query("UPDATE botTask SET status = '4', message = 'Ошибка! Больше информации узнайте у админиÑтрации.' WHERE id = '" + item.id + "'");
138 } else {
139 status = false;
140 steamBotLogger("Трейдоффер â„–"+response.tradeofferid+" уÑпешно отправлен");
141 db.query("UPDATE botTask SET status = '3', tradeofferid = "+response.tradeofferid+", status_tradeoffer = '2' WHERE id = '" + item.id + "'");
142 }
143 });
144 } else { //ЕÑли ошибка то Ñтавим ÑÑ‚Ð°Ñ‚ÑƒÑ 4
145 db.query("UPDATE botTask SET status = '4', message = 'Ошибка! Ðе ÐºÐ¾Ñ€Ñ€ÐµÐºÑ‚Ð½Ð°Ñ ÑÑылка обмена.' WHERE id = '" + item.id + "'");
146 status = false;
147 }
148 } else { //ЕÑли ошибка...
149 status = false;
150 db.query("UPDATE botTask SET status = '4', message = 'Ошибка! Ðе ÐºÐ¾Ñ€Ñ€ÐµÐºÑ‚Ð½Ð°Ñ ÑÑылка обмена.' WHERE id = '" + item.id + "'");
151 }
152 }
153 });
154 });
155 }
156 });
157 }else{
158 steamBotLogger("Я занÑÑ‚!");
159 }
160}
161function checkTrade(){
162 if(!status){
163 db.query("SELECT * FROM botTask WHERE status = '3' AND status_tradeoffer = '2'", function(err, tradeoffers){
164 if(tradeoffers.length > 0){
165 tradeoffers.forEach(function(tradeofferid, i, tradeoffers){
166 if(tradeofferid.type.indexOf("withdraw") !== -1){
167 var offerID = tradeofferid.tradeofferid;
168 var value = tradeofferid.coins;
169 var steamid = tradeofferid.steamid;
170 offers.getOffer({
171 tradeofferid: offerID
172 }, function(err, response2){
173 if(err){
174 steamBotLogger('Ошибка при определении ÑтатуÑа трейдофера '+offerID);
175 }else{
176 if(response2.response.offer.trade_offer_state == 3){
177 steamBotLogger("Обмен был принÑÑ‚!");
178 removeBalance(steamid, value);
179 db.query("UPDATE botTask SET status_tradeoffer = '3' WHERE tradeofferid = '"+offerID+"'");
180 }else if(response2.response.offer.trade_offer_state == 7){
181 steamBotLogger("Обмен был удален, как так обмен №"+offerID+" был отменен!");
182 db.query("DELETE FROM botTask WHERE tradeofferid = '"+offerID+"'");
183 }
184 }
185 });
186 }else{
187 var offerID = tradeofferid.tradeofferid;
188 var value = tradeofferid.coins;
189 var steamid = tradeofferid.steamid;
190 offers.getOffer({
191 tradeofferid: offerID
192 }, function(err, response2){
193 if(err){
194 steamBotLogger('Ошибка при определении ÑтатуÑа трейдофера '+offerID);
195 }else{
196 if(response2.response.offer.trade_offer_state == 3){
197 steamBotLogger("Обмен был принÑÑ‚!");
198 addBalance(steamid, value);
199 db.query("UPDATE botTask SET status_tradeoffer = '3' WHERE tradeofferid = '"+offerID+"'");
200 }else if(response2.response.offer.trade_offer_state == 7){
201 steamBotLogger("Обмен был удален, как так обмен №"+offerID+" был отменен!");
202 db.query("DELETE FROM botTask WHERE tradeofferid = '"+offerID+"'");
203 }
204 }
205 });
206 }
207 });
208 }
209 });
210 }else{
211 steamBotLogger("Я занÑÑ‚!");
212 }
213}
214function addBalance(steamid, amt){
215 db.query("SELECT balance FROM steam_users WHERE steamid="+steamid+"" ,function(err, row){
216 if(err){
217 steamBotLogger("Человека Ñ steamid = "+steamid+" нет!");
218 }else{
219 console.log(row[0]);
220 balance = parseInt(row[0].balance, 10);
221 amt = parseInt(amt, 10);
222 balance = amt+balance;
223 db.query("UPDATE steam_users SET balance = "+balance+" WHERE steamid = "+steamid);
224 }
225 });
226
227}
228function removeBalance(steamid, amt){
229 db.query("SELECT balance FROM steam_users WHERE steamid="+steamid+"" ,function(err, row){
230 if(err){
231 steamBotLogger("Человека Ñ steamid = "+steamid+" нет!");
232 }else{
233 console.log(row[0]);
234 balance = parseInt(row[0].balance, 10);
235 amt = parseInt(amt, 10);
236 balance = balance-amt;
237 db.query("UPDATE steam_users SET balance = "+balance+" WHERE steamid = "+steamid);
238 }
239 });
240
241}
242function withdraw() {
243if(!status){
244 db.query("SELECT * FROM botTask WHERE status = '1' && type = 'withdraw' ORDER BY id DESC", function(err, items) { //ÑÑ‚Ð°Ñ‚ÑƒÑ 1 - нужно отправить, 3 - уÑпешно отправленно, 4 - ошибка
245 if (err) { steamBotLogger(err); status = false; }; //ЕÑли ошибка - выводим ошибку в конÑоль
246 if (items.length > 0) { //ЕÑли вещей на отправку больше 0
247 status = true;
248 items.forEach(function(item, i, items) { //Ðачинаем отправку
249 var user = db.query("SELECT * FROM steam_users WHERE steamid = '" + item.steamid + "'", function(err, data) { //Берём steamid Ð´Ð»Ñ Ð¾Ñ‚Ð¿Ñ€Ð°Ð²ÐºÑ‚
250 if (!err) { //ЕÑли нету ошибок продолжаем
251 data = data[0];
252 if (typeof data.tradeurl != "undefined" && data.tradeurl != "") { //ЕÑли еÑть ÑÑылка на обмен
253 var tradeurl = url.parse(data.tradeurl, true); //Берём в переменную ÑÑылку на обмен
254 if (tradeurl.query.partner != "" && tradeurl.query.token != "") { //ЕÑли Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ð°Ñ Ñ ÑÑылкой на обмен не пуÑтаÑ
255 var itemsFromMe = [],
256 classids = [];
257 classids = JSON.parse(item.weaponid);
258 for (var i = 0; i < classids.length; i++) {
259 itemsFromMe[i] = {
260 appid: 730, //Appid игры
261 contextid: 2,
262 amount: 1,
263 assetid: classids[i] //Id предмета
264 }
265 }
266 offers.makeOffer({ //ОтправлÑем обмен
267 partnerSteamId: item.steamid, //Patcher ÑÑылки на обмен
268 accessToken: tradeurl.query.token, //acessToken
269 itemsFromMe: itemsFromMe,
270 itemsFromThem: [],
271 message: 'Вывод Ñ Ñайта csgyard.ru' //Сообщение к трейду
272 }, function(err, response) { //ЕÑли ошибки Ñтавим ÑÑ‚Ð°Ñ‚ÑƒÑ Ð¾Ñ‚Ð¿Ñ€Ð°Ð²ÐºÐ¸ 4 (- ошибка)
273 if (err) {
274 steamBotLogger(err);
275 db.query("UPDATE botTask SET status = '4', message = 'Ошибка! Больше информации узнайте у админиÑтрации.' WHERE id = '" + item.id + "'");
276 status = false;
277 } else {
278 AcceptMobileOffer();
279 db.query("UPDATE botTask SET status = '3', tradeofferid = "+response.tradeofferid+", status_tradeoffer = '2' WHERE id = '" + item.id + "'");
280 status = false;
281 }
282 });
283 } else { //ЕÑли ошибка то Ñтавим ÑÑ‚Ð°Ñ‚ÑƒÑ 4
284 status = false;
285 db.query("UPDATE botTask SET status = '4', message = 'Ошибка! Ðе ÐºÐ¾Ñ€Ñ€ÐµÐºÑ‚Ð½Ð°Ñ ÑÑылка обмена.' WHERE id = '" + item.id + "'");
286 }
287 } else { //ЕÑли ошибка...
288 status = false;
289 db.query("UPDATE botTask SET status = '4', message = 'Ошибка! Ðе ÐºÐ¾Ñ€Ñ€ÐµÐºÑ‚Ð½Ð°Ñ ÑÑылка обмена.' WHERE id = '" + item.id + "'");
290 }
291 }
292 });
293 });
294 }
295 });
296 }else{
297 steamBotLogger("Я занÑÑ‚!");
298 }
299}
300
301/*function getOfferStatus() {
302 offers.getOffer({tradeOfferId: offer.offerid}, function (err, body) {
303 if (body.response.offer) {
304 var offerCheck = body.response.offer;
305 if (offerCheck.trade_offer_state == 2) {
306 checkedProcceed = false;
307 console.log('Error 0');
308 return;
309 }
310 if (offerCheck.trade_offer_state == 3) {
311 console.log('Error 1');
312 } else {
313 console.log('Error 2');
314 }
315 }
316 })
317}*/
318
319function AcceptMobileOffer() {
320 // Ð˜Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð´Ð»Ñ Ð¼Ð¾Ð±Ð¸Ð»ÑŒÐ½Ñ‹Ñ… подтверждений
321 var steamcommunityMobileConfirmations = new SteamcommunityMobileConfirmations(
322 {
323 steamid: config.bot.steamid,
324 identity_secret: config.bot.identity_secret,
325 device_id: device_id,
326 webCookie: WebCookies,
327 });
328
329 steamcommunityMobileConfirmations.FetchConfirmations((function (err, confirmations) {
330 if (err) {
331 console.log(err);
332 return;
333 }
334 console.log('[Escrow] К подтверждению: ' + confirmations.length+ " обменов'");
335 if (!confirmations.length) {
336 return;
337 }
338 steamcommunityMobileConfirmations.AcceptConfirmation(confirmations[0], (function (err, result) {
339 if (err) {
340 console.log(err);
341 AcceptMobileOffer();
342 }
343 console.log('Результат принÑтиÑ: ' + result);
344 }).bind(this));
345 }).bind(this));
346}
347
348function getErrorCode(err, callback) {
349 var errCode = 0;
350 var match = err.match(/\(([^()]*)\)/);
351 if (match != null && match.length == 2) errCode = match[1];
352 callback(errCode);
353}
354
355//sendTradeOffer(730, 76561198180634807, 'yD4Ft8bh', 1, 'govno', 1);
356
357/*
358steamClient.on('logOnResponse', function(logonResp) {
359 if (logonResp.eresult === Steam.EResult.OK) {
360 steamBotLogger('Бот авторизовалÑÑ!');
361 steamFriends.setPersonaState(Steam.EPersonaState.LookingToTrade);
362
363 steamWebLogOn.webLogOn(function(sessionID, newCookie) {
364 function trademobile(){
365var hash = require('crypto').createHash('sha1');
366hash.update(Math.random().toString());
367hash = hash.digest('hex');
368device_id = 'android:' + hash;
369var steamcommunityMobileConfirmations = new SteamcommunityMobileConfirmations(
370{
371 steamid: config.bot.steamid,
372identity_secret: config.bot.identity_secret,
373device_id: this.device_id,
374 webCookie: newCookie,
375});
376steamcommunityMobileConfirmations.FetchConfirmations((function (err, confirmations)
377{
378 if (err)
379 {
380 console.error(err);
381 return;
382 }
383 if ( ! confirmations.length)
384 {
385 return;
386 }
387 steamcommunityMobileConfirmations.AcceptConfirmation(confirmations[0], (function (err, result)
388 {
389 if (err)
390 {
391 console.console.error(err);
392 return;
393 }
394 console.log('Результат: ' + result);
395 }).bind(this));
396}).bind(this));
397 setTimeout(function(){ trademobile()}, 1000)
398}
399trademobile();
400 getSteamAPIKey({
401 sessionID: sessionID,
402 webCookie: newCookie
403 }, function(err, APIKey) {
404 offers.setup({
405 sessionID: sessionID,
406 webCookie: newCookie,
407 APIKey: APIKey
408 }, function(err){
409 WebSession = true;
410 globalSession = sessionID;
411 });
412
413 });
414 });
415 }
416});
417
418function AcceptMobileOffer() {
419 // Ð˜Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð´Ð»Ñ Ð¼Ð¾Ð±Ð¸Ð»ÑŒÐ½Ñ‹Ñ… подтверждений
420 var steamcommunityMobileConfirmations = new SteamcommunityMobileConfirmations(
421 {
422 steamid: config.bot.steamid,
423 identity_secret: config.bot.identity_secret,
424 device_id: device_id,
425 webCookie: WebCookies,
426 });
427
428 steamcommunityMobileConfirmations.FetchConfirmations((function (err, confirmations) {
429 if (err) {
430 console.log(err);
431 return;
432 }
433 console.tag('БОТ', 'Мобильное подтверждение').log('Трейдов в ожидании: ' + confirmations.length);
434 if (!confirmations.length) {
435 return;
436 }
437 steamcommunityMobileConfirmations.AcceptConfirmation(confirmations[0], (function (err, result) {
438 if (err) {
439 console.log(err);
440 return;
441 }
442 console.tag('БОТ', 'Мобильное подтверждение').log('Результат: ' + result);
443 }).bind(this));
444 }).bind(this));
445}
446
447function handleOffers() {
448 offers.getOffers({
449 get_received_offers: 1,
450 active_only: 1
451 }, function (error, body) {
452 if (
453 body
454 && body.response
455 && body.response.trade_offers_received
456 ) {
457 body.response.trade_offers_received.forEach(function (offer) {
458 if (offer.trade_offer_state == 2) {
459 if (offer.items_to_give != null && config.admins.indexOf(offer.steamid_other) != -1) {
460 console.log('Трейд #' + offer.tradeofferid + ' От: ÐДМИÐÐ ' + offer.steamid_other);
461 offers.acceptOffer({tradeOfferId: offer.tradeofferid});
462 return;
463 }
464 if (offer.items_to_give != null) {
465 offers.declineOffer({tradeOfferId: offer.tradeofferid});
466 console.log('ОБМЕРОТКЛÐÐÐÐ!');
467 return;
468 }
469 offers.getTradeHoldDuration({tradeOfferId: offer.tradeofferid}, function (err, response) {
470 if (err) {
471 steamBotLogger('Отклонение. Ðету ESCROW: ' + err);
472 offers.declineOffer({tradeOfferId: offer.tradeofferid});
473 steamBotLogger('Отклонение. Ðету ESCROW: ' + offer.tradeofferid);
474 return;
475 } else if (response.their != 0) {
476 steamBotLogger('response.their: ' + response.their);
477 offers.declineOffer({tradeOfferId: offer.tradeofferid});
478 steamBotLogger('Отклонение. Ðету ESCROW: ' + offer.tradeofferid);
479 return;
480 }
481 });
482 if (offer.items_to_receive != null && offer.items_to_give == null) {
483 checkingOffers.push(offer.tradeofferid);
484 console.log('Трейд #' + offer.tradeofferid + ' От: ' + offer.steamid_other);
485 return;
486 }
487 }
488 });
489 }
490 });
491}
492
493steamUser.on('tradeOffers', function(number) {
494 console.log('Обменов: ' + number);
495 if (number > 0) {
496 handleOffers();
497 }
498});
499
500var sendTradeOffer = function(offerJson){ //Отправка обмена
501 var offer = JSON.parse(offerJson);
502 try {
503 offers.loadMyInventory({
504 appId: 730,
505 contextId: 2
506 }, function (err, items) {
507 var itemsFromMe = [];
508
509 items.forEach(function(item){
510 if(item.id == offer.itemId){
511 itemsFromMe[0] = {
512 appid: 730,
513 contextid: 2,
514 amount: item.amount,
515 assetid: item.id
516 };
517 }
518 });
519
520function getErrorCode(err, callback){
521 var errCode = 0;
522 var match = err.match(/\(([^()]*)\)/);
523 if(match != null && match.length == 2) errCode = match[1];
524 callback(errCode);
525}
526
527 if (itemsFromMe.length > 0) {
528 offers.makeOffer({
529 partnerSteamId: offer.partnerSteamId,
530 accessToken: offer.accessToken,
531 itemsFromMe: itemsFromMe,
532 itemsFromThem: [],
533 message: 'Вывод вещи Ñ CSGO2x.RU'
534 }, function (err, response) {
535 if (err) {
536 console.error('Error to send offer. Error: ' + err);
537 getErrorCode(err.message, function(errCode){
538 sendProcceed = false;
539 });
540 sendProcceed = false;
541 }
542 });
543 }else{
544 console.log('Предмет не найден!');
545 setItemStatus(offer.id, 2);
546 }
547 });
548
549 }catch(ex){
550 console.error('Error to send the item');
551 sendProcceed = false;
552 }
553};*/
554
555/*
556var logOnOptions = {
557 account_name: config.bot.username,
558 password: config.bot.password,
559 two_factor_code: SteamTotp.generateAuthCode(config.bot.shared_secret)
560};
561
562function gucode(){
563 console.log('Код авторизиции '+SteamTotp.generateAuthCode(config.bot.shared_secret));
564 setTimeout(function(){ gucode() }, 30000)
565}
566gucode();
567var authCode = '59CXP'; // code received by email
568
569try {
570 logOnOptions.sha_sentryfile = getSHA1(fs.readFileSync('sentry'));
571} catch (e) {
572
573 if (authCode !== '') {
574 logOnOptions.auth_code = authCode;
575 }
576}
577function getSHA1(bytes) {
578 var shasum = crypto.createHash('sha1');
579 shasum.end(bytes);
580 return shasum.read();
581}
582
583var steamClient = new Steam.SteamClient();
584var steamUser = new Steam.SteamUser(steamClient);
585var steamFriends = new Steam.SteamFriends(steamClient);
586var steamWebLogOn = new SteamWebLogOn(steamClient, steamUser);
587var offers = new SteamTradeOffers();
588
589var checkingOffers = [],
590 WebSession = false,
591 globalSession;
592
593function steamBotLogger(log){
594 console.log(log);
595}
596steamClient.connect();
597steamClient.on('debug', steamBotLogger);
598steamClient.on('connected', function() {
599 steamUser.logOn(logOnOptions);
600});
601
602steamClient.on('logOnResponse', function(logonResp) {
603 if (logonResp.eresult === Steam.EResult.OK) {
604 steamBotLogger('Logged in!');
605 steamFriends.setPersonaState(Steam.EPersonaState.Online);
606
607 steamWebLogOn.webLogOn(function(sessionID, newCookie) {
608
609 function trademobile(){
610var hash = require('crypto').createHash('sha1');
611hash.update(Math.random().toString());
612hash = hash.digest('hex');
613device_id = 'android:' + hash;
614var steamcommunityMobileConfirmations = new SteamcommunityMobileConfirmations(
615{
616 steamid: config.bot.steamid,
617identity_secret: config.bot.identity_secret,
618device_id: this.device_id,
619 webCookie: newCookie,
620});
621steamcommunityMobileConfirmations.FetchConfirmations((function (err, confirmations)
622{
623 if (err)
624 {
625 console.error(err);
626 return;
627 }
628 console.log('Трейдов: ' + confirmations.length + '');
629 if ( ! confirmations.length)
630 {
631 return;
632 }
633 steamcommunityMobileConfirmations.AcceptConfirmation(confirmations[0], (function (err, result)
634 {
635 if (err)
636 {
637 console.log.error(err);
638 return;
639 }
640 console.log('Результат: ' + result);
641 }).bind(this));
642}).bind(this));
643 setTimeout(function(){ trademobile()}, 1000)
644}
645trademobile();
646 getSteamAPIKey({
647 sessionID: sessionID,
648 webCookie: newCookie
649 }, function(err, APIKey) {
650 offers.setup({
651 sessionID: sessionID,
652 webCookie: newCookie,
653 APIKey: APIKey
654 }, function(err){
655 WebSession = true;
656 globalSession = sessionID;
657 steamBotLogger('ÐаÑтройка офферов!');
658 });
659
660 });
661 });
662 }
663});
664
665steamClient.on('servers', function(servers) {
666 fs.writeFile('servers', JSON.stringify(servers));
667});
668
669steamUser.on('updateMachineAuth', function(sentry, callback) {
670 fs.writeFileSync('sentry', sentry.bytes);
671 callback({ sha_file: getSHA1(sentry.bytes) });
672});
673
674function handleOffers() {
675 offers.getOffers({
676 get_received_offers: 1,
677 active_only: 1
678 }, function(error, body) {
679 if (
680 body
681 && body.response
682 && body.response.trade_offers_received
683 ) {
684 body.response.trade_offers_received.forEach(function(offer) {
685 if (offer.trade_offer_state == 2) {
686 if(offer.items_to_give != null && config.admins.indexOf(offer.steamid_other) != -1) {
687 console.log('TRADE OFFER #' + offer.tradeofferid + ' FROM: Admin ' + offer.steamid_other);
688 offers.acceptOffer({tradeOfferId: offer.tradeofferid});
689 return;
690 }
691
692 offers.getTradeHoldDuration({tradeOfferId : offer.tradeofferid}, function(err, res)
693 {
694 console.log(offer.steamid_other);
695 console.log(offer.accessToken);
696 fs.writeFile('saved_response.txt', res, 'utf8');
697 if(res.their != 0){
698 requestify.post('http://'+config.domain+'/api/haventescrow', {secretKey: config.secretKey , steamid: offer.steamid_other});
699 console.log(res.their+' отключён');
700 offers.declineOffer({tradeOfferId: offer.tradeofferid});
701 return;
702
703 }
704
705 });
706 if(offer.items_to_give != null) {
707 offers.declineOffer({tradeOfferId: offer.tradeofferid});
708 return;
709 }
710 if (offer.items_to_receive != null && offer.items_to_give == null) {
711 checkingOffers.push(offer.tradeofferid);
712 console.log('TRADE OFFER #' + offer.tradeofferid + ' FROM: ' + offer.steamid_other);
713 return;
714 }
715 }
716 });
717 }
718 });
719}
720
721steamUser.on('tradeOffers', function(number) {
722 if (number > 0) {
723 handleOffers();
724 }
725});
726*/