Advertisement
Guest User

Untitled

a guest
Oct 4th, 2018
1,472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 64.04 KB | None | 0 0
  1. const SteamUser = require('steam-user');
  2. const Helper = require('./helpers.js');
  3.  
  4. const SteamCommunity = require('steamcommunity');
  5. const Inventory = require('./components/inventory.js')
  6. const CustomerHandler = require('./components/userhandler.js');
  7. const TradeOfferManager = require('steam-tradeoffer-manager');
  8.  
  9. const config=Helper.getConfig();
  10. const rates=require('./data/rates.json');
  11. const msg=require('./data/messages.json');
  12.  
  13. require('events').EventEmitter.defaultMaxListeners = 20;
  14.  
  15. let client = new SteamUser( { 'promptSteamGuardCode':false } );
  16. let profit, CheckL_i, d_timeout, web_timeout, didLogin;
  17.  
  18. let LastLogin = {"client":0, "web":0};
  19. let LastLoginTry = {"client":0, "web":0};
  20.  
  21. let community = new SteamCommunity();
  22. let manager = new TradeOfferManager({ "steam": client, "language": "en", "community":community, "pollInterval": "10000", "cancelTime": "7200000" });
  23.  
  24. let helper = new Helper();
  25. let inventory = new Inventory(community, client, config.enableTF, config.enablePUBG, config.enableHydra, config.maxStock, helper);
  26. let customer = new CustomerHandler(client, config.admin, config.maxDays, helper);
  27.  
  28. const B = helper.breakline;
  29.  
  30. let keyPrice = parseInt(rates.SetsPrice.split(':')[1]);
  31. let keySets = parseInt(rates.SetsPrice.split(':')[0]);
  32.  
  33. let keyBuyPrice = parseInt(rates.BuyPrice.split(':')[1]);
  34. let keyBuySets = parseInt(rates.BuyPrice.split(':')[0]);
  35.  
  36. let tfkeyPrice = parseInt(rates.TF2Price.split(':')[1]);
  37. let tfkeySets = parseInt(rates.TF2Price.split(':')[0]);
  38.  
  39. let tfkeyBuyPrice = parseInt(rates.TF2BuyPrice.split(':')[1]);
  40. let tfkeyBuySets = parseInt(rates.TF2BuyPrice.split(':')[0]);
  41.  
  42. let HydrakeyBuyPrice = parseInt(rates.HydraBuyPrice.split(':')[1]);
  43. let HydrakeyBuySets = parseInt(rates.HydraBuyPrice.split(':')[0]);
  44.  
  45. let PUBGkeyPrice = parseInt(rates.PUBGPrice.split(':')[1]);
  46. let PUBGkeySets = parseInt(rates.PUBGPrice.split(':')[0]);
  47.  
  48. let PUBGkeyBuyPrice = parseInt(rates.PUBGBuyPrice.split(':')[1]);
  49. let PUBGkeyBuySets = parseInt(rates.PUBGBuyPrice.split(':')[0]);
  50.  
  51. let GemPrice = parseInt(rates.GemsPrice.split(':')[1]);
  52. let GemSet = parseInt(rates.GemsPrice.split(':')[0]);
  53.  
  54. let GemBuyPrice = parseInt(rates.GemsBuyPrice.split(':')[1]);
  55. let GemBuySet = parseInt(rates.GemsBuyPrice.split(':')[0]);
  56.  
  57. helper.getJSON('poll.json', (data) => { if(Object.keys(data).length){ manager.pollData=data; } } );
  58.  
  59. helper.getJSON('profit.json', (data) => { profit=data; } );
  60.  
  61. tryLogin();
  62.  
  63. function tryLogin(){
  64. let type = client.client.loggedOn;
  65. let lastl = !type ? LastLogin.client : LastLogin.web;
  66. let lastlt = !type ? LastLoginTry.client : LastLoginTry.web;
  67. let timeLimit = !type ? 1000*60*10 : 1000*5;
  68. let tryLimit = !type ? 1000*2 : 1000*2;
  69. let Now = helper.Now();
  70.  
  71. let canTry = () => (Math.floor(Now - (lastlt+tryLimit)) > 0);
  72. let canLogin = () => (Math.floor(Now - (lastl+timeLimit)) > 0);
  73.  
  74. let nextTry = () => {
  75. let val = Math.floor(Now - (lastlt+tryLimit));
  76. return val > 0 ? 1000 : (val)*-1;
  77. };
  78.  
  79. let nextLogin = () => {
  80. let val = Math.floor(Now - (lastl+timeLimit));
  81. return val > 0 ? 1000 : (val)*-1;
  82. };
  83.  
  84. if(type){
  85. if( canTry() ){
  86. LastLoginTry.web = Now;
  87. if( canLogin() ){
  88. if(client.client.loggedOn){
  89. client.setPersona(SteamUser.EPersonaState.Offline);
  90. client.webLogOn();
  91. } else {
  92. setTimeout(tryLogin, 1000);
  93. }
  94. } else {
  95. helper.warn("Next weblogin in "+(nextLogin()/1000)+" seconds.");
  96. clearTimeout(web_timeout);
  97. web_timeout = setTimeout(tryLogin, nextLogin());
  98. }
  99. } else {
  100. helper.debug("Trying to weblogin again in "+(nextTry()/1000)+" seconds.");
  101. clearTimeout(web_timeout);
  102. web_timeout = setTimeout(tryLogin, nextTry());
  103. }
  104. } else {
  105. if( canTry() ){
  106. LastLoginTry.client = Now;
  107. if( canLogin() ){
  108. login();
  109. } else {
  110. helper.warn("Next login in "+(nextLogin()/1000/60)+" minutes.");
  111. clearTimeout(d_timeout);
  112. d_timeout = setTimeout(tryLogin, nextLogin());
  113. }
  114. } else {
  115. helper.debug("Trying to login again in "+(nextTry()/1000)+" seconds.");
  116. clearTimeout(d_timeout);
  117. d_timeout = setTimeout(tryLogin, nextTry());
  118. }
  119. }
  120. }
  121.  
  122. function login(){
  123. if(!client.client.loggedOn){
  124. helper.log('Connecting to Steam..');
  125. if(didLogin){
  126. client.logOn(true);
  127. } else {
  128. client.logOn( helper.getLogOn( config.username, config.password ) );
  129. }
  130. }
  131. }
  132.  
  133. client.on('accountLimitations', function(limited, communityBanned, locked, canInviteFriends) {
  134. if(limited){
  135. helper.logError("This account is limited!", "Account error");
  136. client.logOff();
  137. }
  138. else if(communityBanned){
  139. helper.logError("This account is banned from community!", "Account error");
  140. client.logOff();
  141. }
  142. else if(locked){
  143. helper.logError("This account is locked!", "Account error");
  144. client.logOff();
  145. }
  146. });
  147.  
  148. client.on('loggedOn', function(details) {
  149. didLogin = true;
  150. if(config.changeBotName) {
  151. client.setPersona(SteamUser.EPersonaState.Online, config.changeBotName.replace("{csgo_rate}", keySets+":"+keyPrice));
  152. } else {
  153. client.setPersona(SteamUser.EPersonaState.Online);
  154. }
  155. LastLogin.client = helper.Now();
  156. inventory.ID64 = client.steamID.getSteamID64();
  157. setTimeout(process.exit, 1000 * 60 * 60 * config.restart, 0);
  158. helper.log("Conecting to SteamCommunity..");
  159. });
  160.  
  161. client.on('groupRelationship', (sid, relationship) => { if(relationship == SteamUser.EClanRelationship.Invited){ client.respondToGroupInvite(sid, false); } });
  162.  
  163. client.on('steamGuard', function(domain, callback) { helper.getCode(config.sharedse, (code) => { callback(code); }); });
  164.  
  165. client.on('webSession', function(sessionID, newCookie) {
  166. LastLogin.web = helper.Now();
  167. helper.debug("webLogOn");
  168. if(inventory.card_db){
  169. loadmanager(newCookie);
  170. } else {
  171. helper.log("Loading sets Database..");
  172. helper.updateTradingCardDb( (data) => { if(data){ inventory.card_db = data; loadmanager(newCookie);} } );
  173. }
  174. });
  175.  
  176. var itemsInOffer = [];
  177.  
  178. function send(friend, bits){
  179. let tradeURL = bits[1];
  180. let sets = bits[2];
  181.  
  182. if(tradeURL == null || sets == null)
  183. return client.chatMessage(friend, "Invalid arguments.");
  184.  
  185. if(sets.match(/^[0-9]+$/) == null)
  186. return client.chatMessage(friend, "Set amount must be a number.");
  187.  
  188. let offer = manager.createOffer(tradeURL);
  189.  
  190. inventory.getCustomerSets(1, client.steamID, (error, setItems) => {
  191. if(error) {
  192. client.chatMessage(friend, "An error occurred while loading inventory.");
  193. return console.error(error);
  194. }
  195.  
  196. setItems = setItems.splice(0, parseInt(sets));
  197.  
  198. let traded = [];
  199.  
  200. setItems.forEach(set => {
  201. set.forEach(item => {
  202. traded.push(item);
  203. });
  204. });
  205.  
  206. itemsInOffer = itemsInOffer.concat(traded);
  207.  
  208. offer.addMyItems(traded);
  209.  
  210. offer.setMessage(sets + " sets.");
  211.  
  212. offer.send((error, status) => {
  213. if(error) {
  214. client.chatMessage(friend, "An error occurred.");
  215. return console.error(error);
  216. }
  217.  
  218. if(status == "pending") {
  219. community.acceptConfirmationForObject(config.identity, offer.id, (error) => {
  220. if(error) {
  221. client.chatMessage(friend, "An error occurred.");
  222. return console.error(error);
  223. }
  224.  
  225. client.chatMessage(friend, "Offer sent for " + sets + " sets.");
  226. });
  227. return;
  228. }
  229.  
  230. client.chatMessage(friend, "Offer sent for " + sets + " sets.");
  231. });
  232. });
  233. }
  234.  
  235. function loadmanager(newCookie){
  236. if(!LastLoginTry.web){ helper.log('Loading APIKey..'); }
  237. manager.setCookies(newCookie, function(err){
  238. if(err){
  239. helper.logError(err.message, "Fatal error");
  240. } else {
  241. if(!LastLoginTry.web){ helper.log('Got APIKey: '+manager.apiKey); }
  242. inventory.apiKey = manager.apiKey;
  243. community.startConfirmationChecker(20000, config.identity);
  244. inventory.Load(0, () => { online(); });
  245. clearInterval(CheckL_i);
  246. CheckL_i = setInterval(checkSteamLogged, 1000*60*4);
  247. }
  248. });
  249. }
  250.  
  251. client.on('disconnected', () => { helper.log("Bot Disconnected!"); });
  252.  
  253. community.on('sessionExpired', () => { helper.warn("Session expired!"); tryLogin(); });
  254.  
  255. //process.on("uncaughtException", (err) => { console.log(err); process.exit(1); });
  256.  
  257. community.on('confirmationAccepted', function(conf) {
  258. helper.debug("confirmationAccepted type "+conf.type+" triggered #"+conf.id);
  259. if(conf.type == 2){
  260. helper.debug("Searching for details of #"+conf.creator);
  261. manager.getOffer(conf.creator, function(err, myOffer){
  262. if(err){
  263. helper.logError(err.message, 'confirmationAccepted');
  264. } else {
  265. if(myOffer.isOurOffer){
  266. let response = msg.OfferSent;
  267. response += B+msg.OfferSent2.replace("{url}", "https://steamcommunity.com/tradeoffer/"+conf.creator);
  268. customer.Message(myOffer.partner, response);
  269. helper.logTrade("Successfully sent a trade offer for "+myOffer.partner);
  270. } else {
  271. helper.debug("#"+conf.creator+" with confirmation id #"+conf.id+" isnt a trade offer sended by bot.");
  272. }
  273. }
  274. });
  275. }
  276. });
  277.  
  278. function checkFriendRequests(){ for(let user in client.myFriends){ if(client.myFriends[user] == 2){ addFriend(user); } } }
  279.  
  280. function addFriend(user){
  281. client.addFriend(user, function(err, result){
  282. if(err){
  283. helper.warn("Failed to accept user #"+user+" friend request!: "+err.message);
  284. } else {
  285. //inviteToGroup(user);
  286. customer.Message(user, msg.Welcome.replace("{customer_name}", result));
  287. customer.UserInteract(user, 0);
  288. }
  289. });
  290. }
  291.  
  292. function checkSteamLogged() {
  293. community.loggedIn( function (err, loggedIn) {
  294. if (err) {
  295. helper.logError(err.message, 'checkSteamLogged');
  296. if(err.message.indexOf("socket hang up") > -1 || err.message.indexOf("ESOCKETTIMEDOUT") > -1){
  297. restart_();
  298. } else {
  299. setTimeout(checkSteamLogged, 1000*10);
  300. }
  301. } else if ( ! loggedIn ) {
  302. helper.debug("WebLogin check : NOT LOGGED IN !");
  303. tryLogin();
  304. } else {
  305. helper.debug("WebLogin check : LOGGED IN !");
  306. client.setPersona(SteamUser.EPersonaState.LookingToTrade);
  307. }
  308. });
  309. }
  310.  
  311. manager.on('pollData', (pollData) => { helper.storeData('poll.json', pollData, 1); });
  312.  
  313. manager.on('pollFailure', (err) => { helper.debug("pollFailure: "+err); checkSteamLogged(); });
  314.  
  315. client.on('error', (e) => { helper.logError(e.message.replace("RateLimitExceeded", "Temporary rate limit exceeded"), "Fatal error"); if(!didLogin){ LastLogin.client = helper.Now(); } tryLogin(); });
  316.  
  317. function inviteToGroup(target){
  318. if(config.group){
  319. community.inviteUserToGroup(target, config.group, (err) => {
  320. if(err){
  321. helper.debug("Failed to invite user #"+target+" to group: "+err.message);
  322. }
  323.  
  324. });
  325. }
  326. }
  327.  
  328. function makeOffer(target, itemsFromMe, itemsFromThem, details, type, currency, message){
  329. helper.debug("Creating trade offer for #"+target+" with "+itemsFromMe.length+" items to send and "+itemsFromThem.length+" items to receive");
  330. try {
  331. let offer = manager.createOffer(target);
  332. let addMyItemsCount = offer.addMyItems(itemsFromMe);
  333. let addTheirItemsCount = offer.addTheirItems(itemsFromThem);
  334. //let OfferSize=itemsFromThem.length+itemsFromMe.length;
  335. offer.data('SellInfo', details);
  336. offer.data('SellInfoType', type);
  337. offer.data('SellInfoCurrency', currency);
  338. if(!message)
  339. offer.setMessage(''+offer.data('SellInfo').split(":")[0]+' sets for '+offer.data('SellInfo').split(":")[1]+' '+offer.data('SellInfoCurrency')+'');
  340. else
  341. offer.setMessage(message);
  342. offer.getUserDetails( (err, me, them) => {
  343. if(err){
  344. if(err.message.toLowerCase().indexOf("is not available to trade. more information will be") > -1){
  345. customer.Message(target, msg.Trade_error1);
  346. helper.logTrade("#"+target+" is unavailable to trade");
  347. } else { helper.logError(err.message, 'offer.getUserDetails'); }
  348. } else {
  349. helper.debug("Sending offer for #"+target);
  350. offer.send( (err, status) => {
  351. helper.debug("Offer #"+offer.id+" status: "+status+", "+err);
  352. if (err){
  353.  
  354. if(err.message.toLowerCase().indexOf("sent too many trade offers") > 1){
  355. customer.Message(target, msg.Trade_error2);
  356. } else if(err.message.toLowerCase().indexOf("please try again later. (26)") > 1){
  357. helper.warn("Error 26, restarting.", 'offer.send');
  358. customer.Message(target, msg.Trade_error);
  359. process.exit();
  360. } else {
  361. helper.logError(err.message, 'offer.send');
  362. customer.Message(target, msg.Trade_error);
  363. }
  364. } else {
  365. manager.getOffer(offer.id, (err, myOffer) => {
  366. if(err){
  367. helper.logError(err.message, 'manager.getOffer');
  368. customer.Message(target, msg.Trade_error);
  369. if(err.message.indexOf("socket hang up") > -1 || err.message.indexOf("ESOCKETTIMEDOUT") > -1){
  370. tryLogin();
  371. }
  372. } else {
  373. if(addMyItemsCount != myOffer.itemsToGive.length){
  374. helper.logError('Cant add itemsFromMe, some item is missing in my inventory!', 'manager.getOffer');
  375. customer.Message(target, msg.Trade_error);
  376. myOffer.cancel();
  377. } else if(addTheirItemsCount != myOffer.itemsToReceive.length){
  378. helper.logError('Cant add itemsFromThem, some item is missing in my inventory!', 'manager.getOffer');
  379. customer.Message(target, msg.Trade_error);
  380. myOffer.cancel();
  381. } else if (status == 'pending') {
  382. community.checkConfirmations();
  383. } else {
  384. let response = msg.OfferSent;
  385. response += B+msg.OfferSent2.replace("{url}", "https://steamcommunity.com/tradeoffer/"+offer.id);
  386. customer.Message(target, response);
  387. helper.logTrade("Successfully sent a trade offer for "+target);
  388. }
  389. }
  390. });
  391. }
  392. });
  393. }
  394. });
  395. } catch(e) {
  396. customer.Message(target, msg.Trade_error);
  397. }
  398.  
  399. }
  400.  
  401. function playPrices(){
  402. let play = msg.play.replace("{have_sets}", helper.nFormat(inventory.haveSets())).replace("{csgo_rate}", keySets+":"+keyPrice).replace("{gems_rate}", GemSet+":"+GemPrice);
  403. if(inventory.enableTF){ play += msg.play2.replace("{tf_rate}", tfkeySets+":"+tfkeyPrice);}
  404. if(inventory.enablePUBG){ play += msg.play3.replace("{PUBG_rate}", PUBGkeySets+":"+PUBGkeyPrice);}
  405. client.gamesPlayed(play, true);
  406. }
  407.  
  408. function online(){ client.setPersona(SteamUser.EPersonaState.LookingToTrade); playPrices(); checkFriendRequests(); }
  409.  
  410. manager.on('newOffer', function(offer) {
  411. let partner = offer.partner.getSteamID64();
  412. if(config.admin.indexOf(partner) > -1){
  413. helper.logTrade("New offer from admin #"+partner);
  414. offer.accept(function(err, res) {
  415. if(err) {
  416. helper.warn("Unable to accept admin offer: " + err.message);
  417. }
  418. else {
  419. if(res == "pending"){
  420. helper.logTrade("Accepting admin offer..");
  421. community.checkConfirmations();
  422. } else {
  423. helper.logTrade("Admin Offer accepeted!");
  424. }
  425. }
  426. });
  427. }
  428. });
  429.  
  430. manager.on('receivedOfferChanged', function(offer, oldState) {
  431. helper.debug("receivedOfferChanged Triggered at #"+offer.id+", state: "+offer.state+", oldState: "+oldState)
  432. if(offer.state == 3 && customer.finishedTrades[offer.id] == null){
  433. customer.finishedTrades[offer.id] = new Date().getTime();
  434. helper.log('Reloading sets..');
  435. inventory.Load(1, () => {playPrices();client.setPersona(SteamUser.EPersonaState.LookingToTrade);});
  436. }
  437. });
  438.  
  439. manager.on('sentOfferChanged', function(offer, oldState) {
  440. helper.debug("sentOfferChanged Triggered at #"+offer.id+", state: "+offer.state+", oldState: "+oldState)
  441. if(offer.state == 3 && customer.finishedTrades[offer.id] == null){
  442. customer.finishedTrades[offer.id] = new Date().getTime();
  443. customer.trade(offer.partner);
  444.  
  445. helper.log('Reloading sets..');
  446. inventory.Load(1, () => {playPrices();client.setPersona(SteamUser.EPersonaState.LookingToTrade);});
  447.  
  448. if(config.ThanksM && offer.data('SellInfo') != 'admin'){
  449. customer.canComment(offer.partner.getSteamID64(), function(canComment){
  450. if(canComment){ community.postUserComment(offer.partner.getSteamID64(), config.ThanksM, function(err){
  451. if(!err){ customer.UserInteract(offer.partner.getSteamID64(), 1); }
  452. });
  453. }
  454. });
  455. let response = msg.Thanks;
  456.  
  457. customer.Message(offer.partner, response);
  458. }
  459. inviteToGroup(offer.partner.getSteamID64());
  460. if(offer.data('SellInfoType') != null){
  461. if(offer.data('SellInfoType') == 0){
  462. if(offer.data('SellInfoCurrency') == "tf keys"){ profit.sell.tf.sets = parseInt(profit.sell.tf.sets)+parseInt(offer.data('SellInfo').split(":")[0]); profit.sell.tf.currency = parseInt(profit.sell.tf.currency)+parseInt(offer.data('SellInfo').split(":")[1]);}
  463. if(offer.data('SellInfoCurrency') == "PUBG key(s)"){ profit.sell.PUBG.sets = parseInt(profit.sell.PUBG.sets)+parseInt(offer.data('SellInfo').split(":")[0]); profit.sell.PUBG.currency = parseInt(profit.sell.PUBG.currency)+parseInt(offer.data('SellInfo').split(":")[1]);}
  464. if(offer.data('SellInfoCurrency') == "keys"){ profit.sell.csgo.sets = parseInt(profit.sell.csgo.sets)+parseInt(offer.data('SellInfo').split(":")[0]); profit.sell.csgo.currency = parseInt(profit.sell.csgo.currency)+parseInt(offer.data('SellInfo').split(":")[1]);}
  465. if(offer.data('SellInfoCurrency') == "gems"){ profit.sell.gems.sets = parseInt(profit.sell.gems.sets)+parseInt(offer.data('SellInfo').split(":")[0]); profit.sell.gems.currency = parseInt(profit.sell.gems.currency)+parseInt(offer.data('SellInfo').split(":")[1]);}
  466. helper.storeData('profit.json', profit, 1);
  467. helper.logTrade(offer.partner.getSteamID64()+' have accepted an trade offer!, i have selled '+offer.data('SellInfo').split(":")[0]+' set(s) for '+offer.data('SellInfo').split(":")[1]+' '+offer.data('SellInfoCurrency')+'!');
  468. if(config.sellmsgs){
  469. customer.sendAdminMessages("Hey!, i just have selled "+offer.data('SellInfo').split(":")[0]+" Set(s) for "+offer.data('SellInfo').split(":")[1]+" "+offer.data('SellInfoCurrency')+"!");
  470. }
  471. } else if(offer.data('SellInfoType') == 1){
  472. if(offer.data('SellInfoCurrency') == "PUBG key(s)"){ profit.buy.PUBG.sets = parseInt(profit.buy.PUBG.sets)+parseInt(offer.data('SellInfo').split(":")[0]); profit.buy.PUBG.currency = parseInt(profit.buy.PUBG.currency)+parseInt(offer.data('SellInfo').split(":")[1]);}
  473. if(offer.data('SellInfoCurrency') == "tf keys"){ profit.buy.tf.sets = parseInt(profit.buy.tf.sets)+parseInt(offer.data('SellInfo').split(":")[0]); profit.buy.tf.currency = parseInt(profit.buy.tf.currency)+parseInt(offer.data('SellInfo').split(":")[1]);}
  474. if(offer.data('SellInfoCurrency') == "keys"){ profit.buy.csgo.sets = parseInt(profit.buy.csgo.sets)+parseInt(offer.data('SellInfo').split(":")[0]); profit.buy.csgo.currency = parseInt(profit.buy.csgo.currency)+parseInt(offer.data('SellInfo').split(":")[1]);}
  475. if(offer.data('SellInfoCurrency') == "gems"){ profit.buy.gems.sets = parseInt(profit.buy.gems.sets)+parseInt(offer.data('SellInfo').split(":")[0]); profit.buy.gems.currency = parseInt(profit.buy.gems.currency)+parseInt(offer.data('SellInfo').split(":")[1]);}
  476. helper.logTrade(offer.partner.getSteamID64()+' have accepted an trade offer!, i have buyed '+offer.data('SellInfo').split(":")[0]+' sets for '+offer.data('SellInfo').split(":")[1]+' '+offer.data('SellInfoCurrency')+'!');
  477. if(config.sellmsgs){
  478. customer.sendAdminMessages("Hey!, i just have buyed "+offer.data('SellInfo').split(":")[0]+" Set(s) for "+offer.data('SellInfo').split(":")[1]+" "+offer.data('SellInfoCurrency')+"!");
  479. }
  480. }
  481. }
  482. }
  483. });
  484.  
  485. function gemswithdraw (admin, qty){
  486. let InventoryGems = inventory.return_GemsQty();
  487. customer.Message(admin, msg.OwnerRequest);
  488. if(InventoryGems){
  489. if(InventoryGems >= qty) {
  490. inventory.getGems(qty, function(toGive){
  491. makeOffer(admin, toGive, [], 'admin');
  492. });
  493. } else {
  494. customer.Message(admin, msg.Sorryme.replace("{currency_qty}", helper.nFormat(InventoryGems)).replace("{currency_name}", "gems").replace("{command}", "!gemswithdraw").replace("{command_qty}", InventoryGems));
  495. }
  496. } else {
  497. customer.Message(admin, msg.Sorryme2.replace("{currency_name}", "gems"))
  498. }
  499. }
  500.  
  501. function tfwithdraw (admin, qty){
  502. customer.Message(admin, msg.OwnerRequest);
  503. let Tf_keys = inventory.haveTfKeys();
  504. if(Tf_keys){
  505. if(Tf_keys >= qty){
  506. inventory.getToOffer_TF_Keys(qty, function(send){
  507. makeOffer(admin, send, [], 'admin');
  508. });
  509. } else {
  510. customer.Message(admin, msg.Sorryme.replace("{currency_qty}", Tf_keys).replace("{currency_name}", "tf keys").replace("{command}", "!tfwithdraw").replace("{command_qty}", Tf_keys));
  511. }
  512. } else {
  513. customer.Message(admin, msg.Sorryme2.replace("{currency_name}", "tf keys"));
  514. }
  515. }
  516.  
  517. function pubgwithdraw (admin, qty){
  518. customer.Message(admin, msg.OwnerRequest);
  519. let PUBG_keys = inventory.havePUBGKeys();
  520. if(PUBG_keys){
  521. if(PUBG_keys >= qty){
  522. inventory.getToOffer_PUBG_Keys(qty, function(send){
  523. makeOffer(admin, send, [], 'admin');
  524. });
  525. } else {
  526. customer.Message(admin, msg.Sorryme.replace("{currency_qty}", PUBG_keys).replace("{currency_name}", "PUBG keys").replace("{command}", "!pubgwithdraw").replace("{command_qty}", PUBG_keys));
  527. }
  528. } else {
  529. customer.Message(admin, msg.Sorryme2.replace("{currency_name}", "PUBG keys"));
  530. }
  531. }
  532.  
  533. function withdraw (admin, qty){
  534. customer.Message(admin, msg.OwnerRequest);
  535. let user_keys = inventory.haveCsKeys();
  536. if(user_keys){
  537. if(user_keys >= qty){
  538. inventory.getToOffer_CS_Keys(qty, function(send){
  539. makeOffer(admin, send, [], 'admin');
  540. });
  541. } else {
  542. customer.Message(admin, msg.Sorryme.replace("{currency_qty}", user_keys).replace("{currency_name}", "TF2 keys").replace("{command}", "!withdraw").replace("{command_qty}", user_keys));
  543. }
  544. } else {
  545. customer.Message(admin, msg.Sorryme2.replace("{currency_name}", "cs:go keys"));
  546. }
  547.  
  548. }
  549.  
  550. function tfdeposit(admin, qty){
  551. customer.Message(admin, msg.OwnerRequest);
  552. inventory.return_CustomerTFKeys(admin, function(err, keys){
  553. if(err){
  554. handleInventoryErrors(err, admin);
  555. } else {
  556. let user_keys = keys.length;
  557. if(user_keys){
  558. if(user_keys >= qty){
  559. inventory.getToOfferKeys(keys, qty, 440, function(toReceive){
  560. makeOffer(admin, [], toReceive, 'admin');
  561. });
  562. } else {
  563. customer.Message(admin, msg.Sorrythem.replace("{currency_qty}", user_keys).replace("{currency_name}", "tf keys").replace("{command}", "!tfdeposit").replace("{command_qty}", user_keys));
  564. }
  565. } else {
  566. customer.Message(admin, msg.Sorrythem2.replace("{currency_name}", "tf keys"));
  567. }
  568. }
  569. });
  570. }
  571.  
  572. function pubgdeposit(admin, qty){
  573. customer.Message(admin, msg.OwnerRequest);
  574. inventory.return_CustomerPUBGKeys(admin, function(err, keys){
  575. if(err){
  576. handleInventoryErrors(err, admin);
  577. } else {
  578. let user_keys = keys.length;
  579. if(user_keys){
  580. if(user_keys >= qty){
  581. inventory.getToOfferKeys(keys, qty, 578080, function(toReceive){
  582. makeOffer(admin, [], toReceive, 'admin');
  583. });
  584. } else {
  585. customer.Message(admin, msg.Sorrythem.replace("{currency_qty}", user_keys).replace("{currency_name}", "PUBG keys").replace("{command}", "!pubgdeposit").replace("{command_qty}", user_keys));
  586. }
  587. } else {
  588. customer.Message(admin, msg.Sorrythem2.replace("{currency_name}", "PUBG keys"));
  589. }
  590. }
  591. });
  592. }
  593.  
  594. function deposit(admin, qty){
  595. customer.Message(admin, msg.OwnerRequest);
  596. inventory.return_CustomerCSGOKeys(admin, function(err, keys){
  597. if(err){
  598. handleInventoryErrors(err, admin);
  599. } else {
  600. let user_keys = keys.length;
  601. if(user_keys){
  602. if(user_keys >= qty){
  603. inventory.getToOfferKeys(keys, qty, 730, function(toReceive){
  604. makeOffer(admin, [], toReceive, 'admin');
  605. });
  606. } else {
  607. customer.Message(admin, msg.Sorrythem.replace("{currency_qty}", user_keys).replace("{currency_name}", "cs:go keys").replace("{command}", "!deposit").replace("{command_qty}", user_keys));
  608. }
  609. } else {
  610. customer.Message(admin, msg.Sorrythem2.replace("{currency_name}", "cs:go keys"));
  611. }
  612. }
  613. });
  614. }
  615.  
  616. function depositgems(admin, qty){
  617. customer.Message(admin, msg.OwnerRequest);
  618. inventory.getCustomerGemAssets(admin, function(err, Gems_Assets, Gems_Qty){
  619. if(err){
  620. handleInventoryErrors(err, admin);
  621. } else {
  622. if(Gems_Qty){
  623. if(Gems_Qty >= qty){
  624. inventory.getCustomerGems(Gems_Assets, qty, function(toReceive){
  625. makeOffer(admin, [], toReceive, 'admin');
  626. });
  627. } else {
  628. customer.Message(admin, msg.Sorrythem.replace("{currency_qty}", Gems_Qty).replace("{currency_name}", "gems").replace("{command}", "!depositgems").replace("{command_qty}", Gems_Qty));
  629. }
  630. } else {
  631. customer.Message(admin, msg.Sorrythem2.replace("{currency_name}", "gems"));
  632. }
  633. }
  634. });
  635. }
  636.  
  637. function check(source){
  638. if(inventory.haveSets()) {
  639. //customer.Message(source, msg.CustomerRequest);
  640. inventory.getUserBadges(source, 1, 5, function(err, badge){
  641. if(err){
  642. handleBadgeErrors(err, source);
  643. } else {
  644. let space = " ";
  645. let Qty=0;
  646.  
  647. for(let appid in inventory.AvailableSets){
  648. Qty += Math.min.apply( Math, [ inventory.AvailableSets[appid].length, (badge[appid] != null ? badge[appid] : 5 ) ] );
  649. }
  650.  
  651. if(Qty){
  652. let response = msg.Check.replace("{have_sets}", helper.nFormat(Qty)).replace("{csgo_price}", ((Qty/keySets)*keyPrice).toFixed(1)).replace("{gems_price}", helper.nFormat(Math.round(Qty/GemSet)*GemPrice));
  653. if(inventory.enableTF){ response += msg.Check2.replace("{tf_price}", ((Qty/tfkeySets)*tfkeyPrice).toFixed(1));}
  654.  
  655. response += space+msg.Check_i.replace("{buy_qty}", parseInt(Qty/keySets)*keyPrice).replace("{buygems_qty}", Qty);
  656. if(inventory.enableTF){ response += msg.Check_i2.replace("{buytf_qty}", parseInt(Qty/tfkeySets)*tfkeyPrice);}
  657. if(inventory.haveCsKeys() && config.enableSell){ response += space+msg.Sell_keys; }
  658. customer.Message(source, response);
  659. } else {
  660. let response = msg.Donthave;
  661. if(inventory.haveCsKeys() && config.enableSell){ response += space+msg.Sell_keys; }
  662. customer.Message(source, response);
  663. }
  664. }
  665. });
  666.  
  667. } else {
  668. let response = msg.Donthave;
  669. if(inventory.haveCsKeys() && config.enableSell){ response += B+msg.Sell_keys; }
  670. customer.Message(source, response);
  671. }
  672. }
  673.  
  674. function buy(source, qty, compare, mode){
  675. customer.Message(source, msg.CustomerRequest);
  676. inventory.return_CustomerTFKeys(source, function(err, KeysFromThemAsset){
  677. if(err){
  678. handleInventoryErrors(err, source);
  679. } else {
  680. let user_keys = KeysFromThemAsset.length;
  681. if(user_keys){
  682. let need = tfkeyPrice*qty;
  683. let set_need = tfkeySets*qty;
  684. if(user_keys >= need){
  685. inventory.getAvailableSetsForCustomer(source, compare, mode, set_need, function(err, toSend){
  686. if(err){
  687. handleBadgeErrors(err, source);
  688. } else {
  689. if(toSend.length == set_need){
  690. inventory.getToOfferKeys(KeysFromThemAsset, need, 440, function(toReceive){
  691. makeOffer(source, [].concat.apply([], toSend), toReceive, set_need+":"+need, 0, "tf keys");
  692. });
  693. } else {
  694. customer.Message(source, msg.i_need.replace("{currency_qty}", toSend.length).replace("{currency}", "sets").replace("{needed}", set_need));
  695. }
  696. }
  697. });
  698. } else {
  699. customer.Message(source, msg.them_need.replace("{currency_qty}", user_keys).replace("{currency}", "tf keys").replace("{needed}", need));
  700. }
  701. } else {
  702. customer.Message(source, msg.Sorrythem2.replace("{currency_name}", "tf keys"));
  703. }
  704. }
  705. });
  706. }
  707.  
  708. function buylevel(source, qty){
  709. customer.Message(source, msg.CustomerRequest);
  710. inventory.getUserBadges(source, 0, 0, function(err, badge, player_level, player_xp){
  711. if(err){
  712. handleBadgeErrors(err, source);
  713. } else {
  714. if(qty < player_level){
  715. customer.Message(source, "You are already level "+qty+"");
  716. } else {
  717. let needed = Math.ceil(((helper.getLevelExp(parseInt(qty)))-player_xp)/100);
  718. inventory.return_CustomerCSGOKeys(source, function(err, KeysFromThemAsset){
  719. if(err){
  720. handleInventoryErrors(err, source);
  721. } else {
  722. let user_keys = KeysFromThemAsset.length;
  723. if(user_keys){
  724. let set_need = needed;
  725. let need = Math.ceil(keyPrice * (needed / keySets));
  726. if(need > config.maxTradeKeys)
  727. return customer.Message(source, "Please try a lower amount.");
  728.  
  729. if(user_keys >= need){
  730. inventory.getAvailableSetsForCustomer(source, 1, 5, set_need, function(err, toSend){
  731. if(err){
  732. handleBadgeErrors(err, source);
  733. } else {
  734. if(toSend.length == set_need){
  735. inventory.getToOfferKeys(KeysFromThemAsset, need, 730, function(toReceive){
  736. makeOffer(source, [].concat.apply([], toSend), toReceive, set_need+":"+need, 0, "keys", need + " keys for level " + qty);
  737. });
  738. } else {
  739. customer.Message(source, msg.i_need.replace("{currency_qty}", toSend.length).replace("{currency}", "sets").replace("{needed}", set_need));
  740. }
  741. }
  742. });
  743. } else {
  744. customer.Message(source, msg.them_need.replace("{currency_qty}", user_keys).replace("{currency}", "TF2 keys").replace("{needed}", need));
  745. }
  746. } else {
  747. customer.Message(source, msg.Sorrythem2.replace("{currency_name}", "cs:go keys"));
  748. }
  749. }
  750. });
  751. }
  752. }
  753. });
  754. }
  755.  
  756.  
  757. function buytf(source, qty, compare, mode){
  758. customer.Message(source, msg.CustomerRequest);
  759. inventory.return_CustomerTFKeys(source, function(err, KeysFromThemAsset){
  760. if(err){
  761. handleInventoryErrors(err, source);
  762. } else {
  763. let user_keys = KeysFromThemAsset.length;
  764. if(user_keys){
  765. let need = tfkeyPrice*qty;
  766. let set_need = tfkeySets*qty;
  767. if(user_keys >= need){
  768. inventory.getAvailableSetsForCustomer(source, compare, mode, set_need, function(err, toSend){
  769. if(err){
  770. handleBadgeErrors(err, source);
  771. } else {
  772. if(toSend.length == set_need){
  773. inventory.getToOfferKeys(KeysFromThemAsset, need, 440, function(toReceive){
  774. makeOffer(source, [].concat.apply([], toSend), toReceive, set_need+":"+need, 0, "tf keys");
  775. });
  776. } else {
  777. customer.Message(source, msg.i_need.replace("{currency_qty}", toSend.length).replace("{currency}", "sets").replace("{needed}", set_need));
  778. }
  779. }
  780. });
  781. } else {
  782. customer.Message(source, msg.them_need.replace("{currency_qty}", user_keys).replace("{currency}", "tf keys").replace("{needed}", need));
  783. }
  784. } else {
  785. customer.Message(source, msg.Sorrythem2.replace("{currency_name}", "tf keys"));
  786. }
  787. }
  788. });
  789. }
  790.  
  791. function buypubg(source, qty, compare, mode){
  792. customer.Message(source, msg.CustomerRequest);
  793. inventory.return_CustomerPUBGKeys(source, function(err, KeysFromThemAsset){
  794. if(err){
  795. handleInventoryErrors(err, source);
  796. } else {
  797. let user_keys = KeysFromThemAsset.length;
  798. if(user_keys){
  799. let need = PUBGkeyPrice*qty;
  800. let set_need = PUBGkeySets*qty;
  801. if(user_keys >= need){
  802. inventory.getAvailableSetsForCustomer(source, compare, mode, set_need, function(err, toSend){
  803. if(err){
  804. handleBadgeErrors(err, source);
  805. } else {
  806. if(toSend.length == set_need){
  807. inventory.getToOfferKeys(KeysFromThemAsset, need, 578080, function(toReceive){
  808. makeOffer(source, [].concat.apply([], toSend), toReceive, set_need+":"+need, 0, "PUBG keys");
  809. });
  810. } else {
  811. customer.Message(source, msg.i_need.replace("{currency_qty}", toSend.length).replace("{currency}", "sets").replace("{needed}", set_need));
  812. }
  813. }
  814. });
  815. } else {
  816. customer.Message(source, msg.them_need.replace("{currency_qty}", user_keys).replace("{currency}", "PUBG keys").replace("{needed}", need));
  817. }
  818. } else {
  819. customer.Message(source, msg.Sorrythem2.replace("{currency_name}", "PUBG keys"));
  820. }
  821. }
  822. });
  823. }
  824.  
  825. function buygems(source, qty, compare, mode){
  826. customer.Message(source, msg.CustomerRequest);
  827. inventory.getCustomerGemAssets(source, function(err, Gems_Assets, Gems_Qty){
  828. if(err){
  829. handleInventoryErrors(err, source);
  830. } else {
  831. let need = GemPrice*qty;
  832. let set_need = GemSet*qty;
  833. if(Gems_Qty){
  834. if(Gems_Qty >= need){
  835. inventory.getAvailableSetsForCustomer(source, compare, mode, set_need, function(err, toSend){
  836. if(err){
  837. handleBadgeErrors(err, source);
  838. } else {
  839. if(toSend.length == set_need){
  840. inventory.getCustomerGems(Gems_Assets, need, function(toReceive){
  841. makeOffer(source, [].concat.apply([], toSend), toReceive, set_need+":"+need, 0, "gems");
  842. });
  843. } else {
  844. customer.Message(source, msg.i_need.replace("{currency_qty}", toSend.length).replace("{currency}", "sets").replace("{needed}", set_need));
  845. }
  846. }
  847. });
  848. } else {
  849. customer.Message(source, msg.them_need.replace("{currency_qty}", Gems_Qty).replace("{currency}", "gems").replace("{needed}", need));
  850. }
  851. } else {
  852. customer.Message(source, msg.Sorrythem2.replace("{currency_name}", "gems"));
  853. }
  854. }
  855. });
  856. }
  857.  
  858. function checkam(source, amount, type, callback){
  859. //customer.Message(source, msg.CustomerRequest);
  860. inventory.getUserBadges(source, 0, 0, function(err, badge, player_level, player_xp){
  861. if(err){
  862. handleBadgeErrors(err, source);
  863. } else {
  864. let xpWon=(type ? keySets/keyPrice : tfkeySets/tfkeyPrice)*100*amount;
  865.  
  866. let totalExp=player_xp+xpWon;
  867.  
  868. let i=player_level-1;
  869.  
  870. let can=0;
  871. do {
  872. i++;
  873. if(i > config.maxLevelComm){
  874. let response = "I'm not allowed to calculate level above than "+config.maxLevelComm+" :/";
  875. response += B+"Sorry but can you try a lower level?";
  876. customer.Message(source, response);
  877. can++;
  878. break;
  879. }
  880. }
  881. while (helper.getLevelExp(i) <= totalExp);
  882. if(!can){callback(player_level, (i-1));}
  883. }
  884. });
  885. }
  886.  
  887. function checkpubg(source, amount, type, callback){
  888. //customer.Message(source, msg.CustomerRequest);
  889. inventory.getUserBadges(source, 0, 0, function(err, badge, player_level, player_xp){
  890. if(err){
  891. handleBadgeErrors(err, source);
  892. } else {
  893. let xpWon=(PUBGkeySets/PUBGkeyPrice)*100*amount;
  894.  
  895. let totalExp=player_xp+xpWon;
  896.  
  897. let i=player_level-1;
  898. let can=0;
  899. do {
  900. i++;
  901. if(i > config.maxLevelComm){
  902. let response = "Please try a lower number.";
  903. //response += B+"Sorry but can you try a lower level?";
  904. customer.Message(source, response);
  905. can++;
  906. break;
  907. }
  908. }
  909. while (helper.getLevelExp(i) <= totalExp);
  910. if(!can){callback(player_level, (i-1));}
  911. }
  912. });
  913. }
  914.  
  915. function checkgam(source, amount, callback){
  916. //customer.Message(source, msg.CustomerRequest);
  917. inventory.getUserBadges(source, 0, 0, function(err, badge, player_level, player_xp){
  918. if(err){
  919. handleBadgeErrors(err, source);
  920. } else {
  921. let xpWon=(GemSet/GemPrice)*100*amount;
  922.  
  923. let totalExp=player_xp+xpWon;
  924.  
  925. let i=parseInt(player_level)-1;
  926. let can=0;
  927. do {
  928. i++;
  929. if(i > config.maxLevelComm){
  930. let response = "Please try a lower number.";
  931. //response += B+"Sorry but can you try a lower level?";
  932. customer.Message(source, response);
  933. can++;
  934. break;
  935. }
  936. }
  937. while (helper.getLevelExp(i) <= totalExp);
  938. if(!can){callback(player_level, (i-1));}
  939. }
  940. });
  941. }
  942.  
  943. function sell(source, keys){
  944. if(inventory.haveCsKeys()){
  945. if(inventory.haveCsKeys() >= keys){
  946. customer.Message(source, msg.CustomerRequest);
  947. inventory.getCustomerSets(false, source, function(err, customer_sets){
  948. if(err){
  949. handleInventoryErrors(err, source);
  950. } else {
  951. let requested_sets=parseInt((keys/keyBuyPrice)*keyBuySets);
  952. if(customer_sets.length > 0){
  953. if(customer_sets.length >= requested_sets){
  954. //customer.Message(source, msg.SendingOffer);
  955. inventory.getToOfferSets(customer_sets, requested_sets, function(toRequest){
  956. inventory.getToOffer_CS_Keys(keys, function(toSend){
  957. makeOffer(source, toSend, [].concat.apply([], toRequest), requested_sets+":"+keys, 1, "keys");
  958. });
  959. });
  960. } else {
  961. customer.Message(source, msg.them_need.replace("{currency_qty}", +customer_sets.length).replace("{currency}", "sets").replace("{needed}", requested_sets));
  962. }
  963. } else {
  964. customer.Message(source, msg.ThemDonthave);
  965. }
  966. }
  967. });
  968. } else {
  969. customer.Message(source, msg.i_need.replace("{currency_qty}", inventory.haveCsKeys()).replace("{currency}", "TF2 keys").replace("{needed}", keys));
  970. }
  971. } else {
  972. customer.Message(source, msg.Sorryme2.replace("{currency_name}", "TF2 keys"))
  973. }
  974. }
  975.  
  976. function sellhydra(source, keys){
  977. if(inventory.haveHydraKeys()){
  978. if(inventory.haveHydraKeys() >= keys){
  979. customer.Message(source, msg.CustomerRequest);
  980. inventory.getCustomerSets(false, source, function(err, customer_sets){
  981. if(err){
  982. handleInventoryErrors(err, source);
  983. } else {
  984. let requested_sets=parseInt((keys/HydrakeyBuyPrice)*HydrakeyBuySets);
  985. if(customer_sets.length > 0){
  986. if(customer_sets.length >= requested_sets){
  987. //customer.Message(source, msg.SendingOffer);
  988. inventory.getToOfferSets(customer_sets, requested_sets, function(toRequest){
  989. inventory.getToOffer_Hydra_Keys(keys, function(toSend){
  990. makeOffer(source, toSend, [].concat.apply([], toRequest), requested_sets+":"+keys, 1, "keys");
  991. });
  992. });
  993. } else {
  994. customer.Message(source, msg.them_need.replace("{currency_qty}", +customer_sets.length).replace("{currency}", "sets").replace("{needed}", requested_sets));
  995. }
  996. } else {
  997. customer.Message(source, msg.ThemDonthave);
  998. }
  999. }
  1000. });
  1001. } else {
  1002. customer.Message(source, msg.i_need.replace("{currency_qty}", inventory.haveCsKeys()).replace("{currency}", "cs:go keys").replace("{needed}", keys));
  1003. }
  1004. } else {
  1005. customer.Message(source, msg.Sorryme2.replace("{currency_name}", "cs:go keys"))
  1006. }
  1007. }
  1008.  
  1009. function sellgems(source, sets){
  1010. let GemsQty = inventory.return_GemsQty();
  1011. if(GemsQty){
  1012. let need = GemBuyPrice*sets;
  1013. if(GemsQty >= need){
  1014. customer.Message(source, msg.CustomerRequest);
  1015. inventory.getCustomerSets(false, source, function(err, customer_sets){
  1016. if(err){
  1017. handleInventoryErrors(err, source);
  1018. } else {
  1019. if(customer_sets.length > 0){
  1020. if(customer_sets.length >= sets){
  1021. //customer.Message(source, msg.SendingOffer);
  1022. inventory.getToOfferSets(customer_sets, sets, function(toRequest){
  1023. inventory.getGems(need, function(toSend){
  1024. makeOffer(source, toSend, [].concat.apply([], toRequest), sets+":"+need, 1, "gems");
  1025. });
  1026. });
  1027. } else {
  1028. customer.Message(source, msg.them_need.replace("{currency_qty}", +customer_sets.length).replace("{currency}", "sets").replace("{needed}", sets));
  1029. }
  1030. } else {
  1031. customer.Message(source, msg.ThemDonthave);
  1032. }
  1033. }
  1034. });
  1035. } else {
  1036. customer.Message(source, msg.i_need.replace("{currency_qty}", GemsQty).replace("{currency}", "gems").replace("{needed}", need));
  1037. }
  1038. } else {
  1039. customer.Message(source, msg.Sorryme2.replace("{currency_name}", "gems"))
  1040. }
  1041. }
  1042.  
  1043. function selltf(source, keys){
  1044. if(inventory.haveTfKeys()){
  1045. if(inventory.haveTfKeys() >= keys){
  1046. customer.Message(source, msg.CustomerRequest);
  1047. inventory.getCustomerSets(false, source, function(err, customer_sets){
  1048. if(err){
  1049. handleInventoryErrors(err, source);
  1050. } else {
  1051. let requested_sets=parseInt((keys/tfkeyBuyPrice)*tfkeyBuySets);
  1052. if(customer_sets.length > 0){
  1053. if(customer_sets.length >= requested_sets){
  1054. //customer.Message(source, msg.SendingOffer);
  1055. inventory.getToOfferSets(customer_sets, requested_sets, function(toRequest){
  1056. inventory.getToOffer_TF_Keys(keys, function(toSend){
  1057. makeOffer(source, toSend, [].concat.apply([], toRequest), requested_sets+":"+keys, 1, "tf keys");
  1058. });
  1059. });
  1060. } else {
  1061. customer.Message(source, msg.them_need.replace("{currency_qty}", +customer_sets.length).replace("{currency}", "sets").replace("{needed}", requested_sets));
  1062. }
  1063. } else {
  1064. customer.Message(source, msg.ThemDonthave);
  1065. }
  1066. }
  1067. });
  1068. } else {
  1069. customer.Message(source, msg.i_need.replace("{currency_qty}", inventory.haveTfKeys()).replace("{currency}", "tf keys").replace("{needed}", keys));
  1070. }
  1071. } else {
  1072. customer.Message(source, msg.Sorryme2.replace("{currency_name}", "tf keys"))
  1073. }
  1074. }
  1075.  
  1076. function sellpubg(source, keys){
  1077. if(inventory.havePUBGKeys()){
  1078. if(inventory.havePUBGKeys() >= keys){
  1079. customer.Message(source, msg.CustomerRequest);
  1080. inventory.getCustomerSets(false, source, function(err, customer_sets){
  1081. if(err){
  1082. handleInventoryErrors(err, source);
  1083. } else {
  1084. let requested_sets=parseInt((keys/PUBGkeyBuyPrice)*PUBGkeyBuySets);
  1085. if(customer_sets.length > 0){
  1086. if(customer_sets.length >= requested_sets){
  1087. //customer.Message(source, msg.SendingOffer);
  1088. inventory.getToOfferSets(customer_sets, requested_sets, function(toRequest){
  1089. inventory.getToOffer_PUBG_Keys(keys, function(toSend){
  1090. makeOffer(source, toSend, [].concat.apply([], toRequest), requested_sets+":"+keys, 1, "PUBG key(s)");
  1091. });
  1092. });
  1093. } else {
  1094. customer.Message(source, msg.them_need.replace("{currency_qty}", +customer_sets.length).replace("{currency}", "sets").replace("{needed}", requested_sets));
  1095. }
  1096. } else {
  1097. customer.Message(source, msg.ThemDonthave);
  1098. }
  1099. }
  1100. });
  1101. } else {
  1102. customer.Message(source, msg.i_need.replace("{currency_qty}", inventory.havePUBGKeys()).replace("{currency}", "PUBG keys").replace("{needed}", keys));
  1103. }
  1104. } else {
  1105. customer.Message(source, msg.Sorryme2.replace("{currency_name}", "PUBG keys"))
  1106. }
  1107. }
  1108.  
  1109. function sellcheck(source){
  1110. customer.Message(source, msg.CustomerRequest);
  1111. inventory.getCustomerSets(false, source, function(err, customer_sets){
  1112. if(err){
  1113. handleInventoryErrors(err, source);
  1114. } else {
  1115. let space = " ";
  1116.  
  1117. let cansell=customer_sets.length;
  1118. if(cansell > 0){
  1119. let response = msg.SellCheck.replace("{amount}", cansell);
  1120. response += space+msg.SellCheck2.replace("{csgokeys_amount}", parseInt((cansell/keyBuySets)*keyBuyPrice)).replace("{csgosets_amount}", (keyBuySets/keyBuyPrice)*parseInt((cansell/keyBuySets)*keyBuyPrice)).replace("{gems_amount}", helper.nFormat((cansell/GemBuySet)*GemBuyPrice)).replace("{gemsets_amount}", cansell);
  1121. if(inventory.enableTF){
  1122. response += msg.SellCheck3.replace("{tfkeys_amount}", parseInt((cansell/tfkeyBuySets)*tfkeyBuyPrice)).replace("{tfsets_amount}", (tfkeyBuySets/tfkeyBuyPrice)*parseInt((cansell/tfkeyBuySets)*tfkeyBuyPrice));
  1123. }
  1124. if(inventory.enableHydra) {
  1125. response += msg.SellCheck4.replace("{hydrakeys_amount}", parseInt((cansell/HydrakeyBuySets)*HydrakeyBuyPrice)).replace("{hydrasets_amount}", (HydrakeyBuySets/HydrakeyBuyPrice)*parseInt((cansell/HydrakeyBuySets)*HydrakeyBuyPrice));
  1126. }
  1127. response += space+msg.SellCheck_i.replace("{sell_qty}", parseInt((cansell/keyBuySets)*keyBuyPrice)).replace("{sellgems_qty}", cansell).replace();
  1128. if(inventory.enableHydra){response.replace("{sellhydra_qty}", parseInt((cansell/HydrakeyBuySets)*keyBuyPrice));}
  1129. if(inventory.enableTF){ response+= msg.SellCheck_i2.replace("{selltf_qty}", parseInt((cansell/tfkeyBuySets)*tfkeyBuyPrice));}
  1130. customer.Message(source, response);
  1131. } else {
  1132. customer.Message(source, msg.ThemDonthave);
  1133. }
  1134. }
  1135. });
  1136. }
  1137.  
  1138. function block(admin, target){
  1139. if(config.admin.indexOf(target) > -1){
  1140. customer.Message(admin, 'You can\'t block this user!');
  1141. } else {
  1142. client.blockUser(target, function(result){
  1143. if(result == 1){
  1144. customer.Message(admin, 'Successfully blocked user '+target+' !');
  1145. } else {
  1146. customer.Message(admin, 'Fail!, did you put the right SteamID64 ??');
  1147. }
  1148. });
  1149. }
  1150. }
  1151.  
  1152. function unblock(admin, target){
  1153. if(config.admin.indexOf(target) > -1){
  1154. customer.Message(admin, B+'You can\'t unblock this user!');
  1155. } else {
  1156. client.unblockUser(target, function(result){
  1157. if(result == 1){
  1158. customer.Message(admin, B+'Successfully unblocked user '+target+' !');
  1159. } else {
  1160. customer.Message(admin, B+'Fail!, did you put the right SteamID64 ??');
  1161. }
  1162. });
  1163. }
  1164. }
  1165.  
  1166. function stats(admin){
  1167. let response = "I currently have "+helper.nFormat(inventory.haveSets())+" sets, "+inventory.haveCsKeys()+" CS:GO keys, "+helper.nFormat(inventory.return_GemsQty())+" Gems";
  1168. if(inventory.enableTF){response += ", "+inventory.haveTfKeys()+" Tf keys";}
  1169. if(inventory.enablePUBG){response += ", "+inventory.havePUBGKeys()+" PUBG Keys";}
  1170. response += " in my inventory.";
  1171. customer.Message(admin, response);
  1172. }
  1173.  
  1174. function _profit(admin){
  1175. let response = "I have sold "+helper.nFormat(profit.sell.csgo.sets)+" sets for "+helper.nFormat(profit.sell.csgo.currency)+" CS:GO keys, "+helper.nFormat(profit.sell.gems.sets)+" sets for "+helper.nFormat(profit.sell.gems.currency)+" Gems";
  1176. if(inventory.enableTF){response += ", "+helper.nFormat(profit.sell.tf.sets)+" sets for "+helper.nFormat(profit.sell.tf.currency)+" Tf keys";}
  1177. if(inventory.enablePUBG){response += ", "+helper.nFormat(profit.sell.PUBG.sets)+" sets for "+helper.nFormat(profit.sell.PUBG.currency)+" PUBG keys";}
  1178. response+" :D";
  1179. response += B+"I have buyed "+helper.nFormat(profit.buy.csgo.sets)+" sets for "+helper.nFormat(profit.buy.csgo.currency)+" CS:GO keys, "+helper.nFormat(profit.buy.gems.sets)+" sets for "+helper.nFormat(profit.buy.gems.currency)+" Gems";
  1180. if(inventory.enableTF){response += ", "+helper.nFormat(profit.buy.tf.sets)+" sets for "+helper.nFormat(profit.buy.tf.currency)+" Tf keys";}
  1181. if(inventory.enablePUBG){response += ", "+helper.nFormat(profit.buy.PUBG.sets)+" sets for "+helper.nFormat(profit.buy.PUBG.currency)+" PUBG keys";}
  1182. customer.Message(admin, response+" =D");
  1183. }
  1184.  
  1185. function stock(admin){
  1186. customer.Message(admin, msg.OwnerRequest);
  1187. inventory.getCustomerSets(true, admin, function(err, sets){
  1188. if(err){
  1189. handleInventoryErrors(err, admin);
  1190. } else {
  1191. if(sets.length){
  1192. customer.Message(admin, "I've found "+sets.length+" sets!, i'll send the trade offer now =D");
  1193. makeOffer(admin, [], [].concat.apply([], sets), 'admin');
  1194. } else {
  1195. customer.Message(admin, msg.ThemDonthave);
  1196. }
  1197. }
  1198. });
  1199. }
  1200.  
  1201. function level(source, qty){
  1202. //customer.Message(source, msg.CustomerRequest);
  1203. inventory.getUserBadges(source, 0, 0, function(err, badge, player_level, player_xp){
  1204. if(err){
  1205. handleBadgeErrors(err, source);
  1206. } else {
  1207. if(qty < player_level){
  1208. customer.Message(source, "You are already level "+qty+"");
  1209. } else {
  1210. let space = " ";
  1211.  
  1212. let needed=Math.ceil( ((helper.getLevelExp(parseInt(qty)))-player_xp)/100 );
  1213. let response = msg.Level.replace("{needed}", needed).replace("{desired_level}", qty);
  1214. response += space+msg.Level_c.replace("{price_keys}", Math.ceil((needed/keySets)*keyPrice)).replace("{price_gems}", helper.nFormat((needed/GemSet)*GemPrice));
  1215. if(inventory.enableTF){response += msg.Level_c2.replace("{price_tf}", Math.ceil((needed/tfkeySets)*keyPrice));}
  1216. response += space+msg.Level2;
  1217. customer.Message(source, response);
  1218. }
  1219. }
  1220. });
  1221. }
  1222.  
  1223. function restart_(){
  1224. helper.log('Restarting..');
  1225. if(!client.steamID){
  1226. tryLogin();
  1227. } else {
  1228. client.relog();
  1229. }
  1230. }
  1231. function shutdown() {
  1232. helper.log('Shutdown requested, bye..');
  1233. try {
  1234. client.logOff();
  1235. client.once('disconnected', () => { process.exit(1); });
  1236. } catch(e) {
  1237. process.exit(1);
  1238. }
  1239. setTimeout(() => { process.exit(1); }, 1500);
  1240. }
  1241.  
  1242. client.on('friendMessage', function(source, message) {
  1243. helper.storeChatLogData(source, message);
  1244.  
  1245. /*if(customer.LastInteract[source] && Math.floor(helper.Now() - customer.LastInteract[source]) < 500){
  1246. if(!customer.Warns[source]){ customer.Warns[source] = 0; }
  1247. customer.Warns[source]++;
  1248. if(customer.Warns[source] == 1){ customer.Message(source, msg.SpamWarn1); }
  1249. if(customer.Warns[source] == 2){ customer.Message(source, msg.SpamWarn2); }
  1250. if(customer.Warns[source] > 5){ client.blockUser(source); }
  1251. else if(customer.Warns[source] > 2){
  1252. customer.Message(source, msg.SpamWarn3);
  1253. customer.sendAdminMessages("User #"+source+" has sending to much messages and have been removed from bot friendlist!");
  1254. helper.warn("User #"+source+" has sending to much messages and have been removed from bot friendlist!");
  1255. client.removeFriend(source);
  1256. }
  1257. return;
  1258. }*/
  1259.  
  1260. customer.UserInteract(source, 0);
  1261.  
  1262. let m = message.toLowerCase();
  1263.  
  1264. if(inventory.loading){
  1265. if(m.indexOf('!buylevel') > -1 || m.indexOf('!buy') > -1 || m.indexOf('!sell') > -1 || m.indexOf('!gemswithdraw') > -1 || m.indexOf('!withdraw') > -1 || m.indexOf('!deposit') > -1 | m.indexOf('!tfdeposit') > -1 | m.indexOf('!tfwithdraw') > -1){
  1266. customer.Message(source, msg.Loading);
  1267. return;
  1268. }
  1269. }
  1270.  
  1271. if(m == "!help" || m == "!commands "){
  1272. let response = "EpicHamMan's Card Set Trading Bot";
  1273. //response += B+'!owner - show my owner profile, if you have any problems you may contact me!';
  1274. //response += B+'!stats - show current bot amount of currencies';
  1275. //response += B+'!prices to see our prices';
  1276. //response += B;
  1277. response += B+'!level <number> - Cost to get to that level';
  1278. response += B+'!check - Total sets available to buy from the bot';
  1279. response += B+'!keys <amount> - Sets you will receive from that many keys';
  1280. //response += B+'!check <amount> - show how many sets and which level you would reach for a specific amount of keys';
  1281. //if(inventory.enableTF){response += B+'!checktf [amount] - show how many sets and which level you would reach for a specific amount of keys';}
  1282. //if(inventory.enablePUBG){response += B+'!checkpubg [amount] - show how many sets and which level you would reach for a specific amount of pubg keys';}
  1283. //response += B+'!checkgems [amount] - show how many sets and which level you would reach for a specific amount of gems';
  1284. response += B;
  1285. response += B+'!buysets <amount> - Buy sets with that many TF2 keys';
  1286. response += B+'!buylevel <amount> - Buy enough sets to reach that level'
  1287.  
  1288. //response += B+'!buyany [amount of CS:GO keys] - use to buy that amount of CS:GO keys for any sets, following the current BOT rate';
  1289. //response += B;
  1290. //response += B+'!buyone [amount of CS:GO keys] - use this if you are a badge collector. BOT will send only one set of each game, following the current BOT rate';
  1291. //if(inventory.enableTF){response += B+'!buyonetf [amount of Tf keys] - use this if you are a badge collector. BOT will send only one set of each game, following the current BOT rate';}
  1292. //if(inventory.enablePUBG){response += B+'!buyonepubg [amount of PUBG keys] - use this if you are a badge collector. BOT will send only one set of each game, following the current BOT rate';}
  1293. //response += B+'!buyonegems [amount of sets] - use this if you are a badge collector. sames as !buyone, buy you pay with gems!';
  1294. //response += B;
  1295. //if(config.enableSell){response += B+'!sell [amount of CS:GO keys] - sell your sets for CS:GO Keys';}
  1296. //if(config.enableSell){response += B+'!sellgems [amount of sets] - sell your sets for gems';}
  1297. //if(inventory.enableTF && config.enableSell){response += B+'!selltf [amount of Tf keys] - sell your sets for Tf Keys';}
  1298. //if(config.enableSell){ response +=B+'!sellcheck - show information about the set(s) you can sell'; }
  1299. customer.Message(source, response);
  1300. }
  1301.  
  1302. else if(m.indexOf("!checktf") > -1 && inventory.enableTF){
  1303. parseInputs(message, source, 1, function(inputs){
  1304. if(inputs){
  1305. checkam(source, inputs, 0, function(lvl, desired){
  1306. if(lvl != level){
  1307. customer.Message(source, "With "+inputs+" tf keys you'll get "+parseInt(inputs/tfkeyPrice)*tfkeySets+" set(s) and reach level "+desired+", interested? try !buytf "+parseInt(inputs/tfkeyPrice));
  1308. } else {
  1309. customer.Message(source, "With "+inputs+" tf keys you'll get "+parseInt(inputs/tfkeyPrice)*tfkeySets+" set(s) but still on level "+lvl+", interested? try !buytf "+parseInt(inputs/tfkeyPrice));
  1310. }
  1311. });
  1312. }
  1313. }, 100);
  1314. }
  1315.  
  1316. else if(m.indexOf("!checkpubg") > -1 && inventory.enablePUBG){
  1317. parseInputs(message, source, 1, function(inputs){
  1318. if(inputs){
  1319. checkpubg(source, inputs, 0, function(lvl, desired){
  1320. if(lvl != level){
  1321. customer.Message(source, "With "+inputs+" PUBG key(s) you'll get "+parseInt(inputs/PUBGkeyPrice)*PUBGkeySets+" set(s) and should be enough to reach level "+desired+", interested? try !buypubg "+parseInt(inputs/PUBGkeyPrice));
  1322. } else {
  1323. customer.Message(source, "With "+inputs+" PUBG key(s) you'll get "+parseInt(inputs/PUBGkeyPrice)*PUBGkeySets+" set(s) but still on level "+lvl+", interested? try !buypubg "+parseInt(inputs/PUBGkeyPrice));
  1324. }
  1325. });
  1326. }
  1327. }, 100);
  1328. }
  1329.  
  1330. else if(m.indexOf("!checkgems") > -1){
  1331. parseInputs(message, source, GemPrice, function(inputs){
  1332. if(inputs){
  1333. checkgam(source, inputs, function(lvl, desired){
  1334. if(lvl != desired){
  1335. customer.Message(source, "With "+inputs+" gems you'll get "+parseInt(inputs/GemPrice)*GemSet+" set(s) and reach level "+desired+", interested? try !buygems "+parseInt(inputs/GemPrice));
  1336. } else {
  1337. customer.Message(source, "With "+inputs+" gems you'll get "+parseInt(inputs/GemPrice)*GemSet+" set(s) but'll stay on level "+lvl+", interested? try !buygems "+parseInt(inputs/GemPrice));
  1338. }
  1339. });
  1340. }
  1341. }, 100000);
  1342. }
  1343.  
  1344. else if(m.indexOf("!check") > -1){
  1345. if(m.split(" ")[1]){
  1346. parseInputs(message, source, 1, function(inputs){
  1347. if(inputs){
  1348. checkam(source, inputs, 1, function(lvl, desired){
  1349. if(lvl != level){
  1350. customer.Message(source, "With "+inputs+" keys you'll get "+parseInt(inputs/keyPrice)*keySets+" set(s) and reach level "+desired+", interested? try !buy "+parseInt(inputs/keyPrice));
  1351. } else {
  1352. customer.Message(source, "With "+inputs+" keys you'll get "+parseInt(inputs/keyPrice)*keySets+" set(s) but'll stay on level "+lvl+", interested? try !buy "+parseInt(inputs/keyPrice));
  1353. }
  1354. });
  1355. }
  1356. }, 100);
  1357. } else { check(source); }
  1358. } else if(m.indexOf("!keys") > -1) {
  1359. if(m.split(" ")[1]){
  1360. parseInputs(message, source, 1, function(inputs){
  1361. if(inputs){
  1362. checkam(source, inputs, 1, function(lvl, desired){
  1363. if(lvl != level){
  1364. customer.Message(source, "With "+inputs+" keys you'll get "+parseInt(inputs/keyPrice)*keySets+" sets and reach level "+desired);
  1365. } else {
  1366. customer.Message(source, "With "+inputs+" keys you'll get "+parseInt(inputs/keyPrice)*keySets+" sets and reach level "+desired);
  1367.  
  1368. }
  1369. });
  1370. }
  1371. }, 100);
  1372. } else { check(source); }
  1373. } else if(m.indexOf("!key") > -1) {
  1374. if(m.split(" ")[1]){
  1375. parseInputs(message, source, 1, function(inputs){
  1376. if(inputs){
  1377. checkam(source, inputs, 1, function(lvl, desired){
  1378. if(lvl != level){
  1379. customer.Message(source, "With "+inputs+" keys you'll get "+parseInt(inputs/keyPrice)*keySets+" sets and reach level "+desired);
  1380. } else {
  1381. customer.Message(source, "With "+inputs+" keys you'll get "+parseInt(inputs/keyPrice)*keySets+" sets and reach level "+desired);
  1382. }
  1383. });
  1384. }
  1385. }, 100);
  1386. } else { check(source); }
  1387. }
  1388.  
  1389. else if (m == '!prices' || m == '!price' || m == '!rate' || m == '!rates' ) {
  1390. let response = 'The current prices are:'
  1391. response += B+keySets+' sets for '+keyPrice+' CS:GO Key';
  1392. if(inventory.enableTF){response += B+tfkeySets+' set(s) for '+tfkeyPrice+' TF Key';}
  1393. if(inventory.enablePUBG){response += B+PUBGkeySets+' set(s) for '+PUBGkeyPrice+' PUBG Keys';}
  1394. response += B+GemPrice+' Gems for '+GemSet+' sets';
  1395. response += B;
  1396. if(config.enableSell){
  1397. response += B+keyBuySets+' sets for '+keyBuyPrice+' CS:GO Keys';
  1398. response += B+HydrakeyBuySets+' sets for '+HydrakeyBuyPrice+' Hydra Keys';
  1399. if(inventory.enableTF){response += B+tfkeyBuySets+' sets for '+tfkeyBuyPrice+' TF Keys';}
  1400. if(inventory.enablePUBG){response += B+PUBGkeyBuySets+' sets for '+PUBGkeyBuyPrice+' PUBG Keys';}
  1401. response += B+GemBuySet+' sets for '+GemBuyPrice+' Gems';
  1402. response += B;
  1403. }
  1404. response += B+'Type !help for more information!';
  1405. customer.Message(source, response);
  1406. }
  1407.  
  1408.  
  1409. else if(m.indexOf('!level') > -1){ parseInputs(message, source, 1, (inputs) => { if(inputs){ level(source, inputs); } }, config.maxLevelComm); }
  1410. else if(m.indexOf('!buylevel') > -1){ parseInputs(message, source, 1, (inputs) => { if(inputs){ buylevel(source, inputs); } }, config.maxLevelComm);}
  1411. else if(m.indexOf('!buygems') > -1){ parseInputs(message, source, 1, (inputs) => { if(inputs){ buygems(source, inputs, 1, 5); } }, 500); }
  1412. else if(m.indexOf('!buyonetf') > -1 && inventory.enableTF){ parseInputs(message, source, 1, (inputs) => { if(inputs){ buytf(source, inputs, 1, 1); } }, config.maxTradeKeys); }
  1413. else if(m.indexOf('!buyonegems') > -1){ parseInputs(message, source, 1, (inputs) => { if(inputs){ buygems(source, inputs, 1, 1); } }, 500); }
  1414. else if(m.indexOf('!buypubg') > -1 && inventory.enablePUBG){ parseInputs(message, source, 1, function(inputs){ if(inputs){ buypubg(source, inputs, 1, 5); } }, config.maxTradeKeys); }
  1415. else if(m.indexOf('!buyonepubg') > -1 && inventory.enablePUBG){ parseInputs(message, source, 1, function(inputs){ if(inputs){ buypubg(source, inputs, 1, 1); } }, config.maxTradeKeys); }
  1416. else if(m.indexOf('!buyone') > -1){ parseInputs(message, source, 1, (inputs) => { if(inputs){ buy(source, inputs, 1, 1); } }, config.maxTradeKeys); }
  1417. else if(m.indexOf('!buytf') > -1 && inventory.enableTF){ parseInputs(message, source, 1, (inputs) => { if(inputs){ buytf(source, inputs, 1, 5); } }, config.maxTradeKeys); }
  1418. else if(m.indexOf('!buyany') > -1){ parseInputs(message, source, 1, (inputs) => { if(inputs){ buy(source, inputs, 0, 5); } }, config.maxTradeKeys); }
  1419. else if(m.indexOf('!buy') > -1){ parseInputs(message, source, 1, (inputs) => { if(inputs){ buy(source, inputs, 1, 5); } }, config.maxTradeKeys); }
  1420. else if(m.indexOf('!sellcheck') > -1 && config.enableSell){ sellcheck(source); }
  1421. else if(m.indexOf('!sellhydra') > -1 && config.enableSell && inventory.enableHydra){ parseInputs(message, source, 1, (inputs) => { if(inputs) { sellhydra(source, inputs) }}, config.maxTradeKeys); }
  1422. else if(m.indexOf('!selltf') > -1 && inventory.enableTF && config.enableSell){ parseInputs(message, source, 1, (inputs) => { if(inputs){ selltf(source, inputs); } }, config.maxTradeKeys); }
  1423. else if(m.indexOf('!sellpubg') > -1 && inventory.enablePUBG && config.enableSell){ parseInputs(message, source, 1, function(inputs){ if(inputs){ sellpubg(source, inputs); } }, config.maxTradeKeys); }
  1424. else if(m.indexOf('!sellgems') > -1 && config.enableSell){ parseInputs(message, source, 1, (inputs) => { if(inputs){ sellgems(source, inputs); } }, 500); }
  1425. else if(m.indexOf('!sell') > -1 && config.enableSell){ parseInputs(message, source, 1, (inputs) => { if(inputs){ sell(source, inputs); } }, config.maxTradeKeys); }
  1426.  
  1427. else if (m == '!owner') {
  1428. let response = "There is something wrong?";
  1429. response += B+"Let me know if you're experiencing issues with my bot!";
  1430. config.admin.forEach( (target, i) => { response += B+"https://steamcommunity.com/profiles/"+target; });
  1431. customer.Message(source, response);
  1432. }
  1433.  
  1434. else if (m == '!dev' || m == '!proof' || m == '!developer') { customer.Message(source, "This bot was developed by https://steamcommunity.com/profiles/76561198177999769"+B+" - Please don't buy from another person."+B+" - This bot is also custom modified by Viwu's Level Service: http://steamcommunity.com/groups/ViwuTradingService - We cooperate with over 95% of all card bots and this is one of them! <3"); community.inviteUserToGroup(source, '103582791458599631');}
  1435. else if(m == '!stats'){ stats(source); }
  1436.  
  1437. else if(config.admin.indexOf(source.getSteamID64()) > -1){
  1438. if (m == '!admin') {
  1439. let response = 'Admin Commands:';
  1440. response += B+'!withdraw [amount] - withdraw x CS:GO keys';
  1441. if(inventory.enableTF){response += B+'!tfwithdraw [amount] - withdraw x Tf keys';}
  1442. if(inventory.enablePUBG){response += B+'!pubgwithdraw [amount] - withdraw x PUBG keys';}
  1443. response += B+'!gemswithdraw [amount] - withdraw x Gems';
  1444. response += B;
  1445. response += B+'!deposit [amount] - deposit x CS:GO keys';
  1446. if(inventory.enableTF){response += B+'!tfdeposit [amount] - deposit x Tf keys';}
  1447. if(inventory.enablePUBG){response += B+'!pubgdeposit [amount] - deposit x PUBG keys';}
  1448. response += B+'!depositgems [amount] - deposit x Gems';
  1449. response += B;
  1450. response += B+'!block [SteamID64] - block user';
  1451. response += B+'!unblock [SteamID64] - unblock user';
  1452. response += B;
  1453. response += B+'!stock - bot will send a trade offer requesting all your available sets to trade';
  1454. response += B+'!profit - show bot sells';
  1455. response += B;
  1456. response += B+'!restart - restart the bot(logoff and login)';
  1457. response += B+'!shutdown - logoff bot and close application';
  1458. response += B;
  1459. response += B+'!send [TradeURL] [amount] - Send X amount of cards to the given tradeurl';
  1460. customer.Message(source, response);
  1461. }
  1462.  
  1463. else if(m == '!profit'){ _profit(source); }
  1464. else if(m == '!stock'){ stock(source); }
  1465. else if(m.indexOf('!gemswithdraw') > -1){ parseInputs(message, source, 1, (inputs) => { if(inputs){ gemswithdraw(source, inputs); } }); }
  1466. else if(m.indexOf('!tfwithdraw') > -1 && inventory.enableTF){ parseInputs(message, source, 1, (inputs) => { if(inputs){ tfwithdraw(source, inputs); } }); }
  1467. else if(m.indexOf('!pubgwithdraw') > -1 && inventory.enablePUBG){ parseInputs(message, source, 1, function(inputs){ if(inputs){pubgwithdraw(source, inputs); } }); }
  1468. else if(m.indexOf('!withdraw') > -1){ parseInputs(message, source, 1, (inputs) => { if(inputs){ withdraw(source, inputs); } }); }
  1469. else if(m.indexOf('!pubgdeposit') > -1 && inventory.enablePUBG){ parseInputs(message, source, 1, function(inputs){ if(inputs){ pubgdeposit(source, inputs); } }); }
  1470. else if(m.indexOf('!tfdeposit') > -1 && inventory.enableTF){ parseInputs(message, source, 1, (inputs) => { if(inputs){ tfdeposit(source, inputs); } }); }
  1471. else if(m.indexOf('!depositgems') > -1){ parseInputs(message, source, 1, (inputs) => { if(inputs){ depositgems(source, inputs); } }); }
  1472. else if(m.indexOf('!deposit') > -1){ parseInputs(message, source, 1, (inputs) => { if(inputs){ deposit(source, inputs); } }); }
  1473. else if(m.indexOf('!block') > -1){ isId64(message, source, (sid) => { if(sid){block(source, sid);} }); }
  1474. else if(m.indexOf('!unblock') > -1){ isId64(message, source, (sid) => { if(sid){unblock(source, sid);} }); }
  1475. else if(m.indexOf('!send') > -1){ send(source, message.split(" "));}
  1476.  
  1477. else if(m == '!restart'){ customer.Message(source, "I'll be back in a minute!"); restart_(); }
  1478. else if(m == '!shutdown'){ customer.Message(source, "I going down :("); shutdown(); }
  1479.  
  1480. //else { customer.Message(source, msg.UnknowAdmin); }
  1481. }
  1482.  
  1483. //else { customer.Message(source, msg.Unknow); }
  1484. });
  1485.  
  1486. client.on('friendRelationship', (steamid, relationship) => { if (relationship === 2) { addFriend(steamid); } customer.checkRemove(); });
  1487.  
  1488. function isId64(message, target, callback){ let sid=message.split(" ")[1]; if(/[0-9]{17}/.test(sid)){ callback(sid); } else { customer.Message(target, "Try "+message.split(" ")[0]+" [SteamId64]"); callback(0); } }
  1489.  
  1490. function parseInputs(message, target, min, callback, max){
  1491. let qty=parseInt(message.split(" ")[1]);
  1492. let isNumber=!(isNaN(qty));
  1493. if(isNumber){
  1494. if(!(qty >= min)){ customer.Message(target, "The amount should be "+min+" or higher."); callback(0); }
  1495. else { if(max && qty > max){ customer.Message(target, "The amount should be lower than "+max); callback(0); } else { callback(qty); } }
  1496. }
  1497. else { customer.Message(target, "Try "+message.split(" ")[0]+" [amount]"); callback(0); }
  1498. }
  1499.  
  1500. function handleInventoryErrors(err, target){
  1501. if(err.message.indexOf("profile is private") > -1){
  1502. customer.Message(target, msg.Inventory_priv);
  1503. } else {
  1504. helper.logError(err.message, 'Inventory');
  1505. customer.Message(target, msg.Inventory_error);
  1506. }
  1507. }
  1508.  
  1509. function handleBadgeErrors(err, source){
  1510. if(err.message == 'empty'){
  1511. customer.Message(source, "Please make sure your profile is set to public.");
  1512. } else {
  1513. helper.logError(err.message, 'Badge');
  1514. customer.Message(source, msg.Badge_error);
  1515. }
  1516. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement