├── Data ├── User │ └── .gitkeep ├── AcceptedTrades │ └── .gitkeep ├── History │ ├── Error │ │ └── .gitkeep │ ├── Info │ │ └── .gitkeep │ ├── Warn │ │ └── .gitkeep │ ├── AdminChat │ │ └── .gitkeep │ ├── TradeOffer │ │ └── .gitkeep │ ├── UserChat │ │ └── .gitkeep │ └── Profit │ │ ├── Daily │ │ └── .gitkeep │ │ ├── Monthly │ │ └── .gitkeep │ │ └── Yearly │ │ └── .gitkeep └── ChatLogs │ ├── BotLogs │ └── .gitkeep │ └── UserLogs │ └── .gitkeep ├── install.bat ├── .eslintignore ├── update.bat ├── .prettierrc.json ├── start.bat ├── .editorconfig ├── src ├── Components │ ├── message.js │ ├── ErrorHandle │ │ └── constants │ │ │ ├── colors.js │ │ │ └── commands.js │ ├── relationShip.js │ ├── profit │ │ ├── constants │ │ │ └── profit.js │ │ └── index.js │ ├── login.js │ ├── reputation.js │ ├── rank.js │ ├── offer.js │ ├── sets.js │ ├── steamSupply.js │ ├── user.js │ ├── request.js │ └── log.js ├── Commands │ ├── User │ │ ├── GENERAL │ │ │ ├── OWNER │ │ │ │ └── index.js │ │ │ ├── TUTORIAL │ │ │ │ └── index.js │ │ │ ├── HELP │ │ │ │ └── index.js │ │ │ ├── LANGUAGE │ │ │ │ ├── CN │ │ │ │ │ └── index.js │ │ │ │ ├── JA │ │ │ │ │ └── index.js │ │ │ │ ├── index.js │ │ │ │ ├── RU │ │ │ │ │ └── index.js │ │ │ │ ├── DE │ │ │ │ │ └── index.js │ │ │ │ ├── EN │ │ │ │ │ └── index.js │ │ │ │ ├── ES │ │ │ │ │ └── index.js │ │ │ │ ├── FR │ │ │ │ │ └── index.js │ │ │ │ └── PT │ │ │ │ │ └── index.js │ │ │ ├── COMMANDS │ │ │ │ └── index.js │ │ │ ├── PRICES │ │ │ │ └── index.js │ │ │ ├── RANK │ │ │ │ └── index.js │ │ │ ├── REPORT │ │ │ │ └── index.js │ │ │ ├── KEYLIST │ │ │ │ └── index.js │ │ │ ├── INVITE │ │ │ │ └── index.js │ │ │ ├── STOCK │ │ │ │ └── index.js │ │ │ ├── LEVEL │ │ │ │ └── index.js │ │ │ ├── CHECKONE │ │ │ │ └── index.js │ │ │ └── SELLCHECK │ │ │ │ └── index.js │ │ ├── TF │ │ │ ├── CHECK │ │ │ │ └── index.js │ │ │ └── BUYANY │ │ │ │ └── index.js │ │ ├── CSGO │ │ │ ├── CHECK │ │ │ │ └── index.js │ │ │ └── BUYANY │ │ │ │ └── index.js │ │ ├── HYDRA │ │ │ ├── CHECK │ │ │ │ └── index.js │ │ │ └── BUYANY │ │ │ │ └── index.js │ │ └── GEMS │ │ │ ├── CHECK │ │ │ └── index.js │ │ │ └── BUYANY │ │ │ └── index.js │ ├── Unknow │ │ └── index.js │ ├── Admin │ │ ├── GENERAL │ │ │ ├── DIE │ │ │ │ └── index.js │ │ │ ├── RESTART │ │ │ │ └── index.js │ │ │ ├── ADMIN │ │ │ │ └── index.js │ │ │ ├── AUTHCODE │ │ │ │ └── index.js │ │ │ ├── BROADCAST │ │ │ │ └── index.js │ │ │ ├── RELOAD │ │ │ │ └── index.js │ │ │ ├── UNBLOCK │ │ │ │ └── index.js │ │ │ ├── BLOCK │ │ │ │ └── index.js │ │ │ ├── REQUESTER │ │ │ │ └── index.js │ │ │ ├── MYSTATS │ │ │ │ └── index.js │ │ │ ├── UNPACK │ │ │ │ └── index.js │ │ │ ├── CANCEL │ │ │ │ └── index.js │ │ │ ├── RESTOCK │ │ │ │ └── index.js │ │ │ ├── ROLLBACK │ │ │ │ └── index.js │ │ │ ├── USERCHECK │ │ │ │ └── index.js │ │ │ ├── WITHDRAWLEFTOVER │ │ │ │ └── index.js │ │ │ └── PROFIT │ │ │ │ └── index.js │ │ ├── BOOSTER │ │ │ ├── WITHDRAW │ │ │ │ └── index.js │ │ │ └── DEPOSIT │ │ │ │ └── index.js │ │ ├── TF │ │ │ ├── WITHDRAW │ │ │ │ └── index.js │ │ │ └── DEPOSIT │ │ │ │ └── index.js │ │ ├── CSGO │ │ │ ├── WITHDRAW │ │ │ │ └── index.js │ │ │ └── DEPOSIT │ │ │ │ └── index.js │ │ ├── HYDRA │ │ │ ├── WITHDRAW │ │ │ │ └── index.js │ │ │ └── DEPOSIT │ │ │ │ └── index.js │ │ ├── GEMS │ │ │ ├── WITHDRAW │ │ │ │ └── index.js │ │ │ └── DEPOSIT │ │ │ │ └── index.js │ │ ├── SETS │ │ │ ├── WITHDRAW │ │ │ │ └── index.js │ │ │ └── DEPOSIT │ │ │ │ └── index.js │ │ └── index.js │ └── index.js └── Config │ ├── rates.js │ ├── currencies.js │ └── main.example.js ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── workflows │ └── codeql-analysis.yml ├── .eslintrc.json ├── LICENSE ├── package.json ├── CONTRIBUTING.md ├── .gitignore ├── CODE_OF_CONDUCT.md └── TUTORIAL.md /Data/User/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/AcceptedTrades/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/History/Error/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/History/Info/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/History/Warn/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/ChatLogs/BotLogs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/ChatLogs/UserLogs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/History/AdminChat/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/History/TradeOffer/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/History/UserChat/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/History/Profit/Daily/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/History/Profit/Monthly/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Data/History/Profit/Yearly/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /install.bat: -------------------------------------------------------------------------------- 1 | npm install --production --force -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | package.json -------------------------------------------------------------------------------- /update.bat: -------------------------------------------------------------------------------- 1 | npx -p npm-check-updates ncu -u && npm i 2 | pause 3 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "traillingComma": "es5" 4 | } -------------------------------------------------------------------------------- /start.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | :loop 3 | title *** Bot Card *** 4 | color 07 5 | echo 1: node 6 | node --max-old-space-size=4096 src/index.js 7 | GOTO loop -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = false 9 | insert_final_newline = false -------------------------------------------------------------------------------- /src/Components/message.js: -------------------------------------------------------------------------------- 1 | const log = require('./log'); 2 | 3 | const chatMessage = (client, id64, msg) => { 4 | client.chatMessage(id64, msg); 5 | log.botChatFullMessages(id64, msg); 6 | }; 7 | module.exports = chatMessage; 8 | -------------------------------------------------------------------------------- /src/Components/ErrorHandle/constants/colors.js: -------------------------------------------------------------------------------- 1 | const colors = [ 2 | 'yellowBright', 3 | 'redBright', 4 | 'greenBright', 5 | 'whiteBright', 6 | 'blackBright', 7 | 'blueBright', 8 | 'magentaBright', 9 | 'cyanBright', 10 | ]; 11 | 12 | module.exports = colors; 13 | -------------------------------------------------------------------------------- /src/Components/relationShip.js: -------------------------------------------------------------------------------- 1 | function relationShip(client, id64, callback) { 2 | let relation = ''; 3 | 4 | switch (client.myFriends[id64]) { 5 | case 3: 6 | relation = 'FRIEND'; 7 | break; 8 | case 5: 9 | relation = 'BANNED'; 10 | break; 11 | default: 12 | relation = 'NOTAFRIEND'; 13 | } 14 | 15 | callback(relation); 16 | } 17 | 18 | module.exports = relationShip; 19 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/OWNER/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const main = require('../../../../Config/main'); 3 | const log = require('../../../../Components/log'); 4 | const utils = require('../../../../Utils'); 5 | 6 | module.exports = (sender, client, users) => { 7 | const language = utils.getLanguage(sender.getSteamID64(), users); 8 | log.userChat(sender.getSteamID64(), language, '[ !OWNER ]'); 9 | chatMessage(client, sender, main.owner); 10 | }; 11 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/TUTORIAL/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const main = require('../../../../Config/main'); 3 | const log = require('../../../../Components/log'); 4 | const utils = require('../../../../Utils'); 5 | 6 | module.exports = (sender, client, users) => { 7 | const language = utils.getLanguage(sender.getSteamID64(), users); 8 | 9 | log.userChat(sender.getSteamID64(), language, '[ !TUTORIAL ]'); 10 | chatMessage(client, sender, main.tutorial); 11 | }; 12 | -------------------------------------------------------------------------------- /src/Commands/Unknow/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../Components/message'); 2 | const main = require('../../Config/main'); 3 | const messages = require('../../Config/messages'); 4 | const utils = require('../../Utils'); 5 | 6 | module.exports = (sender, client, users) => { 7 | const language = utils.getLanguage(sender.getSteamID64(), users); 8 | 9 | if (main.admins.includes(sender.getSteamID64())) { 10 | chatMessage(client, sender, messages.ERROR.INPUT.UNKNOW.ADMIN[language]); 11 | } else { 12 | chatMessage(client, sender, messages.ERROR.INPUT.UNKNOW.CUSTOMER[language]); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/DIE/index.js: -------------------------------------------------------------------------------- 1 | const kill = require('tree-kill'); 2 | const process = require('process'); 3 | 4 | const messages = require('../../../../Config/messages'); 5 | const chatMessage = require('../../../../Components/message'); 6 | const log = require('../../../../Components/log'); 7 | const utils = require('../../../../Utils'); 8 | 9 | module.exports = (sender, client, users) => { 10 | const language = utils.getLanguage(sender.getSteamID64(), users); 11 | 12 | chatMessage(client, sender, messages.REQUEST[language]); 13 | log.adminChat(sender.getSteamID64(), language, '[ !DIE ]'); 14 | kill(process.ppid); 15 | }; 16 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/RESTART/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const chatMessage = require('../../../../Components/message'); 3 | const log = require('../../../../Components/log'); 4 | const { restart } = require('../../../../Components/login'); 5 | const utils = require('../../../../Utils'); 6 | 7 | module.exports = (sender, client, users) => { 8 | const language = utils.getLanguage(sender.getSteamID64(), users); 9 | 10 | chatMessage(client, sender, messages.REQUEST[language]); 11 | log.adminChat(sender.getSteamID64(), language, '[ !RESTART ]'); 12 | chatMessage(client, sender, messages.RESTART[language]); 13 | restart(client); 14 | }; 15 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/HELP/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const messages = require('../../../../Config/messages'); 3 | const log = require('../../../../Components/log'); 4 | const main = require('../../../../Config/main'); 5 | const utils = require('../../../../Utils'); 6 | 7 | module.exports = (sender, client, users, lang) => { 8 | const language = lang || utils.getLanguage(sender.getSteamID64(), users); 9 | 10 | log.userChat(sender.getSteamID64(), language, '[ !HELP ]'); 11 | 12 | chatMessage(client, sender, messages.HELP[language]); 13 | 14 | if (main.tutorial) { 15 | chatMessage(client, sender, `${main.tutorial}`); 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | labels: enhancement 5 | assignees: Luc4sguilherme 6 | 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 11 | 12 | **Describe the solution you'd like** 13 | A clear and concise description of what you want to happen. 14 | 15 | **Describe alternatives you've considered** 16 | A clear and concise description of any alternative solutions or features you've considered. 17 | 18 | **Additional context** 19 | Add any other context or screenshots about the feature request here. 20 | -------------------------------------------------------------------------------- /src/Config/rates.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | csgo: { 3 | buy: 50, // how many sets you will buy for a csgo key (!SELLCSGO) 4 | sell: 32, // how many sets you will sell for a csgo key (!BUYCSGO) 5 | }, 6 | 7 | hydra: { 8 | buy: 25, // how many sets you will buy for a csgo hydra key (!SELLHYDRA) 9 | sell: 12, // how many sets you will sell for a csgo hydra key (!BUYHYDRA) 10 | }, 11 | 12 | tf: { 13 | buy: 30, // how many sets you will buy for a tf2 key (!SELLTF) 14 | sell: 24, // how many sets you will sell for a tf2 key (!BUYTF) 15 | }, 16 | 17 | gems: { 18 | buy: 200, // how many gems you will pay for a set (!SELLGEMS) 19 | sell: 550, // how many gems you will take for a set (!BUYGEMS) 20 | }, 21 | }; 22 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "commonjs": true, 4 | "es2020": true 5 | }, 6 | "extends": [ 7 | "airbnb-base", 8 | "prettier", 9 | "plugin:node/recommended" 10 | ], 11 | "parserOptions": { 12 | "ecmaVersion": 11 13 | }, 14 | "plugins": ["prettier"], 15 | "rules": { 16 | "prettier/prettier": "error", 17 | "no-unused-vars": "warn", 18 | "no-console": "off", 19 | "func-names": "off", 20 | "no-process-exit": "off", 21 | "object-shorthand": "off", 22 | "class-methods-use-this": "off", 23 | "node/no-unpublished-require": "off", 24 | "no-labels": "off", 25 | "no-continue": "off" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/ADMIN/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const chatMessage = require('../../../../Components/message'); 3 | const log = require('../../../../Components/log'); 4 | const { filterCommands } = require('../../../../Utils'); 5 | const utils = require('../../../../Utils'); 6 | 7 | module.exports = (sender, client, users) => { 8 | const language = utils.getLanguage(sender.getSteamID64(), users); 9 | const msg = filterCommands(messages.ADMIN[language], true); 10 | 11 | log.adminChat(sender.getSteamID64(), language, '[ !ADMIN ]'); 12 | 13 | let message = '/pre '; 14 | for (let i = 0; i < msg.length; i += 1) { 15 | message += msg[i]; 16 | } 17 | chatMessage(client, sender, message); 18 | }; 19 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/AUTHCODE/index.js: -------------------------------------------------------------------------------- 1 | const SteamTotp = require('steam-totp'); 2 | const messages = require('../../../../Config/messages'); 3 | const main = require('../../../../Config/main'); 4 | const chatMessage = require('../../../../Components/message'); 5 | const log = require('../../../../Components/log'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, client, users) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | log.adminChat(sender.getSteamID64(), language, '[ !AUTHCODE ]'); 11 | chatMessage( 12 | client, 13 | sender, 14 | messages.AUTHCODE[language].replace( 15 | '{CODE}', 16 | SteamTotp.getAuthCode(main.sharedSecret) 17 | ) 18 | ); 19 | }; 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: Luc4sguilherme 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. '...' 16 | 2. '....' 17 | 3. '....' 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots** 23 | If applicable, add screenshots to help explain your problem. 24 | 25 | **Desktop (please complete the following information):** 26 | - OS: [e.g. iOS] 27 | - Version [e.g. 22] 28 | 29 | **Additional context** 30 | Add any other context about the problem here. 31 | -------------------------------------------------------------------------------- /src/Commands/index.js: -------------------------------------------------------------------------------- 1 | const User = require('./User'); 2 | const Admin = require('./Admin'); 3 | const main = require('../Config/main'); 4 | const Unknow = require('./Unknow'); 5 | 6 | function commands(sender, msg, client, users, community, allCards, manager) { 7 | if (main.admins.includes(sender.getSteamID64())) { 8 | if ( 9 | Admin(sender, msg, client, users, community, allCards, manager) === 10 | 'UNKNOW' && 11 | User(sender, msg, client, users, community, allCards, manager) === 12 | 'UNKNOW' 13 | ) { 14 | Unknow(sender, client, users); 15 | } 16 | } else if ( 17 | User(sender, msg, client, users, community, allCards, manager) === 'UNKNOW' 18 | ) { 19 | Unknow(sender, client, users); 20 | } 21 | } 22 | module.exports = commands; 23 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/LANGUAGE/CN/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('graceful-fs'); 2 | const chatMessage = require('../../../../../Components/message'); 3 | const log = require('../../../../../Components/log'); 4 | const utils = require('../../../../../Utils'); 5 | 6 | module.exports = (sender, client, users) => { 7 | const user = users; 8 | log.userChat( 9 | sender.getSteamID64(), 10 | utils.getLanguage(sender.getSteamID64(), user), 11 | 12 | '[ !CN ]' 13 | ); 14 | user[sender.getSteamID64()].language = 'CN'; 15 | fs.writeFile('./Data/User/Users.json', JSON.stringify(user), (ERR) => { 16 | if (ERR) { 17 | log.error(`An error occurred while writing UserData file: ${ERR}`); 18 | } else { 19 | chatMessage(client, sender, '语言变为中文'); 20 | } 21 | }); 22 | }; 23 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/LANGUAGE/JA/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('graceful-fs'); 2 | const chatMessage = require('../../../../../Components/message'); 3 | const log = require('../../../../../Components/log'); 4 | const utils = require('../../../../../Utils'); 5 | 6 | module.exports = (sender, client, users) => { 7 | const user = users; 8 | log.userChat( 9 | sender.getSteamID64(), 10 | utils.getLanguage(sender.getSteamID64(), user), 11 | '[ !JA ]' 12 | ); 13 | user[sender.getSteamID64()].language = 'JA'; 14 | fs.writeFile('./Data/User/Users.json', JSON.stringify(user), (ERR) => { 15 | if (ERR) { 16 | log.error(`An error occurred while writing UserData file: ${ERR}`); 17 | } else { 18 | chatMessage(client, sender, '言語が日本語に変更されました'); 19 | } 20 | }); 21 | }; 22 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/LANGUAGE/index.js: -------------------------------------------------------------------------------- 1 | const log = require('../../../../Components/log'); 2 | const messages = require('../../../../Config/messages'); 3 | const chatMessage = require('../../../../Components/message'); 4 | const { filterCommands } = require('../../../../Utils'); 5 | const utils = require('../../../../Utils'); 6 | 7 | module.exports = (sender, client, users) => { 8 | const language = utils.getLanguage(sender.getSteamID64(), users); 9 | 10 | log.userChat(sender.getSteamID64(), `${language}`, '[ !LANG ]'); 11 | let message = ''; 12 | for (let i = 0; i < messages.LANGUAGE[language].length; i += 1) { 13 | message += messages.LANGUAGE[language][i]; 14 | } 15 | 16 | message = `/pre ${filterCommands(message).join('\n')}`; 17 | chatMessage(client, sender, message); 18 | }; 19 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/LANGUAGE/RU/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('graceful-fs'); 2 | const chatMessage = require('../../../../../Components/message'); 3 | const log = require('../../../../../Components/log'); 4 | const utils = require('../../../../../Utils'); 5 | 6 | module.exports = (sender, client, users) => { 7 | const user = users; 8 | log.userChat( 9 | sender.getSteamID64(), 10 | utils.getLanguage(sender.getSteamID64(), user), 11 | '[ !RU ]' 12 | ); 13 | user[sender.getSteamID64()].language = 'RU'; 14 | fs.writeFile('./Data/User/Users.json', JSON.stringify(user), (ERR) => { 15 | if (ERR) { 16 | log.error(`An error occurred while writing UserData file: ${ERR}`); 17 | } else { 18 | chatMessage(client, sender, 'Язык изменен на русский.'); 19 | } 20 | }); 21 | }; 22 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/LANGUAGE/DE/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('graceful-fs'); 2 | const chatMessage = require('../../../../../Components/message'); 3 | const log = require('../../../../../Components/log'); 4 | const utils = require('../../../../../Utils'); 5 | 6 | module.exports = (sender, client, users) => { 7 | const user = users; 8 | log.userChat( 9 | sender.getSteamID64(), 10 | utils.getLanguage(sender.getSteamID64(), user), 11 | '[ !DE ]' 12 | ); 13 | user[sender.getSteamID64()].language = 'DE'; 14 | fs.writeFile('./Data/User/Users.json', JSON.stringify(user), (ERR) => { 15 | if (ERR) { 16 | log.error(`An error occurred while writing UserData file: ${ERR}`); 17 | } else { 18 | chatMessage(client, sender, 'Sprache auf Deutsch geändert'); 19 | } 20 | }); 21 | }; 22 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/LANGUAGE/EN/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('graceful-fs'); 2 | const chatMessage = require('../../../../../Components/message'); 3 | const log = require('../../../../../Components/log'); 4 | const utils = require('../../../../../Utils'); 5 | 6 | module.exports = (sender, client, users) => { 7 | const user = users; 8 | log.userChat( 9 | sender.getSteamID64(), 10 | utils.getLanguage(sender.getSteamID64(), user), 11 | '[ !EN ]' 12 | ); 13 | user[sender.getSteamID64()].language = 'EN'; 14 | fs.writeFile('./Data/User/Users.json', JSON.stringify(user), (ERR) => { 15 | if (ERR) { 16 | log.error(`An error occurred while writing UserData file: ${ERR}`); 17 | } else { 18 | chatMessage(client, sender, 'Language changed to English'); 19 | } 20 | }); 21 | }; 22 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/LANGUAGE/ES/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('graceful-fs'); 2 | const chatMessage = require('../../../../../Components/message'); 3 | const log = require('../../../../../Components/log'); 4 | const utils = require('../../../../../Utils'); 5 | 6 | module.exports = (sender, client, users) => { 7 | const user = users; 8 | log.userChat( 9 | sender.getSteamID64(), 10 | utils.getLanguage(sender.getSteamID64(), user), 11 | '[ !ES ]' 12 | ); 13 | user[sender.getSteamID64()].language = 'ES'; 14 | fs.writeFile('./Data/User/Users.json', JSON.stringify(user), (ERR) => { 15 | if (ERR) { 16 | log.error(`An error occurred while writing UserData file: ${ERR}`); 17 | } else { 18 | chatMessage(client, sender, 'Idioma cambiado a español'); 19 | } 20 | }); 21 | }; 22 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/LANGUAGE/FR/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('graceful-fs'); 2 | const chatMessage = require('../../../../../Components/message'); 3 | const log = require('../../../../../Components/log'); 4 | const utils = require('../../../../../Utils'); 5 | 6 | module.exports = (sender, client, users) => { 7 | const user = users; 8 | log.userChat( 9 | sender.getSteamID64(), 10 | utils.getLanguage(sender.getSteamID64(), user), 11 | '[ !FR ]' 12 | ); 13 | user[sender.getSteamID64()].language = 'FR'; 14 | fs.writeFile('./Data/User/Users.json', JSON.stringify(user), (ERR) => { 15 | if (ERR) { 16 | log.error(`An error occurred while writing UserData file: ${ERR}`); 17 | } else { 18 | chatMessage(client, sender, 'Langue changée en français'); 19 | } 20 | }); 21 | }; 22 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/LANGUAGE/PT/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('graceful-fs'); 2 | const chatMessage = require('../../../../../Components/message'); 3 | const log = require('../../../../../Components/log'); 4 | const utils = require('../../../../../Utils'); 5 | 6 | module.exports = (sender, client, users) => { 7 | const user = users; 8 | log.userChat( 9 | sender.getSteamID64(), 10 | utils.getLanguage(sender.getSteamID64(), user), 11 | '[ !PT ]' 12 | ); 13 | user[sender.getSteamID64()].language = 'PT'; 14 | fs.writeFile('./Data/User/Users.json', JSON.stringify(user), (ERR) => { 15 | if (ERR) { 16 | log.error(`An error occurred while writing UserData file: ${ERR}`); 17 | } else { 18 | chatMessage(client, sender, 'Idioma alterado para Português'); 19 | } 20 | }); 21 | }; 22 | -------------------------------------------------------------------------------- /src/Components/profit/constants/profit.js: -------------------------------------------------------------------------------- 1 | const profit = { 2 | totaltrades: 0, 3 | status: { 4 | sets: 0, 5 | csgo: 0, 6 | gems: 0, 7 | hydra: 0, 8 | tf: 0, 9 | }, 10 | sell: { 11 | csgo: { 12 | sets: 0, 13 | currency: 0, 14 | }, 15 | gems: { 16 | sets: 0, 17 | currency: 0, 18 | }, 19 | hydra: { 20 | sets: 0, 21 | currency: 0, 22 | }, 23 | tf: { 24 | sets: 0, 25 | currency: 0, 26 | }, 27 | }, 28 | buy: { 29 | csgo: { 30 | sets: 0, 31 | currency: 0, 32 | }, 33 | gems: { 34 | sets: 0, 35 | currency: 0, 36 | }, 37 | hydra: { 38 | sets: 0, 39 | currency: 0, 40 | }, 41 | tf: { 42 | sets: 0, 43 | currency: 0, 44 | }, 45 | }, 46 | }; 47 | 48 | module.exports = profit; 49 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/BROADCAST/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const log = require('../../../../Components/log'); 3 | const messages = require('../../../../Config/messages'); 4 | const utils = require('../../../../Utils'); 5 | 6 | module.exports = (sender, msg, client, users) => { 7 | const language = utils.getLanguage(sender.getSteamID64(), users); 8 | const n = msg.substring('!BROADCAST'.length).trim(); 9 | if (n.length > 0) { 10 | log.adminChat(sender.getSteamID64(), language, `[ !BROADCAST ${n} ]`); 11 | for (let i = 0; i <= Object.keys(client.myFriends).length; i += 1) { 12 | if (Object.values(client.myFriends)[i] === 3) { 13 | chatMessage(client, Object.keys(client.myFriends)[i], `/pre ${n}`); 14 | } 15 | } 16 | } else { 17 | chatMessage(client, sender, messages.ERROR.INPUT.INVALID.MESSAGE[language]); 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/COMMANDS/index.js: -------------------------------------------------------------------------------- 1 | const log = require('../../../../Components/log'); 2 | const messages = require('../../../../Config/messages'); 3 | const chatMessage = require('../../../../Components/message'); 4 | const { filterCommands } = require('../../../../Utils'); 5 | const utils = require('../../../../Utils'); 6 | 7 | module.exports = (sender, client, users, lang) => { 8 | const language = lang || utils.getLanguage(sender.getSteamID64(), users); 9 | const msg = filterCommands(messages.COMMANDS[language]); 10 | 11 | log.userChat(sender.getSteamID64(), language, '[ !COMMANDS ]'); 12 | 13 | let message1 = '/pre '; 14 | for (let i = 0; i < 14; i += 1) { 15 | message1 += msg[i]; 16 | } 17 | chatMessage(client, sender, message1); 18 | 19 | let message2 = '/pre '; 20 | for (let i = 14; i < msg.length; i += 1) { 21 | message2 += msg[i]; 22 | } 23 | chatMessage(client, sender, message2); 24 | }; 25 | -------------------------------------------------------------------------------- /src/Config/currencies.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | steamGems: ['753-Gems'], 3 | 4 | csgo: [ 5 | // keys CS:GO 6 | 'CS20 Case Key', 7 | 'Chroma Case Key', 8 | 'Chroma 2 Case Key', 9 | 'Chroma 3 Case Key', 10 | 'CS:GO Case Key', 11 | 'Clutch Case Key', 12 | 'Danger Zone Case Key', 13 | 'eSports Key', 14 | 'Falchion Case Key', 15 | 'Gamma Case Key', 16 | 'Gamma 2 Case Key', 17 | 'Glove Case Key', 18 | 'Huntsman Case Key', 19 | 'Horizon Case Key', 20 | 'Operation Breakout Case Key', 21 | 'Operation Phoenix Case Key', 22 | 'Operation Vanguard Case Key', 23 | 'Operation Wildfire Case Key', 24 | 'Prisma Case Key', 25 | 'Revolver Case Key', 26 | 'Shadow Case Key', 27 | 'Spectrum Case Key', 28 | 'Spectrum 2 Case Key', 29 | 'Winter Offensive Case Key', 30 | ], 31 | 32 | hydra: [ 33 | // keys HYDRA 34 | 'Operation Hydra Case Key', 35 | ], 36 | 37 | tf: [ 38 | // keys TF2 39 | 'Mann Co. Supply Crate Key', 40 | ], 41 | }; 42 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/PRICES/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const messages = require('../../../../Config/messages'); 3 | const rates = require('../../../../Config/rates'); 4 | const log = require('../../../../Components/log'); 5 | const { filterCommands } = require('../../../../Utils'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, client, users) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | 11 | log.userChat(sender.getSteamID64(), language, '[ !PRICES ]'); 12 | chatMessage( 13 | client, 14 | sender, 15 | filterCommands(messages.PRICES[language]) 16 | .join('\n') 17 | .replace('{CSGOSELL}', rates.csgo.sell) 18 | .replace('{TFSELL}', rates.tf.sell) 19 | .replace('{HYDRASELL}', rates.hydra.sell) 20 | .replace('{GEMSSELL}', rates.gems.sell) 21 | .replace('{CSGOBUY}', rates.csgo.buy) 22 | .replace('{TFBUY}', rates.tf.buy) 23 | .replace('{HYDRABUY}', rates.hydra.buy) 24 | .replace('{GEMSBUY}', rates.gems.buy) 25 | ); 26 | }; 27 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/RANK/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const log = require('../../../../Components/log'); 3 | const { rank } = require('../../../../Components/rank'); 4 | const chatMessage = require('../../../../Components/message'); 5 | const utils = require('../../../../Utils'); 6 | 7 | module.exports = async (sender, client, users) => { 8 | const language = utils.getLanguage(sender.getSteamID64(), users); 9 | 10 | log.userChat(sender.getSteamID64(), language, '[ !RANK ]'); 11 | chatMessage(client, sender, messages.REQUEST[language]); 12 | 13 | try { 14 | const { WORLDWIDEXP, REGIONXP, COUNTRYXP } = await rank( 15 | sender.getSteamID64() 16 | ); 17 | chatMessage( 18 | client, 19 | sender, 20 | messages.RANK.RESPONSE[language] 21 | .replace('{WORLDWIDEXP}', WORLDWIDEXP) 22 | .replace('{REGIONXP}', REGIONXP) 23 | .replace('{COUNTRYXP}', COUNTRYXP) 24 | ); 25 | } catch (error) { 26 | log.error(`An error occurred while getting the rank: ${error}`); 27 | chatMessage(client, sender, messages.RANK.ERROR[language]); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-2021 Lucas Guilherme da Silva 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/RELOAD/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const inventory = require('../../../../Components/inventory'); 3 | const chatMessage = require('../../../../Components/message'); 4 | const log = require('../../../../Components/log'); 5 | const main = require('../../../../Config/main'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, client, users, community, allCards) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const load = ['SETS']; 11 | 12 | Object.keys(main.acceptedCurrencies).forEach((currency) => { 13 | if (main.acceptedCurrencies[currency]) { 14 | if (currency === 'HYDRA') { 15 | load.push(currency); 16 | } else { 17 | load.unshift(currency); 18 | } 19 | } 20 | }); 21 | 22 | chatMessage(client, sender, messages.REQUEST[language]); 23 | log.adminChat(sender.getSteamID64(), language, '[ !RELOAD ]'); 24 | inventory.loadInventory(client, community, allCards, load, () => { 25 | inventory.play(client); 26 | chatMessage(client, sender, messages.RELOAD[language]); 27 | }); 28 | }; 29 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/REPORT/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const main = require('../../../../Config/main'); 3 | const messages = require('../../../../Config/messages'); 4 | const log = require('../../../../Components/log'); 5 | const utils = require('../../../../Utils'); 6 | 7 | module.exports = (sender, msg, client, users) => { 8 | const language = utils.getLanguage(sender.getSteamID64(), users); 9 | 10 | log.userChat(sender.getSteamID64(), language, '[ !REPORT ]'); 11 | const n = msg.substring('!REPORT'.length).trim(); 12 | if (n.length > 0) { 13 | for (let j = 0; j < main.admins.length; j += 1) { 14 | chatMessage( 15 | client, 16 | main.admins[j], 17 | messages.REPORT.RESPONSE[0][utils.getLanguage(main.admins[j], users)] 18 | .replace( 19 | '{USERNAME}', 20 | client.users[sender.getSteamID64()].player_name 21 | ) 22 | .replace('{ID64}', sender.getSteamID64()) 23 | .replace('{MESSAGE}', n) 24 | ); 25 | } 26 | chatMessage(client, sender, messages.REPORT.RESPONSE[1][language]); 27 | } else { 28 | chatMessage(client, sender, messages.REPORT.ERROR[language]); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/UNBLOCK/index.js: -------------------------------------------------------------------------------- 1 | const SID64REGEX = new RegExp(/^[0-9]{17}$/); 2 | 3 | const messages = require('../../../../Config/messages'); 4 | const chatMessage = require('../../../../Components/message'); 5 | const log = require('../../../../Components/log'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, msg, client, users) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const n = msg.toUpperCase().replace('!UNBLOCK ', '').toString(); 11 | 12 | log.adminChat(sender.getSteamID64(), language, `[ !UNBLOCK ${n} ]`); 13 | if (SID64REGEX.test(n)) { 14 | if (n !== sender.getSteamID64()) { 15 | client.unblockUser(n, (err) => { 16 | if (err) { 17 | chatMessage(client, sender, messages.UNBLOCK.ERROR[language]); 18 | log.error(`An error occured while unblocking user: ${err}`); 19 | } else { 20 | chatMessage(client, sender, messages.UNBLOCK.RESPONSE[language]); 21 | } 22 | }); 23 | } else { 24 | chatMessage(client, sender, messages.UNBLOCK.NOTALLOWED[language]); 25 | } 26 | } else { 27 | chatMessage( 28 | client, 29 | sender, 30 | messages.ERROR.INPUT.INVALID.STEAMID64[language] 31 | ); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/BLOCK/index.js: -------------------------------------------------------------------------------- 1 | const SID64REGEX = new RegExp(/^[0-9]{17}$/); 2 | 3 | const messages = require('../../../../Config/messages'); 4 | const chatMessage = require('../../../../Components/message'); 5 | const log = require('../../../../Components/log'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, msg, client, users) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const n = msg.toUpperCase().replace('!BLOCK ', '').toString(); 11 | 12 | log.adminChat(sender.getSteamID64(), language, `[ !BLOCK ${n} ]`); 13 | if (SID64REGEX.test(n)) { 14 | if (n !== sender.getSteamID64()) { 15 | client.blockUser(n, (err) => { 16 | if (err) { 17 | chatMessage(client, sender, messages.BLOCK.ERROR[language]); 18 | log.error(`An error occured while blocking user: ${err}`); 19 | } else { 20 | chatMessage(client, sender, messages.BLOCK.RESPONSE[language]); 21 | } 22 | }); 23 | client.removeFriend(n); 24 | } else { 25 | chatMessage(client, sender, messages.BLOCK.NOTALLOWED[language]); 26 | } 27 | } else { 28 | chatMessage( 29 | client, 30 | sender, 31 | messages.ERROR.INPUT.INVALID.STEAMID64[language] 32 | ); 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/KEYLIST/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const messages = require('../../../../Config/messages'); 3 | const log = require('../../../../Components/log'); 4 | const { removeKeys } = require('../../../../Utils'); 5 | const main = require('../../../../Config/main'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, client, users) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | log.userChat(sender.getSteamID64(), language, '[ !KEYLIST ]'); 11 | let message = ''; 12 | message += messages.KEYLIST.MESSAGES[0][language]; 13 | 14 | if (main.acceptedCurrencies.CSGO || main.acceptedCurrencies.HYDRA) { 15 | message += messages.KEYLIST.MESSAGES[1][language]; 16 | for ( 17 | let i = 0; 18 | i < messages.KEYLIST.ACCEPTED.CSGO[language].length; 19 | i += 1 20 | ) { 21 | message += messages.KEYLIST.ACCEPTED.CSGO[language][i]; 22 | } 23 | } 24 | 25 | message += messages.KEYLIST.MESSAGES[2][language]; 26 | for (let j = 0; j < messages.KEYLIST.ACCEPTED.TF[language].length; j += 1) { 27 | message += messages.KEYLIST.ACCEPTED.TF[language][j]; 28 | } 29 | 30 | message = `/pre ${removeKeys(message).join('\n')}`; 31 | 32 | chatMessage(client, sender, message); 33 | }; 34 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/REQUESTER/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const main = require('../../../../Config/main'); 3 | const inventory = require('../../../../Components/inventory'); 4 | const chatMessage = require('../../../../Components/message'); 5 | const request = require('../../../../Components/request'); 6 | const log = require('../../../../Components/log'); 7 | const utils = require('../../../../Utils'); 8 | 9 | module.exports = (sender, client, users, community, allCards, manager) => { 10 | const language = utils.getLanguage(sender.getSteamID64(), users); 11 | 12 | log.adminChat(sender.getSteamID64(), language, '[ !REQUESTER ]'); 13 | chatMessage(client, sender, messages.REQUESTER[0][language]); 14 | let i = 0; 15 | const ID64 = main.requester.steamID64; 16 | if (ID64[0]) { 17 | (function req() { 18 | if (i < ID64.length) { 19 | request( 20 | ID64[i], 21 | community, 22 | allCards, 23 | manager, 24 | inventory, 25 | (callback) => { 26 | if (callback) { 27 | i += 1; 28 | setTimeout(req, 10000); 29 | } 30 | } 31 | ); 32 | } 33 | })(); 34 | } else { 35 | chatMessage(client, sender, messages.REQUESTER[1][language]); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/INVITE/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const main = require('../../../../Config/main'); 3 | const messages = require('../../../../Config/messages'); 4 | const utils = require('../../../../Utils'); 5 | const log = require('../../../../Components/log'); 6 | 7 | module.exports = (sender, client, users, community) => { 8 | const language = utils.getLanguage(sender.getSteamID64(), users); 9 | chatMessage(client, sender, messages.REQUEST[language]); 10 | log.userChat(sender.getSteamID64(), language, '[ !INVITE ]'); 11 | utils.checkUserinGroup(community, sender.getSteamID64(), (err, isMember) => { 12 | if (!err) { 13 | if (!isMember) { 14 | client.inviteToGroup(sender.getSteamID64(), main.steamGroup.ID); 15 | chatMessage( 16 | client, 17 | sender.getSteamID64(), 18 | messages.INVITETOGROUP.INVITED[language] 19 | ); 20 | } else { 21 | chatMessage( 22 | client, 23 | sender.getSteamID64(), 24 | messages.INVITETOGROUP.ITSALREADY[language] 25 | ); 26 | } 27 | } else { 28 | chatMessage( 29 | client, 30 | sender.getSteamID64(), 31 | messages.INVITETOGROUP.ERROR[language] 32 | ); 33 | log.error(`An error occurred inviting user to steam group: ${err}`); 34 | } 35 | }); 36 | }; 37 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "steam-levelup-bot", 3 | "version": "1.14.11", 4 | "description": "A steam Cardsets/LevelUp BOT", 5 | "author": "Lucas Guilherme", 6 | "homepage": "https://github.com/Luc4sguilherme/Steam-levelup-BOT", 7 | "bugs": { 8 | "url": "https://github.com/Luc4sguilherme/Steam-levelup-BOT/issues" 9 | }, 10 | "license": "MIT", 11 | "main": "./src/index.js", 12 | "scripts": { 13 | "lint": "eslint --fix ./src/**/*.js", 14 | "start": "node --max-old-space-size=4096 src/index.js", 15 | "update": "npx -p npm-check-updates ncu -u && npm i" 16 | }, 17 | "engines": { 18 | "node": ">=14.15.0" 19 | }, 20 | "dependencies": { 21 | "async": "^3.2.0", 22 | "axios": "^0.21.1", 23 | "cli-color": "^2.0.0", 24 | "graceful-fs": "^4.2.6", 25 | "joi": "^17.4.0", 26 | "lodash": "^4.17.21", 27 | "moment": "^2.29.1", 28 | "steam-totp": "^2.1.1", 29 | "steam-tradeoffer-manager": "^2.10.3", 30 | "steam-user": "^4.19.6", 31 | "steamcommunity": "^3.42.0", 32 | "tree-kill": "^1.2.2" 33 | }, 34 | "devDependencies": { 35 | "eslint": "^7.26.0", 36 | "eslint-config-airbnb": "^18.2.1", 37 | "eslint-config-airbnb-base": "^14.2.1", 38 | "eslint-config-node": "^4.1.0", 39 | "eslint-config-prettier": "^8.3.0", 40 | "eslint-plugin-import": "^2.22.1", 41 | "eslint-plugin-node": "^11.1.0", 42 | "eslint-plugin-prettier": "^3.4.0", 43 | "prettier": "^2.3.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor? 2 | 3 | ## Contributor License Agreement 4 | 5 | By making a contribution to this project, I certify that: 6 | 7 | * (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license under which is this project; or 8 | 9 | * (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or 10 | 11 | * (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. 12 | 13 | * (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. 14 | 15 | ## How to submit your contributions? 16 | 17 | 1. Submit an issue describing your proposed change to the repo in question. 18 | 1. The repo owner will respond to your issue promptly. 19 | 1. Fork the desired repo, develop and test your code changes. 20 | 1. Submit a pull request writing an detail report with all information about the changes you made. 21 | -------------------------------------------------------------------------------- /src/Commands/User/GENERAL/STOCK/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const log = require('../../../../Components/log'); 3 | const inventory = require('../../../../Components/inventory'); 4 | const chatMessage = require('../../../../Components/message'); 5 | const { filterCommands } = require('../../../../Utils'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, client, users) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | 11 | log.userChat(sender.getSteamID64(), language, '[ !STOCK ]'); 12 | chatMessage(client, sender, messages.REQUEST[language]); 13 | 14 | chatMessage( 15 | client, 16 | sender, 17 | filterCommands(messages.STOCK[language]) 18 | .join('\n') 19 | .replace('{TOTALBOTSETS}', inventory.stock.totalBotSets) 20 | .replace('{CSKEYSTRADABLE}', inventory.stock.csKeys.tradable) 21 | .replace('{HYDRAKEYSTRADABLE}', inventory.stock.hydraKeys.tradable) 22 | .replace('{TFKEYSTRADABLE}', inventory.stock.tfKeys.tradable) 23 | .replace('{GEMSQUANTITYTRADABLE}', inventory.stock.gemsQuantity.tradable) 24 | .replace('{CSKEYSNOTRADABLE}', inventory.stock.csKeys.notradable) 25 | .replace('{HYDRAKEYSNOTRADABLE}', inventory.stock.hydraKeys.notradable) 26 | .replace('{TFKEYSNOTRADABLE}', inventory.stock.tfKeys.notradable) 27 | .replace( 28 | '{GEMSQUANTITYNOTRADABLE}', 29 | inventory.stock.gemsQuantity.notradable 30 | ) 31 | ); 32 | }; 33 | -------------------------------------------------------------------------------- /src/Components/login.js: -------------------------------------------------------------------------------- 1 | const SteamUser = require('steam-user'); 2 | const SteamTotp = require('steam-totp'); 3 | const main = require('../Config/main'); 4 | const log = require('./log'); 5 | 6 | const init = (client) => { 7 | try { 8 | client.logOn({ 9 | accountName: main.userName, 10 | password: main.passWord, 11 | twoFactorCode: SteamTotp.getAuthCode(main.sharedSecret), 12 | identity_secret: main.identitySecret, 13 | rememberPassword: true, 14 | shared_secret: main.sharedSecret, 15 | }); 16 | } catch (e) { 17 | log.error(e); 18 | } 19 | }; 20 | 21 | const restart = (client) => { 22 | log.warn('Restarting...'); 23 | if (!client.steamID) { 24 | init(client); 25 | } else { 26 | client.relog(); 27 | } 28 | }; 29 | 30 | function webLogin(client) { 31 | log.warn('Session Expired. Relogging.'); 32 | 33 | try { 34 | client.webLogOn(); 35 | } catch (e) { 36 | log.error(e); 37 | } 38 | } 39 | 40 | const check = (client, community) => { 41 | setInterval(() => { 42 | community.loggedIn((err, loggedIn) => { 43 | if (err) { 44 | log.error(err); 45 | if ( 46 | err.message.indexOf('socket hang up') > -1 || 47 | err.message.indexOf('ESOCKETTIMEDOUT') > -1 48 | ) { 49 | webLogin(client); 50 | } else { 51 | restart(client); 52 | } 53 | } else if (!loggedIn) { 54 | restart(client); 55 | } else { 56 | client.setPersona(SteamUser.EPersonaState.LookingToTrade); 57 | } 58 | }); 59 | }, 1000 * 60 * 15); 60 | }; 61 | 62 | module.exports = { 63 | init, 64 | check, 65 | restart, 66 | webLogin, 67 | }; 68 | -------------------------------------------------------------------------------- /src/Components/reputation.js: -------------------------------------------------------------------------------- 1 | const utils = require('../Utils'); 2 | 3 | async function reputation(id64) { 4 | try { 5 | const rep = await utils.getRep(id64); 6 | 7 | const infos = { 8 | summary: '', 9 | tags: '', 10 | vacban: '', 11 | tradeban: '', 12 | }; 13 | 14 | switch (rep.steamrep.reputation.summary) { 15 | case 'SCAMMER': 16 | infos.summary = 'SCAMMER'; 17 | break; 18 | case 'Caution': 19 | infos.summary = 'CAUTION'; 20 | break; 21 | case 'Admin': 22 | infos.summary = 'ADMIN'; 23 | break; 24 | case 'Middleman': 25 | infos.summary = 'MIDDLEMAN'; 26 | break; 27 | case 'Trusted Seller': 28 | infos.summary = 'TRUSTEDSELLER'; 29 | break; 30 | case 'none': 31 | infos.summary = 'NONE'; 32 | break; 33 | default: 34 | infos.summary = 'UNKNOWN'; 35 | } 36 | if (rep.steamrep.reputation.tags) { 37 | switch (rep.steamrep.reputation.tags.tag.category) { 38 | case 'evil': 39 | infos.tags = 'EVIL'; 40 | break; 41 | case 'trusted': 42 | infos.tags = 'TRUSTED'; 43 | break; 44 | case 'misc': 45 | infos.tags = 'MISC'; 46 | break; 47 | default: 48 | infos.tags = 'UNKNOWN'; 49 | } 50 | } 51 | if (rep.steamrep.vacban === 1) { 52 | infos.vacban = 'VACBAN'; 53 | } 54 | if (rep.steamrep.tradeban === 2) { 55 | infos.tradeban = 'TRADEBAN'; 56 | } 57 | 58 | return infos; 59 | } catch (error) { 60 | throw new Error(error); 61 | } 62 | } 63 | 64 | module.exports = reputation; 65 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/MYSTATS/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const chatMessage = require('../../../../Components/message'); 3 | const log = require('../../../../Components/log'); 4 | const customer = require('../../../../Components/customer'); 5 | const utils = require('../../../../Utils'); 6 | 7 | module.exports = (sender, client, users, community, allCards) => { 8 | const language = utils.getLanguage(sender.getSteamID64(), users); 9 | 10 | chatMessage(client, sender, messages.REQUEST[language]); 11 | 12 | log.adminChat(sender.getSteamID64(), language, `[ !MYSTATS ]`); 13 | 14 | customer.loadInventory(sender.getSteamID64(), community, allCards, (err) => { 15 | if (err) { 16 | chatMessage( 17 | client, 18 | sender, 19 | messages.ERROR.LOADINVENTORY.THEM[0][language] 20 | ); 21 | } else { 22 | const message = `/pre ${messages.ADMINCHECK.INVENTORY[language] 23 | .replace('{TOTALSETS}', customer.stock.totalSets) 24 | .replace('{CSKEYSTRADABLE}', customer.stock.csKeys.tradable) 25 | .replace('{HYDRAKEYSTRADABLE}', customer.stock.hydraKeys.tradable) 26 | .replace('{TFKEYSTRADABLE}', customer.stock.tfKeys.tradable) 27 | .replace('{GEMSQUANTITYTRADABLE}', customer.stock.gemsQuantity.tradable) 28 | .replace('{CSKEYSNOTRADABLE}', customer.stock.csKeys.notradable) 29 | .replace('{HYDRAKEYSNOTRADABLE}', customer.stock.hydraKeys.notradable) 30 | .replace('{TFKEYSNOTRADABLE}', customer.stock.tfKeys.notradable) 31 | .replace( 32 | '{GEMSQUANTITYNOTRADABLE}', 33 | customer.stock.gemsQuantity.notradable 34 | )}`; 35 | 36 | chatMessage(client, sender, message); 37 | } 38 | }); 39 | }; 40 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/UNPACK/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const chatMessage = require('../../../../Components/message'); 3 | const log = require('../../../../Components/log'); 4 | const utils = require('../../../../Utils'); 5 | 6 | module.exports = (sender, client, users, community, manager) => { 7 | const language = utils.getLanguage(sender.getSteamID64(), users); 8 | 9 | log.adminChat(sender.getSteamID64(), language, '[ !UNPACK ]'); 10 | manager.getInventoryContents(753, 6, true, (ERR1, INV) => { 11 | if (!ERR1) { 12 | const botBooster = []; 13 | let itemid; 14 | let appid; 15 | for (let i = 0; i < INV.length; i += 1) { 16 | if (INV[i].type === 'Booster Pack') { 17 | botBooster.push(INV[i]); 18 | appid = INV[i].market_fee_app; 19 | itemid = INV[i].id; 20 | community.openBoosterPack(appid, itemid, (ERR2) => { 21 | if (ERR2) { 22 | log.error( 23 | `An error occurred while getting unpack Booster: ${ERR2}` 24 | ); 25 | } 26 | }); 27 | } 28 | } 29 | if (botBooster.length > 0) { 30 | chatMessage( 31 | client, 32 | sender, 33 | messages.UNPACK.RESPONSE[language].replace( 34 | '{BOOSTER}', 35 | botBooster.length 36 | ) 37 | ); 38 | } else { 39 | chatMessage(client, sender, messages.UNPACK.ERROR[language]); 40 | } 41 | } else { 42 | chatMessage(client, sender, messages.ERROR.LOADINVENTORY.US[language]); 43 | log.error( 44 | sender.getSteamID64(), 45 | `[ !UNPACK ] An error occurred while getting inventory: ${ERR1}` 46 | ); 47 | } 48 | }); 49 | }; 50 | -------------------------------------------------------------------------------- /src/Components/rank.js: -------------------------------------------------------------------------------- 1 | const moment = require('moment'); 2 | const axios = require('axios'); 3 | 4 | const main = require('../Config/main.js'); 5 | 6 | const apiKey = main.steamLadderApiKey; 7 | 8 | const get = async (SID) => { 9 | try { 10 | const options = { 11 | method: 'GET', 12 | baseURL: 'https://steamladder.com/api/v1/', 13 | url: `profile/${SID}`, 14 | headers: { 15 | Authorization: `Token ${apiKey}`, 16 | }, 17 | }; 18 | 19 | const { data } = await axios(options); 20 | return { 21 | WORLDWIDEXP: data.ladder_rank.worldwide_xp, 22 | REGIONXP: data.ladder_rank.region.region_xp, 23 | COUNTRYXP: data.ladder_rank.country.country_xp, 24 | LASTUPDATE: data.steam_stats.last_update, 25 | }; 26 | } catch (error) { 27 | throw new Error(error); 28 | } 29 | }; 30 | 31 | const update = async (SID) => { 32 | try { 33 | const options = { 34 | method: 'POST', 35 | baseURL: 'https://steamladder.com/api/v1/', 36 | url: `profile/${SID}/`, 37 | headers: { 38 | Authorization: `Token ${apiKey}`, 39 | }, 40 | }; 41 | 42 | const { data } = await axios(options); 43 | return { 44 | WORLDWIDEXP: data.ladder_rank.worldwide_xp, 45 | REGIONXP: data.ladder_rank.region.region_xp, 46 | COUNTRYXP: data.ladder_rank.country.country_xp, 47 | }; 48 | } catch (error) { 49 | throw new Error(error); 50 | } 51 | }; 52 | 53 | const rank = (SID) => 54 | new Promise((resolve, reject) => { 55 | get(SID) 56 | .then((data) => { 57 | if (moment().isAfter(moment(`${data.LASTUPDATE}Z`).add(4, 'hours'))) { 58 | resolve(update(SID)); 59 | } else { 60 | resolve(data); 61 | } 62 | }) 63 | .catch(reject); 64 | }); 65 | 66 | module.exports = { 67 | rank, 68 | }; 69 | -------------------------------------------------------------------------------- /src/Components/offer.js: -------------------------------------------------------------------------------- 1 | const messages = require('../Config/messages'); 2 | const utils = require('../Utils'); 3 | const log = require('./log'); 4 | const chatMessage = require('./message'); 5 | 6 | const makeOffer = ( 7 | client, 8 | users, 9 | manager, 10 | target, 11 | itemsFromMe, 12 | itemsFromThem, 13 | commandused, 14 | message, 15 | amountofsets = 0, 16 | amountofleftovers = 0, 17 | amountofkeys = 0, 18 | amountofgems = 0 19 | ) => { 20 | const offer = manager.createOffer(target); 21 | const language = utils.getLanguage(target, users); 22 | 23 | offer.addMyItems(itemsFromMe); 24 | offer.addTheirItems(itemsFromThem); 25 | 26 | log.tradeoffer('Creating trade offer'); 27 | 28 | offer.data('commandused', commandused); 29 | if (amountofsets) { 30 | offer.data('amountofsets', amountofsets); 31 | } 32 | if (amountofleftovers) { 33 | offer.data('amountofleftovers', amountofleftovers); 34 | } 35 | if (amountofkeys) { 36 | offer.data('amountofkeys', amountofkeys); 37 | } 38 | if (amountofgems) { 39 | offer.data('amountofgems', amountofgems); 40 | } 41 | 42 | offer.setMessage(message); 43 | offer.getUserDetails((ERR1, ME, THEM) => { 44 | if (ERR1) { 45 | log.error(`An error occurred while getting trade holds: ${ERR1}`); 46 | chatMessage(client, target, messages.ERROR.TRADEHOLD[language]); 47 | } else if (ME.escrowDays === 0 && THEM.escrowDays === 0) { 48 | log.tradeoffer('Sending trade offer'); 49 | offer.send((ERR2) => { 50 | if (ERR2) { 51 | chatMessage(client, target, messages.ERROR.SENDTRADE[language]); 52 | log.error(`An error occurred while sending trade offer: ${ERR2}`); 53 | } else { 54 | chatMessage(client, target, `${messages.TRADEMSG[language]} \n\n`); 55 | log.tradeoffer( 56 | `offer #${offer.id} sent successfully to user #${target}` 57 | ); 58 | } 59 | }); 60 | } else { 61 | chatMessage(client, target, messages.TRADEHOLD[language]); 62 | } 63 | }); 64 | }; 65 | 66 | module.exports = makeOffer; 67 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/CANCEL/index.js: -------------------------------------------------------------------------------- 1 | const log = require('../../../../Components/log'); 2 | const chatMessage = require('../../../../Components/message'); 3 | const messages = require('../../../../Config/messages'); 4 | const utils = require('../../../../Utils'); 5 | 6 | module.exports = (sender, msg, client, users, manager) => { 7 | const language = utils.getLanguage(sender.getSteamID64(), users); 8 | const offerID = msg.substring('!CANCEL'.length).trim(); 9 | 10 | if (offerID) { 11 | chatMessage(client, sender, messages.REQUEST[language]); 12 | log.adminChat(sender.getSteamID64(), language, `[ !CANCEL ${offerID} ]`); 13 | 14 | manager.getOffer(offerID, (error1, offer) => { 15 | if (error1) { 16 | chatMessage(client, sender, messages.ERROR.GETOFFER[language]); 17 | log.error(`There was an error getting offers: ${error1}`); 18 | } else { 19 | offer.decline((error2) => { 20 | if (error2) { 21 | if ( 22 | error2.message.indexOf( 23 | `Offer #${offerID} is not active, so it may not be cancelled or declined` 24 | ) > -1 25 | ) { 26 | chatMessage( 27 | client, 28 | sender, 29 | messages.ERROR.NONEXISTENTOFFER[language].replace( 30 | '{OFFERID}', 31 | offerID 32 | ) 33 | ); 34 | } else { 35 | chatMessage(client, sender, messages.ERROR.CANCELOFFER[language]); 36 | } 37 | 38 | log.error(`An error occurred while declining trade: ${error2}`); 39 | } else { 40 | chatMessage( 41 | client, 42 | sender, 43 | messages.TRADE.CANCELED[language].replace('{OFFERID}', offer.id) 44 | ); 45 | } 46 | }); 47 | } 48 | }); 49 | } else { 50 | chatMessage( 51 | client, 52 | sender, 53 | messages.ERROR.INPUT.INVALID.OFFERID[language].replace( 54 | '{command}', 55 | '!CANCEL offerID' 56 | ) 57 | ); 58 | } 59 | }; 60 | -------------------------------------------------------------------------------- /src/Commands/Admin/BOOSTER/WITHDRAW/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const makeOffer = require('../../../../Components/offer'); 3 | const messages = require('../../../../Config/messages'); 4 | const log = require('../../../../Components/log'); 5 | const utils = require('../../../../Utils'); 6 | 7 | module.exports = (sender, msg, client, users, manager) => { 8 | const language = utils.getLanguage(sender.getSteamID64(), users); 9 | const amountbooster = parseInt( 10 | msg.toUpperCase().replace('!WITHDRAWBOOSTER ', ''), 11 | 10 12 | ); 13 | if (!Number.isNaN(amountbooster) && parseInt(amountbooster, 10) > 0) { 14 | log.adminChat( 15 | sender.getSteamID64(), 16 | language, 17 | `[ !WITHDRAWBOOSTER ${amountbooster} ]` 18 | ); 19 | chatMessage(client, sender, messages.REQUEST[language]); 20 | manager.getInventoryContents(753, 6, true, (ERR, INV) => { 21 | if (ERR) { 22 | chatMessage(client, sender, messages.ERROR.LOADINVENTORY.US[language]); 23 | log.error(`An error occurred while getting inventory: ${ERR}`); 24 | } else { 25 | const botBooster = []; 26 | for (let i = 0; i < INV.length; i += 1) { 27 | if ( 28 | botBooster.length < amountbooster && 29 | INV[i].type === 'Booster Pack' 30 | ) { 31 | botBooster.push(INV[i]); 32 | } 33 | } 34 | if (botBooster.length < amountbooster) { 35 | chatMessage( 36 | client, 37 | sender, 38 | messages.ERROR.OUTOFSTOCK.DEFAULT.BOOSTER.US[language].replace( 39 | '{BOOSTER}', 40 | botBooster.length 41 | ) 42 | ); 43 | } else { 44 | const message = messages.TRADE.SETMESSAGE[0].BOOSTER[ 45 | language 46 | ].replace('{BOOSTER}', amountbooster.toString()); 47 | makeOffer( 48 | client, 49 | users, 50 | manager, 51 | sender.getSteamID64(), 52 | botBooster, 53 | [], 54 | '!WITHDRAWBOOSTER', 55 | message, 56 | 0, 57 | 0, 58 | 0, 59 | 0 60 | ); 61 | } 62 | } 63 | }); 64 | } else { 65 | chatMessage( 66 | client, 67 | sender, 68 | messages.ERROR.INPUT.INVALID.BOOSTER[language].replace( 69 | '{command}', 70 | '!WITHDRAWBOOSTER 1' 71 | ) 72 | ); 73 | } 74 | }; 75 | -------------------------------------------------------------------------------- /src/Components/sets.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable guard-for-in */ 2 | /* eslint-disable no-restricted-syntax */ 3 | const _ = require('lodash'); 4 | const fs = require('graceful-fs'); 5 | 6 | const log = require('./log'); 7 | const main = require('../Config/main'); 8 | const steamSupply = require('./steamSupply'); 9 | 10 | const maxSets = (cardsFromSortedInventory) => { 11 | let cardCounts = _.mapValues( 12 | cardsFromSortedInventory, 13 | (cardsArray) => cardsArray.length 14 | ); 15 | cardCounts = Object.keys(cardCounts).map((key) => cardCounts[key]); 16 | return Math.min(...cardCounts); 17 | }; 18 | 19 | const updateCardsDB = () => { 20 | steamSupply 21 | .getCardDB() 22 | .then((data) => { 23 | fs.writeFileSync('./Data/Sets/set_data.json', data); 24 | }) 25 | .catch((error) => { 26 | log.error(`An error occurred while updating cardsDB: ${error}`); 27 | }); 28 | }; 29 | 30 | const parseCardsData = (data) => { 31 | const db = JSON.parse(data); 32 | const sets = {}; 33 | 34 | for (const appId in db) { 35 | sets[appId] = { 36 | appid: appId, 37 | count: db[appId], 38 | }; 39 | } 40 | 41 | return sets; 42 | }; 43 | 44 | const getCardsInSets = (callback) => { 45 | const dir = './Data/Sets/set_data.json'; 46 | if (main.steamSupply.updateCardDB && !fs.existsSync(dir)) { 47 | steamSupply 48 | .getCardDB() 49 | .then((data) => { 50 | const sets = parseCardsData(data); 51 | 52 | fs.writeFileSync(dir, data); 53 | 54 | callback(null, sets); 55 | }) 56 | .catch((error) => { 57 | callback(error); 58 | }); 59 | } else { 60 | fs.readFile(dir, 'utf8', (err, data) => { 61 | if (err) { 62 | callback(err); 63 | } else { 64 | const sets = parseCardsData(data); 65 | callback(null, sets); 66 | } 67 | }); 68 | } 69 | }; 70 | 71 | const getSets = (INV, DATA, callback) => { 72 | const s = {}; 73 | _.forOwn(INV, (c, id) => { 74 | const uc = Object.keys(c).length; 75 | if (DATA[id.toString()] && uc === DATA[id.toString()].count) { 76 | const r = maxSets(c); 77 | s[id.toString()] = []; 78 | for (let i = 0; i < r; i += 1) { 79 | const set = []; 80 | _.forOwn(c, (e) => { 81 | set.push(e[i]); 82 | }); 83 | s[id.toString()].push(set); 84 | } 85 | } else if (!DATA[id.toString()]) { 86 | log.warn(`Card set non-existent, skipping it ${id.toString()} `); 87 | } 88 | }); 89 | callback(null, s); 90 | }; 91 | 92 | module.exports = { 93 | getCardsInSets, 94 | getSets, 95 | updateCardsDB, 96 | }; 97 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # ******** NOTE ******** 12 | 13 | name: "CodeQL" 14 | 15 | on: 16 | push: 17 | branches: [ master ] 18 | pull_request: 19 | # The branches below must be a subset of the branches above 20 | branches: [ master ] 21 | schedule: 22 | - cron: '32 12 * * 5' 23 | 24 | jobs: 25 | analyze: 26 | name: Analyze 27 | runs-on: ubuntu-latest 28 | 29 | strategy: 30 | fail-fast: false 31 | matrix: 32 | language: [ 'javascript' ] 33 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 34 | # Learn more... 35 | # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection 36 | 37 | steps: 38 | - name: Checkout repository 39 | uses: actions/checkout@v2 40 | 41 | # Initializes the CodeQL tools for scanning. 42 | - name: Initialize CodeQL 43 | uses: github/codeql-action/init@v1 44 | with: 45 | languages: ${{ matrix.language }} 46 | # If you wish to specify custom queries, you can do so here or in a config file. 47 | # By default, queries listed here will override any specified in a config file. 48 | # Prefix the list here with "+" to use these queries and those in the config file. 49 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 50 | 51 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 52 | # If this step fails, then you should remove it and run the build manually (see below) 53 | - name: Autobuild 54 | uses: github/codeql-action/autobuild@v1 55 | 56 | # ℹ️ Command-line programs to run using the OS shell. 57 | # 📚 https://git.io/JvXDl 58 | 59 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 60 | # and modify them (or add more) to build your code if your project 61 | # uses a compiled language 62 | 63 | #- run: | 64 | # make bootstrap 65 | # make release 66 | 67 | - name: Perform CodeQL Analysis 68 | uses: github/codeql-action/analyze@v1 69 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | Data/ChatLogs/**/*.txt 10 | Data/History/**/*.txt 11 | Data/History/**/*.json 12 | Data/AcceptedTrades/*.txt 13 | Data/User/*.json 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | package-lock.json 50 | 51 | # Snowpack dependency directory (https://snowpack.dev/) 52 | web_modules/ 53 | 54 | # TypeScript cache 55 | *.tsbuildinfo 56 | 57 | # Optional npm cache directory 58 | .npm 59 | 60 | # Optional eslint cache 61 | .eslintcache 62 | 63 | # Microbundle cache 64 | .rpt2_cache/ 65 | .rts2_cache_cjs/ 66 | .rts2_cache_es/ 67 | .rts2_cache_umd/ 68 | 69 | # Optional REPL history 70 | .node_repl_history 71 | 72 | # Output of 'npm pack' 73 | *.tgz 74 | 75 | # Yarn Integrity file 76 | .yarn-integrity 77 | 78 | # dotenv environment variables file 79 | .env 80 | .env.test 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # Serverless directories 104 | .serverless/ 105 | 106 | # FuseBox cache 107 | .fusebox/ 108 | 109 | # DynamoDB Local files 110 | .dynamodb/ 111 | 112 | # TernJS port file 113 | .tern-port 114 | 115 | # Stores VSCode versions used for testing VSCode extensions 116 | .vscode-test 117 | 118 | # yarn v2 119 | .yarn/cache 120 | .yarn/unplugged 121 | .yarn/build-state.yml 122 | .yarn/install-state.gz 123 | .pnp.* 124 | 125 | # Configs 126 | src/Config/main.js -------------------------------------------------------------------------------- /src/Commands/Admin/TF/WITHDRAW/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const acceptedCurrencies = require('../../../../Config/currencies'); 3 | const chatMessage = require('../../../../Components/message'); 4 | const makeOffer = require('../../../../Components/offer'); 5 | const log = require('../../../../Components/log'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, msg, client, users, manager) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const amountkeys = parseInt( 11 | msg.toUpperCase().replace('!WITHDRAWTF ', ''), 12 | 10 13 | ); 14 | 15 | if (!Number.isNaN(amountkeys) && parseInt(amountkeys, 10) > 0) { 16 | log.adminChat( 17 | sender.getSteamID64(), 18 | language, 19 | `[ !WITHDRAWTF ${amountkeys} ]` 20 | ); 21 | chatMessage(client, sender, messages.REQUEST[language]); 22 | manager.getInventoryContents(440, 2, true, (ERR, INV) => { 23 | if (ERR) { 24 | chatMessage(client, sender, messages.ERROR.LOADINVENTORY.US[language]); 25 | log.error(`An error occurred while getting inventory: ${ERR}`); 26 | } else { 27 | let botkeys = 0; 28 | let added = 0; 29 | const myKeys = []; 30 | for (let i = 0; i < INV.length; i += 1) { 31 | if (acceptedCurrencies.tf.indexOf(INV[i].market_hash_name) >= 0) { 32 | botkeys += 1; 33 | if (added < amountkeys) { 34 | myKeys.push(INV[i]); 35 | added += 1; 36 | } 37 | } 38 | } 39 | if (botkeys < amountkeys) { 40 | chatMessage( 41 | client, 42 | sender, 43 | messages.ERROR.OUTOFSTOCK.DEFAULT.TF.US[1][language].replace( 44 | '{TF}', 45 | botkeys 46 | ) 47 | ); 48 | } else { 49 | const message = messages.TRADE.SETMESSAGE[0].TF[language].replace( 50 | '{TF}', 51 | amountkeys 52 | ); 53 | makeOffer( 54 | client, 55 | users, 56 | manager, 57 | sender.getSteamID64(), 58 | myKeys, 59 | [], 60 | '!WITHDRAWTF', 61 | message, 62 | 0, 63 | 0, 64 | amountkeys, 65 | 0 66 | ); 67 | } 68 | } 69 | }); 70 | } else { 71 | chatMessage( 72 | client, 73 | sender, 74 | messages.ERROR.INPUT.INVALID.TF[language].replace( 75 | '{command}', 76 | '!WITHDRAWTF 1' 77 | ) 78 | ); 79 | } 80 | }; 81 | -------------------------------------------------------------------------------- /src/Commands/Admin/CSGO/WITHDRAW/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const acceptedCurrencies = require('../../../../Config/currencies'); 3 | const chatMessage = require('../../../../Components/message'); 4 | const makeOffer = require('../../../../Components/offer'); 5 | const log = require('../../../../Components/log'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, msg, client, users, manager) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const amountkeys = parseInt( 11 | msg.toUpperCase().replace('!WITHDRAWCSGO ', ''), 12 | 10 13 | ); 14 | if (!Number.isNaN(amountkeys) && parseInt(amountkeys, 10) > 0) { 15 | log.adminChat( 16 | sender.getSteamID64(), 17 | language, 18 | `[ !WITHDRAWCSGO ${amountkeys} ]` 19 | ); 20 | chatMessage(client, sender, messages.REQUEST[language]); 21 | manager.getInventoryContents(730, 2, true, (ERR, INV) => { 22 | if (ERR) { 23 | chatMessage(client, sender, messages.ERROR.LOADINVENTORY.US[language]); 24 | log.error(`An error occurred while getting inventory: ${ERR}`); 25 | } else { 26 | let botkeys = 0; 27 | let added = 0; 28 | const myKeys = []; 29 | for (let i = 0; i < INV.length; i += 1) { 30 | if (acceptedCurrencies.csgo.indexOf(INV[i].market_hash_name) >= 0) { 31 | botkeys += 1; 32 | if (added < amountkeys) { 33 | myKeys.push(INV[i]); 34 | added += 1; 35 | } 36 | } 37 | } 38 | if (botkeys < amountkeys) { 39 | chatMessage( 40 | client, 41 | sender, 42 | messages.ERROR.OUTOFSTOCK.DEFAULT.CSGO.US[1][language].replace( 43 | '{CSGO}', 44 | botkeys 45 | ) 46 | ); 47 | } else { 48 | const message = messages.TRADE.SETMESSAGE[0].CSGO[language].replace( 49 | '{CSGO}', 50 | amountkeys 51 | ); 52 | makeOffer( 53 | client, 54 | users, 55 | manager, 56 | sender.getSteamID64(), 57 | myKeys, 58 | [], 59 | '!WITHDRAWCSGO', 60 | message, 61 | 0, 62 | 0, 63 | amountkeys, 64 | 0 65 | ); 66 | } 67 | } 68 | }); 69 | } else { 70 | chatMessage( 71 | client, 72 | sender, 73 | messages.ERROR.INPUT.INVALID.CSGO[language].replace( 74 | '{command}', 75 | '!WITHDRAWCSGO 1' 76 | ) 77 | ); 78 | } 79 | }; 80 | -------------------------------------------------------------------------------- /src/Commands/Admin/HYDRA/WITHDRAW/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const acceptedCurrencies = require('../../../../Config/currencies'); 3 | const chatMessage = require('../../../../Components/message'); 4 | const makeOffer = require('../../../../Components/offer'); 5 | const log = require('../../../../Components/log'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, msg, client, users, manager) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const amountkeys = parseInt( 11 | msg.toUpperCase().replace('!WITHDRAWHYDRA ', ''), 12 | 10 13 | ); 14 | 15 | if (!Number.isNaN(amountkeys) && parseInt(amountkeys, 10) > 0) { 16 | log.adminChat( 17 | sender.getSteamID64(), 18 | language, 19 | `[ !WITHDRAWHYDRA ${amountkeys} ]` 20 | ); 21 | chatMessage(client, sender, messages.REQUEST[language]); 22 | manager.getInventoryContents(730, 2, true, (ERR, INV) => { 23 | if (ERR) { 24 | chatMessage(client, sender, messages.ERROR.LOADINVENTORY.US[language]); 25 | log.error(`An error occurred while getting inventory: ${ERR}`); 26 | } else { 27 | let botkeys = 0; 28 | let added = 0; 29 | const myKeys = []; 30 | for (let i = 0; i < INV.length; i += 1) { 31 | if (acceptedCurrencies.hydra.indexOf(INV[i].market_hash_name) >= 0) { 32 | botkeys += 1; 33 | if (added < amountkeys) { 34 | myKeys.push(INV[i]); 35 | added += 1; 36 | } 37 | } 38 | } 39 | if (botkeys < amountkeys) { 40 | chatMessage( 41 | client, 42 | sender, 43 | messages.ERROR.OUTOFSTOCK.DEFAULT.HYDRA.US[1][language].replace( 44 | '{HYDRA}', 45 | botkeys 46 | ) 47 | ); 48 | } else { 49 | const message = messages.TRADE.SETMESSAGE[0].HYDRA[language].replace( 50 | '{HYDRA}', 51 | amountkeys 52 | ); 53 | makeOffer( 54 | client, 55 | users, 56 | manager, 57 | sender.getSteamID64(), 58 | myKeys, 59 | [], 60 | '!WITHDRAWHYDRA', 61 | message, 62 | 0, 63 | 0, 64 | amountkeys, 65 | 0 66 | ); 67 | } 68 | } 69 | }); 70 | } else { 71 | chatMessage( 72 | client, 73 | sender, 74 | messages.ERROR.INPUT.INVALID.HYDRA[language].replace( 75 | '{command}', 76 | '!WITHDRAWHYDRA 1' 77 | ) 78 | ); 79 | } 80 | }; 81 | -------------------------------------------------------------------------------- /src/Components/ErrorHandle/constants/commands.js: -------------------------------------------------------------------------------- 1 | const commands = [ 2 | '!COMMANDS', 3 | '!COMMAND', 4 | '!HELP', 5 | '!AJUDA', 6 | '!ПОМОЩЬ', 7 | '!AYUDA', 8 | '!救命', 9 | '!AIDER', 10 | '!助けて', 11 | '!HILFE', 12 | '!LANG', 13 | '!LANGUAGE', 14 | '!SPRACHE', 15 | '!IDIOMA', 16 | '!LANGUE', 17 | '!言語', 18 | '!ЯЗЫК', 19 | '!EN', 20 | '!ENGLISH', 21 | '!ENGLISCHE', 22 | '!INGLÊS', 23 | '!英语', 24 | '!英語', 25 | '!АНГЛИЙСКИЙ', 26 | '!ES', 27 | '!SPANISH', 28 | '!SPANISCHE', 29 | '!ESPANHOL', 30 | '!西班牙语', 31 | '!スペイン語', 32 | '!ИСПАНСКИЙ', 33 | '!PT', 34 | '!PORTUGUESE', 35 | '!PORTUGIESISCHE', 36 | '!PORTUGUÊS', 37 | '!葡萄牙语语言', 38 | '!ポルトガル語', 39 | '!ПОРТУГАЛЬСКИЙ', 40 | '!CN', 41 | '!CHINESE', 42 | '!CHINESISCHE', 43 | '!CHINÊS', 44 | '!CHINO', 45 | '!中文', 46 | '!中国語', 47 | '!КИТАЙСКИЙ', 48 | '!RU', 49 | '!RUSSIAN', 50 | '!RUSSISCHE', 51 | '!RUSSO', 52 | '!RUSO', 53 | '!俄语', 54 | '!ロシア語', 55 | '!РУССКИЙ', 56 | '!FR', 57 | '!FRANCE', 58 | '!FRANKREICH', 59 | '!FRANCÊS', 60 | '!FRANCIA', 61 | '!語言法國', 62 | '!言語フランス', 63 | '!ФРАНЦИЯ', 64 | '!JA', 65 | '!JAPANESE', 66 | '!JAPANISCH', 67 | '!JAPONÊS', 68 | '!語言日語', 69 | '!日本語日本語', 70 | '!ЯПОНСКИЙ', 71 | '!DE', 72 | '!GERMAN', 73 | '!DEUTSCHE', 74 | '!ALEMÂO', 75 | '!德国的语言', 76 | '!ドイツ語', 77 | '!НЕМЕЦКИЙ', 78 | '!BUYANYCSGO', 79 | '!BUYANYGEMS', 80 | '!BUYANYHYDRA', 81 | '!BUYANYTF', 82 | '!BUYCSGO', 83 | '!BUYGEMS', 84 | '!BUYHYDRA', 85 | '!BUYTF', 86 | '!BUYONECSGO', 87 | '!BUYONEGEMS', 88 | '!BUYONEHYDRA', 89 | '!BUYONETF', 90 | '!SELLCSGO', 91 | '!SELLGEMS', 92 | '!SELLHYDRA', 93 | '!SELLTF', 94 | '!CHECK', 95 | '!CHECKONE', 96 | '!CHECKCSGO', 97 | '!CHECKGEMS', 98 | '!CHECKHYDRA', 99 | '!CHECKTF', 100 | '!INVITE', 101 | '!KEYLIST', 102 | '!LEVEL', 103 | '!OWNER', 104 | '!PRICES', 105 | '!PRICE', 106 | '!RATES', 107 | '!RATE', 108 | '!RANK', 109 | '!REPORT', 110 | '!STOCK', 111 | '!STATS', 112 | '!TUTORIAL', 113 | '!SETS4SETS', 114 | '!SET4SET', 115 | '!ADMIN', 116 | '!AUTHCODE', 117 | '!BLOCK', 118 | '!BROADCAST', 119 | '!DIE', 120 | '!PROFIT', 121 | '!RELOAD', 122 | '!REQUESTER', 123 | '!RESTART', 124 | '!RESTOCK', 125 | '!UNBLOCK', 126 | '!CANCEL', 127 | '!ROLLBACK', 128 | '!UNPACK', 129 | '!USERCHECK', 130 | '!MYSTATS', 131 | '!WITHDRAWBOOSTER', 132 | '!WITHDRAWCSGO', 133 | '!WITHDRAWGEMS', 134 | '!WITHDRAWHYDRA', 135 | '!WITHDRAWTF', 136 | '!WITHDRAWSETS', 137 | '!WITHDRAWLEFTOVER', 138 | '!DEPOSITBOOSTER', 139 | '!DEPOSITCSGO', 140 | '!DEPOSITGEMS', 141 | '!DEPOSITHYDRA', 142 | '!DEPOSITTF', 143 | '!DEPOSITSETS', 144 | ]; 145 | 146 | module.exports = commands; 147 | -------------------------------------------------------------------------------- /src/Commands/Admin/GEMS/WITHDRAW/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const acceptedCurrencies = require('../../../../Config/currencies'); 3 | const chatMessage = require('../../../../Components/message'); 4 | const makeOffer = require('../../../../Components/offer'); 5 | const log = require('../../../../Components/log'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, msg, client, users, manager) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const amountgems = parseInt( 11 | msg.toUpperCase().replace('!WITHDRAWGEMS ', ''), 12 | 10 13 | ); 14 | if (!Number.isNaN(amountgems) && parseInt(amountgems, 10) > 0) { 15 | chatMessage(client, sender, messages.REQUEST[language]); 16 | manager.getInventoryContents(753, 6, true, (ERR, INV) => { 17 | log.adminChat( 18 | sender.getSteamID64(), 19 | language, 20 | `[ !WITHDRAWGEMS ${amountgems} ]` 21 | ); 22 | if (ERR) { 23 | chatMessage(client, sender, messages.ERROR.LOADINVENTORY.US[language]); 24 | log.error(`An error occurred while getting inventory: ${ERR}`); 25 | } else { 26 | let botgems = 0; 27 | const inv = INV; 28 | const myGems = []; 29 | let need = amountgems; 30 | for (let i = 0; i < inv.length; i += 1) { 31 | if (need !== 0) { 32 | if ( 33 | acceptedCurrencies.steamGems.indexOf(inv[i].market_hash_name) >= 0 34 | ) { 35 | inv[i].amount = need <= inv[i].amount ? need : inv[i].amount; 36 | need -= inv[i].amount; 37 | botgems += inv[i].amount; 38 | myGems.push(inv[i]); 39 | } 40 | } else { 41 | break; 42 | } 43 | } 44 | if (botgems < amountgems) { 45 | chatMessage( 46 | client, 47 | sender, 48 | messages.ERROR.OUTOFSTOCK.DEFAULT.GEMS.US[1][language].replace( 49 | '{GEMS}', 50 | botgems 51 | ) 52 | ); 53 | } else { 54 | const message = messages.TRADE.SETMESSAGE[0].GEMS[language].replace( 55 | '{GEMS}', 56 | amountgems 57 | ); 58 | makeOffer( 59 | client, 60 | users, 61 | manager, 62 | sender.getSteamID64(), 63 | myGems, 64 | [], 65 | '!WITHDRAWGEMS', 66 | message, 67 | 0, 68 | 0, 69 | 0, 70 | amountgems 71 | ); 72 | } 73 | } 74 | }); 75 | } else { 76 | chatMessage( 77 | client, 78 | sender, 79 | messages.ERROR.INPUT.INVALID.GEMS[language].replace( 80 | '{command}', 81 | '!WITHDRAWGEMS 1' 82 | ) 83 | ); 84 | } 85 | }; 86 | -------------------------------------------------------------------------------- /src/Components/steamSupply.js: -------------------------------------------------------------------------------- 1 | const moment = require('moment'); 2 | const axios = require('axios'); 3 | 4 | const { steamSupply, maxStock, maxBuy } = require('../Config/main.js'); 5 | const rates = require('../Config/rates.js'); 6 | const log = require('./log.js'); 7 | 8 | const updateCatalog = async ( 9 | hydraKeysQuantity = 0, 10 | csgoKeysQuantity = 0, 11 | tf2KeysQuantity = 0, 12 | gemsQuantity = 0 13 | ) => { 14 | if (steamSupply.apiKey === '') { 15 | throw new Error('Steam.Supply API its empty!'); 16 | } else { 17 | const SteamSupplyData = {}; 18 | 19 | // Bot Setup Data 20 | SteamSupplyData.maxTradeKeys = maxBuy; 21 | SteamSupplyData.maxStock = maxStock; 22 | 23 | // Inventory Amount 24 | SteamSupplyData.hydraamount = hydraKeysQuantity; 25 | SteamSupplyData.csgoamount = csgoKeysQuantity; 26 | SteamSupplyData.tf2amount = tf2KeysQuantity; 27 | SteamSupplyData.gemamount = gemsQuantity; 28 | 29 | // Sell Rate 30 | SteamSupplyData.hydrarate = rates.hydra.sell; 31 | SteamSupplyData.csgorate = rates.csgo.sell; 32 | SteamSupplyData.tf2rate = rates.tf.sell; 33 | SteamSupplyData.gemrate = rates.gems.sell; 34 | 35 | // Buy Rate 36 | SteamSupplyData.hydrabuyrate = rates.hydra.buy; 37 | SteamSupplyData.csgobuyrate = rates.csgo.buy; 38 | SteamSupplyData.tf2buyrate = rates.tf.buy; 39 | SteamSupplyData.gembuyrate = rates.gems.buy; 40 | 41 | const options = { 42 | method: 'GET', 43 | baseURL: 'https://steam.supply/API/', 44 | url: `${steamSupply.apiKey}/update/`, 45 | params: SteamSupplyData, 46 | }; 47 | 48 | await axios(options); 49 | } 50 | }; 51 | 52 | const getCardDB = () => 53 | new Promise((resolve, reject) => { 54 | if (steamSupply.apiKey === '') { 55 | reject(new Error('Steam.Supply APIKEY its empty!')); 56 | } 57 | 58 | const options = { 59 | method: 'GET', 60 | baseURL: 'https://steam.supply/API/', 61 | url: `${steamSupply.apiKey}/cardamount`, 62 | }; 63 | 64 | axios(options) 65 | .then(({ status, data }) => { 66 | if (status !== 200) { 67 | log.warn( 68 | `Failed to request steam.supply database, trying again in a minute.` 69 | ); 70 | setTimeout(() => { 71 | resolve(getCardDB()); 72 | }, moment.duration(1, 'minute')); 73 | return; 74 | } 75 | 76 | if (typeof data === 'string') { 77 | if ( 78 | data.indexOf('Missing api type or key') > -1 || 79 | data.indexOf('you are not paid.') > -1 || 80 | data.indexOf('API key not found') > -1 81 | ) { 82 | reject( 83 | new Error( 84 | 'Your steam.supply api its not correct, or you its not featured.' 85 | ) 86 | ); 87 | } 88 | } 89 | 90 | resolve(JSON.stringify(data)); 91 | }) 92 | .catch(reject); 93 | }); 94 | 95 | module.exports = { updateCatalog, getCardDB }; 96 | -------------------------------------------------------------------------------- /src/Commands/Admin/BOOSTER/DEPOSIT/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const messages = require('../../../../Config/messages'); 3 | const makeOffer = require('../../../../Components/offer'); 4 | const log = require('../../../../Components/log'); 5 | const utils = require('../../../../Utils'); 6 | 7 | module.exports = (sender, msg, client, users, manager) => { 8 | const language = utils.getLanguage(sender.getSteamID64(), users); 9 | const amountbooster = parseInt( 10 | msg.toUpperCase().replace('!DEPOSITBOOSTER ', ''), 11 | 10 12 | ); 13 | if (!Number.isNaN(amountbooster) && parseInt(amountbooster, 10) > 0) { 14 | log.adminChat( 15 | sender.getSteamID64(), 16 | language, 17 | `[ !DEPOSITBOOSTER ${amountbooster} ]` 18 | ); 19 | chatMessage(client, sender, messages.REQUEST[language]); 20 | manager.getUserInventoryContents( 21 | sender.getSteamID64(), 22 | 753, 23 | 6, 24 | true, 25 | (ERR, INV) => { 26 | if (!ERR) { 27 | const theirbooster = []; 28 | for (let i = 0; i < INV.length; i += 1) { 29 | if ( 30 | theirbooster.length < amountbooster && 31 | INV[i].type === 'Booster Pack' 32 | ) { 33 | theirbooster.push(INV[i]); 34 | } 35 | } 36 | if (theirbooster.length < amountbooster) { 37 | chatMessage( 38 | client, 39 | sender, 40 | messages.ERROR.OUTOFSTOCK.DEFAULT.BOOSTER.THEM[language].replace( 41 | '{BOOSTER}', 42 | theirbooster.length 43 | ) 44 | ); 45 | } else { 46 | const message = messages.TRADE.SETMESSAGE[0].BOOSTER[ 47 | language 48 | ].replace('{BOOSTER}', amountbooster.toString()); 49 | makeOffer( 50 | client, 51 | users, 52 | manager, 53 | sender.getSteamID64(), 54 | [], 55 | theirbooster, 56 | '!DEPOSITBOOSTER', 57 | message, 58 | 0, 59 | 0, 60 | 0, 61 | 0 62 | ); 63 | } 64 | } else if (ERR.message.indexOf('profile is private') > -1) { 65 | chatMessage( 66 | client, 67 | sender, 68 | messages.ERROR.LOADINVENTORY.THEM[2][language] 69 | ); 70 | log.error(`An error occurred while getting user inventory: ${ERR}`); 71 | } else { 72 | chatMessage( 73 | client, 74 | sender, 75 | messages.ERROR.LOADINVENTORY.THEM[0][language] 76 | ); 77 | log.error(`An error occurred while getting user inventory: ${ERR}`); 78 | } 79 | } 80 | ); 81 | } else { 82 | chatMessage( 83 | client, 84 | sender, 85 | messages.ERROR.INPUT.INVALID.BOOSTER[language].replace( 86 | '{command}', 87 | '!DEPOSITBOOSTER 1' 88 | ) 89 | ); 90 | } 91 | }; 92 | -------------------------------------------------------------------------------- /src/Commands/Admin/TF/DEPOSIT/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const acceptedCurrencies = require('../../../../Config/currencies'); 3 | const chatMessage = require('../../../../Components/message'); 4 | const makeOffer = require('../../../../Components/offer'); 5 | const log = require('../../../../Components/log'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, msg, client, users, manager) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const amountkeys = parseInt(msg.toUpperCase().replace('!DEPOSITTF ', ''), 10); 11 | if (!Number.isNaN(amountkeys) && parseInt(amountkeys, 10) > 0) { 12 | log.adminChat( 13 | sender.getSteamID64(), 14 | language, 15 | `[ !DEPOSITTF ${amountkeys} ]` 16 | ); 17 | chatMessage(client, sender, messages.REQUEST[language]); 18 | manager.getUserInventoryContents( 19 | sender.getSteamID64(), 20 | 440, 21 | 2, 22 | true, 23 | (ERR, INV) => { 24 | if (!ERR) { 25 | const theirKeys = []; 26 | for (let i = 0; i < INV.length; i += 1) { 27 | if ( 28 | theirKeys.length < amountkeys && 29 | acceptedCurrencies.tf.indexOf(INV[i].market_hash_name) >= 0 30 | ) { 31 | theirKeys.push(INV[i]); 32 | } 33 | } 34 | if (theirKeys.length < amountkeys) { 35 | chatMessage( 36 | client, 37 | sender, 38 | messages.ERROR.OUTOFSTOCK.DEFAULT.TF.THEM[1][language].replace( 39 | '{TF}', 40 | theirKeys.length 41 | ) 42 | ); 43 | } else { 44 | const message = messages.TRADE.SETMESSAGE[0].TF[language].replace( 45 | '{TF}', 46 | amountkeys 47 | ); 48 | makeOffer( 49 | client, 50 | users, 51 | manager, 52 | sender.getSteamID64(), 53 | [], 54 | theirKeys, 55 | '!DEPOSITTF', 56 | message, 57 | 0, 58 | 0, 59 | amountkeys, 60 | 0 61 | ); 62 | } 63 | } else if (ERR.message.indexOf('profile is private') > -1) { 64 | chatMessage( 65 | client, 66 | sender, 67 | messages.ERROR.LOADINVENTORY.THEM[2][language] 68 | ); 69 | log.error(`An error occurred while getting user inventory: ${ERR}`); 70 | } else { 71 | chatMessage( 72 | client, 73 | sender, 74 | messages.ERROR.LOADINVENTORY.THEM[0][language] 75 | ); 76 | log.error(`An error occurred while getting user inventory: ${ERR}`); 77 | } 78 | } 79 | ); 80 | } else { 81 | chatMessage( 82 | client, 83 | sender, 84 | messages.ERROR.INPUT.INVALID.TF[language].replace( 85 | '{command}', 86 | '!DEPOSITTF 1' 87 | ) 88 | ); 89 | } 90 | }; 91 | -------------------------------------------------------------------------------- /src/Commands/Admin/HYDRA/DEPOSIT/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const acceptedCurrencies = require('../../../../Config/currencies'); 3 | const chatMessage = require('../../../../Components/message'); 4 | const makeOffer = require('../../../../Components/offer'); 5 | const log = require('../../../../Components/log'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, msg, client, users, manager) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const amountkeys = parseInt( 11 | msg.toUpperCase().replace('!DEPOSITHYDRA ', ''), 12 | 10 13 | ); 14 | 15 | if (!Number.isNaN(amountkeys) && parseInt(amountkeys, 10) > 0) { 16 | log.adminChat( 17 | sender.getSteamID64(), 18 | language, 19 | `[ !DEPOSITHYDRA ${amountkeys} ]` 20 | ); 21 | chatMessage(client, sender, messages.REQUEST[language]); 22 | manager.getUserInventoryContents( 23 | sender.getSteamID64(), 24 | 730, 25 | 2, 26 | true, 27 | (ERR, INV) => { 28 | if (!ERR) { 29 | const theirKeys = []; 30 | for (let i = 0; i < INV.length; i += 1) { 31 | if ( 32 | theirKeys.length < amountkeys && 33 | acceptedCurrencies.hydra.indexOf(INV[i].market_hash_name) >= 0 34 | ) { 35 | theirKeys.push(INV[i]); 36 | } 37 | } 38 | if (theirKeys.length < amountkeys) { 39 | chatMessage( 40 | client, 41 | sender, 42 | messages.ERROR.OUTOFSTOCK.DEFAULT.HYDRA.THEM[1][language].replace( 43 | '{HYDRA}', 44 | theirKeys.length 45 | ) 46 | ); 47 | } else { 48 | const message = messages.TRADE.SETMESSAGE[0].HYDRA[ 49 | language 50 | ].replace('{HYDRA}', amountkeys); 51 | makeOffer( 52 | client, 53 | users, 54 | manager, 55 | sender.getSteamID64(), 56 | [], 57 | theirKeys, 58 | '!DEPOSITHYDRA', 59 | message, 60 | 0, 61 | 0, 62 | amountkeys, 63 | 0 64 | ); 65 | } 66 | } else if (ERR.message.indexOf('profile is private') > -1) { 67 | chatMessage( 68 | client, 69 | sender, 70 | messages.ERROR.LOADINVENTORY.THEM[2][language] 71 | ); 72 | log.error(`An error occurred while getting user inventory: ${ERR}`); 73 | } else { 74 | chatMessage( 75 | client, 76 | sender, 77 | messages.ERROR.LOADINVENTORY.THEM[0][language] 78 | ); 79 | log.error(`An error occurred while getting user inventory: ${ERR}`); 80 | } 81 | } 82 | ); 83 | } else { 84 | chatMessage( 85 | client, 86 | sender, 87 | messages.ERROR.INPUT.INVALID.HYDRA[language].replace( 88 | '{command}', 89 | '!DEPOSITHYDRA 1' 90 | ) 91 | ); 92 | } 93 | }; 94 | -------------------------------------------------------------------------------- /src/Commands/Admin/CSGO/DEPOSIT/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const acceptedCurrencies = require('../../../../Config/currencies'); 3 | const chatMessage = require('../../../../Components/message'); 4 | const makeOffer = require('../../../../Components/offer'); 5 | const log = require('../../../../Components/log'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, msg, client, users, manager) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const amountkeys = parseInt( 11 | msg.toUpperCase().replace('!DEPOSITCSGO ', ''), 12 | 10 13 | ); 14 | 15 | if (!Number.isNaN(amountkeys) && parseInt(amountkeys, 10) > 0) { 16 | log.adminChat( 17 | sender.getSteamID64(), 18 | language, 19 | `[ !DEPOSITCSGO ${amountkeys} ]` 20 | ); 21 | chatMessage(client, sender, messages.REQUEST[language]); 22 | manager.getUserInventoryContents( 23 | sender.getSteamID64(), 24 | 730, 25 | 2, 26 | true, 27 | (ERR, INV) => { 28 | if (!ERR) { 29 | const theirKeys = []; 30 | for (let i = 0; i < INV.length; i += 1) { 31 | if ( 32 | theirKeys.length < amountkeys && 33 | acceptedCurrencies.csgo.indexOf(INV[i].market_hash_name) >= 0 34 | ) { 35 | theirKeys.push(INV[i]); 36 | } 37 | } 38 | if (theirKeys.length < amountkeys) { 39 | chatMessage( 40 | client, 41 | sender, 42 | messages.ERROR.OUTOFSTOCK.DEFAULT.CSGO.THEM[1][language].replace( 43 | '{CSGO}', 44 | theirKeys.length 45 | ) 46 | ); 47 | } else { 48 | const message = messages.TRADE.SETMESSAGE[0].CSGO[language].replace( 49 | '{CSGO}', 50 | amountkeys 51 | ); 52 | makeOffer( 53 | client, 54 | users, 55 | manager, 56 | sender.getSteamID64(), 57 | [], 58 | theirKeys, 59 | '!DEPOSITCSGO', 60 | message, 61 | 0, 62 | 0, 63 | amountkeys, 64 | 0 65 | ); 66 | } 67 | } else if (ERR.message.indexOf('profile is private') > -1) { 68 | chatMessage( 69 | client, 70 | sender, 71 | messages.ERROR.LOADINVENTORY.THEM[2][language] 72 | ); 73 | log.error(`An error occurred while getting user inventory: ${ERR}`); 74 | } else { 75 | chatMessage( 76 | client, 77 | sender, 78 | messages.ERROR.LOADINVENTORY.THEM[0][language] 79 | ); 80 | log.error(`An error occurred while getting user inventory: ${ERR}`); 81 | } 82 | } 83 | ); 84 | } else { 85 | chatMessage( 86 | client, 87 | sender, 88 | messages.ERROR.INPUT.INVALID.CSGO[language].replace( 89 | '{command}', 90 | '!DEPOSITCSGO 1' 91 | ) 92 | ); 93 | } 94 | }; 95 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/RESTOCK/index.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-continue */ 2 | const utils = require('../../../../Utils'); 3 | const messages = require('../../../../Config/messages'); 4 | const inventory = require('../../../../Components/inventory'); 5 | const chatMessage = require('../../../../Components/message'); 6 | const makeOffer = require('../../../../Components/offer'); 7 | const { getSets } = require('../../../../Components/sets'); 8 | const log = require('../../../../Components/log'); 9 | 10 | module.exports = (sender, client, users, community, allCards, manager) => { 11 | const language = utils.getLanguage(sender.getSteamID64(), users); 12 | 13 | chatMessage(client, sender, messages.REQUEST[language]); 14 | log.adminChat(sender.getSteamID64(), language, '[ !RESTOCK ]'); 15 | inventory.getInventory(sender.getSteamID64(), community, (ERR1, DATA1) => { 16 | log.warn('INVENTORY LOADED'); 17 | if (!ERR1) { 18 | const s = DATA1; 19 | const theirSets = []; 20 | getSets(s, allCards, (ERR2, DATA2) => { 21 | log.warn('SETS LOADED'); 22 | if (!ERR2) { 23 | let userNSets = 0; 24 | for (let i = 0; i < Object.keys(DATA2).length; i += 1) { 25 | userNSets += DATA2[Object.keys(DATA2)[i]].length; 26 | } 27 | if (userNSets === 0) { 28 | chatMessage( 29 | client, 30 | sender, 31 | messages.ERROR.OUTOFSTOCK.DEFAULT.SETS.THEM[1][language] 32 | ); 33 | } else { 34 | utils.sortSetsByAmountB(s, (DATA3) => { 35 | for (let i = 0; i < DATA3.length; i += 1) { 36 | if (DATA2[DATA3[i]]) { 37 | for (let j = 0; j < DATA2[DATA3[i]].length; j += 1) { 38 | theirSets.push(DATA2[DATA3[i]][j]); 39 | } 40 | } else { 41 | continue; 42 | } 43 | } 44 | }); 45 | const message = messages.TRADE.SETMESSAGE[0].SETS[language].replace( 46 | '{SETS}', 47 | userNSets 48 | ); 49 | makeOffer( 50 | client, 51 | users, 52 | manager, 53 | sender.getSteamID64(), 54 | [], 55 | [].concat(...theirSets), 56 | '!RESTOCK', 57 | message, 58 | userNSets, 59 | 0, 60 | 0, 61 | 0 62 | ); 63 | } 64 | } else { 65 | chatMessage( 66 | client, 67 | sender, 68 | messages.ERROR.LOADINVENTORY.THEM[0][language] 69 | ); 70 | log.error(`An error occurred while getting user sets: ${ERR2}`); 71 | } 72 | }); 73 | } else if (ERR1.message.indexOf('profile is private') > -1) { 74 | chatMessage( 75 | client, 76 | sender, 77 | messages.ERROR.LOADINVENTORY.THEM[2][language] 78 | ); 79 | log.error(`An error occurred while getting user inventory: ${ERR1}`); 80 | } else { 81 | chatMessage( 82 | client, 83 | sender, 84 | messages.ERROR.LOADINVENTORY.THEM[0][language] 85 | ); 86 | log.error(`An error occurred while getting user inventory: ${ERR1}`); 87 | } 88 | }); 89 | }; 90 | -------------------------------------------------------------------------------- /src/Commands/Admin/SETS/WITHDRAW/index.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-restricted-syntax */ 2 | const messages = require('../../../../Config/messages'); 3 | const inventory = require('../../../../Components/inventory'); 4 | const utils = require('../../../../Utils'); 5 | const chatMessage = require('../../../../Components/message'); 6 | const makeOffer = require('../../../../Components/offer'); 7 | const log = require('../../../../Components/log'); 8 | 9 | module.exports = (sender, msg, client, users, manager) => { 10 | const language = utils.getLanguage(sender.getSteamID64(), users); 11 | const amountofsets = parseInt( 12 | msg.toUpperCase().replace('!WITHDRAWSETS ', ''), 13 | 10 14 | ); 15 | 16 | if (!Number.isNaN(amountofsets) && amountofsets > 0) { 17 | log.adminChat( 18 | sender.getSteamID64(), 19 | language, 20 | `[ !WITHDRAWSETS ${amountofsets} ]` 21 | ); 22 | chatMessage(client, sender, messages.REQUEST[language]); 23 | manager.getInventoryContents(753, 2, true, (ERR) => { 24 | if (ERR) { 25 | log.error(`An error occurred while getting inventory: ${ERR}`); 26 | chatMessage(client, sender, messages.ERROR.LOADINVENTORY.US[language]); 27 | } else { 28 | let amountofB = amountofsets; 29 | const mySets = []; 30 | utils.sortSetsByAmount(inventory.botSets, (DATA) => { 31 | const setsSent = {}; 32 | firstLoop: for (let i = 0; i < DATA.length; i += 1) { 33 | if (inventory.botSets[DATA[i]]) { 34 | for (let j = 0; j < inventory.botSets[DATA[i]].length; j += 1) { 35 | if (amountofB > 0) { 36 | if ( 37 | (setsSent[DATA[i]] && setsSent[DATA[i]] > -1) || 38 | !setsSent[DATA[i]] 39 | ) { 40 | mySets.push(inventory.botSets[DATA[i]][j]); 41 | amountofB -= 1; 42 | if (!setsSent[DATA[i]]) { 43 | setsSent[DATA[i]] = 1; 44 | } else { 45 | setsSent[DATA[i]] += 1; 46 | } 47 | } else { 48 | continue firstLoop; 49 | } 50 | } else { 51 | continue firstLoop; 52 | } 53 | } 54 | } else { 55 | continue; 56 | } 57 | } 58 | }); 59 | if (amountofB > 0) { 60 | chatMessage( 61 | client, 62 | sender, 63 | messages.ERROR.OUTOFSTOCK.DEFAULT.SETS.US[0][language] 64 | ); 65 | } else { 66 | const message = messages.TRADE.SETMESSAGE[0].SETS[language].replace( 67 | '{SETS}', 68 | amountofsets 69 | ); 70 | makeOffer( 71 | client, 72 | users, 73 | manager, 74 | sender.getSteamID64(), 75 | [].concat(...mySets), 76 | [], 77 | '!WITHDRAWSETS', 78 | message, 79 | amountofsets, 80 | 0, 81 | 0, 82 | 0 83 | ); 84 | } 85 | } 86 | }); 87 | } else { 88 | chatMessage( 89 | client, 90 | sender, 91 | messages.ERROR.INPUT.INVALID.SETS[language].replace( 92 | '{command}', 93 | '!WITHDRAWSETS 1' 94 | ) 95 | ); 96 | } 97 | }; 98 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/ROLLBACK/index.js: -------------------------------------------------------------------------------- 1 | const log = require('../../../../Components/log'); 2 | const chatMessage = require('../../../../Components/message'); 3 | const makeOffer = require('../../../../Components/offer'); 4 | const messages = require('../../../../Config/messages'); 5 | const utils = require('../../../../Utils'); 6 | 7 | module.exports = (sender, msg, client, users, community, manager) => { 8 | const language = utils.getLanguage(sender.getSteamID64(), users); 9 | const offerID = msg.substring('!ROLLBACK'.length).trim(); 10 | 11 | if (offerID) { 12 | chatMessage(client, sender, messages.REQUEST[language]); 13 | log.adminChat(sender.getSteamID64(), language, `[ !ROLLBACK ${offerID} ]`); 14 | 15 | manager.getOffer(offerID, async (error, offer) => { 16 | if (error) { 17 | chatMessage(client, sender, messages.ERROR.GETOFFER[language]); 18 | log.error(`There was an error getting offers: ${error}`); 19 | } else { 20 | let itemsSent = []; 21 | let itemsReceived = []; 22 | 23 | try { 24 | if (offer.itemsToGive.length > 0) { 25 | itemsSent = await utils.getExchangedItems( 26 | community, 27 | offer.partner.getSteamID64(), 28 | offer.itemsToGive[0].appid, 29 | offer.itemsToGive[0].contextid, 30 | offer.itemsToGive, 31 | 'USER' 32 | ); 33 | } 34 | 35 | if (offer.itemsToReceive.length > 0) { 36 | itemsReceived = await utils.getExchangedItems( 37 | community, 38 | client.steamID.getSteamID64(), 39 | offer.itemsToReceive[0].appid, 40 | offer.itemsToReceive[0].contextid, 41 | offer.itemsToReceive, 42 | 'BOT' 43 | ); 44 | } 45 | 46 | makeOffer( 47 | client, 48 | users, 49 | manager, 50 | offer.partner.getSteamID64(), 51 | [].concat(...itemsReceived), 52 | [].concat(...itemsSent), 53 | '!ROLLBACK', 54 | messages.TRADE.SETMESSAGE[0].ROLLBACK[ 55 | utils.getLanguage(offer.partner.getSteamID64(), users) 56 | ].replace('{OFFERID}', offer.id), 57 | offer.data('amountofsets'), 58 | offer.data('amountofleftovers'), 59 | offer.data('amountofkeys'), 60 | offer.data('amountofgems') 61 | ); 62 | } catch (error1) { 63 | log.error(`There was an error getting items: ${error1}`); 64 | 65 | if (error1.message.indexOf('BOT items are unavailable') > -1) { 66 | chatMessage( 67 | client, 68 | sender, 69 | messages.TRADE.BOTITEMSUNAVAILABLE[language] 70 | ); 71 | } else if ( 72 | error1.message.indexOf('User items are unavailable') > -1 73 | ) { 74 | chatMessage( 75 | client, 76 | sender, 77 | messages.TRADE.USERITEMSUNAVAILABLE[language] 78 | ); 79 | } else { 80 | chatMessage(client, sender, messages.ERROR.GETITEMS[language]); 81 | } 82 | } 83 | } 84 | }); 85 | } else { 86 | chatMessage( 87 | client, 88 | sender, 89 | messages.ERROR.INPUT.INVALID.OFFERID[language].replace( 90 | '{command}', 91 | '!ROLLBACK offerID' 92 | ) 93 | ); 94 | } 95 | }; 96 | -------------------------------------------------------------------------------- /src/Commands/User/TF/CHECK/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const main = require('../../../../Config/main'); 3 | const messages = require('../../../../Config/messages'); 4 | const rates = require('../../../../Config/rates'); 5 | const utils = require('../../../../Utils'); 6 | const log = require('../../../../Components/log'); 7 | 8 | module.exports = (sender, msg, client, users) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const n = parseInt(msg.toUpperCase().replace('!CHECKTF ', ''), 10); 11 | 12 | if (!Number.isNaN(n) && parseInt(n, 10) > 0) { 13 | log.userChat(sender.getSteamID64(), language, `[ !CHECKTF ${n} ]`); 14 | if (main.maxCheck.tf >= n) { 15 | utils.getBadges( 16 | sender.getSteamID64(), 17 | (ERR, DATA, CURRENTLEVEL, _, TOTALXP) => { 18 | if (!ERR) { 19 | if (DATA) { 20 | if (CURRENTLEVEL >= 0) { 21 | const xpWon = 100 * n * rates.tf.sell; 22 | const totalExp = TOTALXP + xpWon; 23 | let i = parseInt(CURRENTLEVEL, 10) - 1; 24 | let can = 0; 25 | do { 26 | i += 1; 27 | if (i - 1 > main.maxLevel) { 28 | chatMessage( 29 | client, 30 | sender, 31 | messages.ERROR.INPUT.AMOUNTOVER.TF[language].replace( 32 | '{KEYS}', 33 | main.maxCheck.tf 34 | ) 35 | ); 36 | can += 1; 37 | break; 38 | } 39 | } while (utils.getLevelExp(i) <= totalExp); 40 | if (!can) { 41 | if (CURRENTLEVEL !== i - 1) { 42 | chatMessage( 43 | client, 44 | sender, 45 | messages.CHECK.TF[0][language] 46 | .replace(/{TF}/g, n) 47 | .replace('{SETS}', n * rates.tf.sell) 48 | .replace('{LEVEL}', i - 1) 49 | ); 50 | } else { 51 | chatMessage( 52 | client, 53 | sender, 54 | messages.CHECK.TF[1][language] 55 | .replace(/{TF}/g, n) 56 | .replace('{SETS}', n * rates.tf.sell) 57 | .replace('{LEVEL}', i - 1) 58 | ); 59 | } 60 | } 61 | } else { 62 | chatMessage(client, sender, messages.ERROR.LEVEL[1][language]); 63 | } 64 | } else { 65 | chatMessage(client, sender, messages.ERROR.LEVEL[0][language]); 66 | } 67 | } else { 68 | log.error(`An error occurred while getting badge data: ${ERR}`); 69 | chatMessage(client, sender, messages.ERROR.BADGES[1][language]); 70 | } 71 | } 72 | ); 73 | } else { 74 | chatMessage( 75 | client, 76 | sender, 77 | messages.ERROR.INPUT.AMOUNTOVER.TF[language].replace( 78 | '{KEYS}', 79 | main.maxCheck.tf 80 | ) 81 | ); 82 | } 83 | } else { 84 | chatMessage( 85 | client, 86 | sender, 87 | messages.ERROR.INPUT.INVALID.TF[language].replace( 88 | '{command}', 89 | '!CHECKTF 1' 90 | ) 91 | ); 92 | } 93 | }; 94 | -------------------------------------------------------------------------------- /src/Commands/Admin/GEMS/DEPOSIT/index.js: -------------------------------------------------------------------------------- 1 | const messages = require('../../../../Config/messages'); 2 | const acceptedCurrencies = require('../../../../Config/currencies'); 3 | const chatMessage = require('../../../../Components/message'); 4 | const makeOffer = require('../../../../Components/offer'); 5 | const log = require('../../../../Components/log'); 6 | const utils = require('../../../../Utils'); 7 | 8 | module.exports = (sender, msg, client, users, manager) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const amountgems = parseInt( 11 | msg.toUpperCase().replace('!DEPOSITGEMS ', ''), 12 | 10 13 | ); 14 | if (!Number.isNaN(amountgems) && parseInt(amountgems, 10) > 0) { 15 | log.adminChat( 16 | sender.getSteamID64(), 17 | language, 18 | `[ !DEPOSITGEMS ${amountgems} ]` 19 | ); 20 | chatMessage(client, sender, messages.REQUEST[language]); 21 | manager.getUserInventoryContents( 22 | sender.getSteamID64(), 23 | 753, 24 | 6, 25 | true, 26 | (ERR, INV) => { 27 | if (!ERR) { 28 | let theirgems = 0; 29 | const inv = INV; 30 | const gems = []; 31 | let need = amountgems; 32 | for (let i = 0; i < INV.length; i += 1) { 33 | if (need !== 0) { 34 | if ( 35 | acceptedCurrencies.steamGems.indexOf(inv[i].market_hash_name) >= 36 | 0 37 | ) { 38 | inv[i].amount = need <= inv[i].amount ? need : inv[i].amount; 39 | need -= inv[i].amount; 40 | theirgems += inv[i].amount; 41 | gems.push(inv[i]); 42 | } 43 | } else { 44 | break; 45 | } 46 | } 47 | if (theirgems < amountgems) { 48 | chatMessage( 49 | client, 50 | sender, 51 | messages.ERROR.OUTOFSTOCK.DEFAULT.GEMS.THEM[1][language].replace( 52 | '{GEMS}', 53 | theirgems 54 | ) 55 | ); 56 | } else { 57 | const message = messages.TRADE.SETMESSAGE[0].GEMS[language].replace( 58 | '{GEMS}', 59 | amountgems 60 | ); 61 | makeOffer( 62 | client, 63 | users, 64 | manager, 65 | sender.getSteamID64(), 66 | [], 67 | gems, 68 | '!DEPOSITGEMS', 69 | message, 70 | 0, 71 | 0, 72 | 0, 73 | amountgems 74 | ); 75 | } 76 | } else if (ERR.message.indexOf('profile is private') > -1) { 77 | chatMessage( 78 | client, 79 | sender, 80 | messages.ERROR.LOADINVENTORY.THEM[2][language] 81 | ); 82 | log.error(`An error occurred while getting user inventory: ${ERR}`); 83 | } else { 84 | chatMessage( 85 | client, 86 | sender, 87 | messages.ERROR.LOADINVENTORY.THEM[0][language] 88 | ); 89 | log.error(`An error occurred while getting user inventory: ${ERR}`); 90 | } 91 | } 92 | ); 93 | } else { 94 | chatMessage( 95 | client, 96 | sender, 97 | messages.ERROR.INPUT.INVALID.GEMS[language].replace( 98 | '{command}', 99 | '!DEPOSITGEMS 1' 100 | ) 101 | ); 102 | } 103 | }; 104 | -------------------------------------------------------------------------------- /src/Commands/User/CSGO/CHECK/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const main = require('../../../../Config/main'); 3 | const messages = require('../../../../Config/messages'); 4 | const rates = require('../../../../Config/rates'); 5 | const utils = require('../../../../Utils'); 6 | const log = require('../../../../Components/log'); 7 | 8 | module.exports = (sender, msg, client, users) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const n = parseInt(msg.toUpperCase().replace('!CHECKCSGO ', ''), 10); 11 | 12 | if (!Number.isNaN(n) && parseInt(n, 10) > 0) { 13 | log.userChat(sender.getSteamID64(), language, `[ !CHECKCSGO ${n} ]`); 14 | if (main.maxCheck.csgo >= n) { 15 | utils.getBadges( 16 | sender.getSteamID64(), 17 | (ERR, DATA, CURRENTLEVEL, _, TOTALXP) => { 18 | if (!ERR) { 19 | if (DATA) { 20 | if (CURRENTLEVEL >= 0) { 21 | const xpWon = 100 * n * rates.csgo.sell; 22 | const totalExp = TOTALXP + xpWon; 23 | let i = parseInt(CURRENTLEVEL, 10) - 1; 24 | let can = 0; 25 | do { 26 | i += 1; 27 | if (i - 1 > main.maxLevel) { 28 | chatMessage( 29 | client, 30 | sender, 31 | messages.ERROR.INPUT.AMOUNTOVER.CSGO[language].replace( 32 | '{KEYS}', 33 | main.maxCheck.csgo 34 | ) 35 | ); 36 | can += 1; 37 | break; 38 | } 39 | } while (utils.getLevelExp(i) <= totalExp); 40 | if (!can) { 41 | if (CURRENTLEVEL !== i - 1) { 42 | chatMessage( 43 | client, 44 | sender, 45 | messages.CHECK.CSGO[0][language] 46 | .replace(/{CSGO}/g, n) 47 | .replace('{SETS}', n * rates.csgo.sell) 48 | .replace('{LEVEL}', i - 1) 49 | ); 50 | } else { 51 | chatMessage( 52 | client, 53 | sender, 54 | messages.CHECK.CSGO[1][language] 55 | .replace(/{CSGO}/g, n) 56 | .replace('{SETS}', n * rates.csgo.sell) 57 | .replace('{LEVEL}', i - 1) 58 | ); 59 | } 60 | } 61 | } else { 62 | chatMessage(client, sender, messages.ERROR.LEVEL[1][language]); 63 | } 64 | } else { 65 | chatMessage(client, sender, messages.ERROR.LEVEL[0][language]); 66 | } 67 | } else { 68 | log.error(`An error occurred while getting badge data: ${ERR}`); 69 | chatMessage(client, sender, messages.ERROR.BADGES[1][language]); 70 | } 71 | } 72 | ); 73 | } else { 74 | chatMessage( 75 | client, 76 | sender, 77 | messages.ERROR.INPUT.AMOUNTOVER.CSGO[language].replace( 78 | '{KEYS}', 79 | main.maxCheck.csgo 80 | ) 81 | ); 82 | } 83 | } else { 84 | chatMessage( 85 | client, 86 | sender, 87 | messages.ERROR.INPUT.INVALID.CSGO[language].replace( 88 | '{command}', 89 | '!CHECKCSGO 1' 90 | ) 91 | ); 92 | } 93 | }; 94 | -------------------------------------------------------------------------------- /src/Commands/User/HYDRA/CHECK/index.js: -------------------------------------------------------------------------------- 1 | const chatMessage = require('../../../../Components/message'); 2 | const main = require('../../../../Config/main'); 3 | const messages = require('../../../../Config/messages'); 4 | const rates = require('../../../../Config/rates'); 5 | const utils = require('../../../../Utils'); 6 | const log = require('../../../../Components/log'); 7 | 8 | module.exports = (sender, msg, client, users) => { 9 | const language = utils.getLanguage(sender.getSteamID64(), users); 10 | const n = parseInt(msg.toUpperCase().replace('!CHECKHYDRA ', ''), 10); 11 | 12 | if (!Number.isNaN(n) && parseInt(n, 10) > 0) { 13 | log.userChat(sender.getSteamID64(), language, `[ !CHECKHYDRA ${n} ]`); 14 | if (main.maxCheck.hydra >= n) { 15 | utils.getBadges( 16 | sender.getSteamID64(), 17 | (ERR, DATA, CURRENTLEVEL, _, TOTALXP) => { 18 | if (!ERR) { 19 | if (DATA) { 20 | if (CURRENTLEVEL >= 0) { 21 | const xpWon = 100 * n * rates.hydra.sell; 22 | const totalExp = TOTALXP + xpWon; 23 | let i = parseInt(CURRENTLEVEL, 10) - 1; 24 | let can = 0; 25 | do { 26 | i += 1; 27 | if (i - 1 > main.maxLevel) { 28 | chatMessage( 29 | client, 30 | sender, 31 | messages.ERROR.INPUT.AMOUNTOVER.HYDRA[language].replace( 32 | '{KEYS}', 33 | main.maxCheck.hydra 34 | ) 35 | ); 36 | can += 1; 37 | break; 38 | } 39 | } while (utils.getLevelExp(i) <= totalExp); 40 | if (!can) { 41 | if (CURRENTLEVEL !== i - 1) { 42 | chatMessage( 43 | client, 44 | sender, 45 | messages.CHECK.HYDRA[0][language] 46 | .replace(/{HYDRA}/g, n) 47 | .replace('{SETS}', n * rates.hydra.sell) 48 | .replace('{LEVEL}', i - 1) 49 | ); 50 | } else { 51 | chatMessage( 52 | client, 53 | sender, 54 | messages.CHECK.HYDRA[1][language] 55 | .replace(/{HYDRA}/g, n) 56 | .replace('{SETS}', n * rates.hydra.sell) 57 | .replace('{LEVEL}', i - 1) 58 | ); 59 | } 60 | } 61 | } else { 62 | chatMessage(client, sender, messages.ERROR.LEVEL[1][language]); 63 | } 64 | } else { 65 | chatMessage(client, sender, messages.ERROR.LEVEL[0][language]); 66 | } 67 | } else { 68 | log.error(`An error occurred while getting badge data: ${ERR}`); 69 | chatMessage(client, sender, messages.ERROR.BADGES[1][language]); 70 | } 71 | } 72 | ); 73 | } else { 74 | chatMessage( 75 | client, 76 | sender, 77 | messages.ERROR.INPUT.AMOUNTOVER.HYDRA[language].replace( 78 | '{KEYS}', 79 | main.maxCheck.hydra 80 | ) 81 | ); 82 | } 83 | } else { 84 | chatMessage( 85 | client, 86 | sender, 87 | messages.ERROR.INPUT.INVALID.HYDRA[language].replace( 88 | '{command}', 89 | '!CHECKHYDRA 1' 90 | ) 91 | ); 92 | } 93 | }; 94 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at . All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/USERCHECK/index.js: -------------------------------------------------------------------------------- 1 | const SID64REGEX = new RegExp(/^[0-9]{17}$/); 2 | 3 | const messages = require('../../../../Config/messages'); 4 | const chatMessage = require('../../../../Components/message'); 5 | const log = require('../../../../Components/log'); 6 | const reputation = require('../../../../Components/reputation'); 7 | const relationShip = require('../../../../Components/relationShip'); 8 | const customer = require('../../../../Components/customer'); 9 | const utils = require('../../../../Utils'); 10 | 11 | module.exports = (sender, msg, client, users, community, allCards) => { 12 | const language = utils.getLanguage(sender.getSteamID64(), users); 13 | 14 | chatMessage(client, sender, messages.REQUEST[language]); 15 | const id64 = msg.toUpperCase().replace('!USERCHECK ', '').toString(); 16 | log.adminChat(sender.getSteamID64(), language, `[ !USERCHECK ${id64} ]`); 17 | if (SID64REGEX.test(id64)) { 18 | let message = '/pre '; 19 | 20 | relationShip(client, id64, (relation) => { 21 | message += messages.USERCHECK.RELATIONSHIP[relation][language]; 22 | }); 23 | 24 | reputation(id64) 25 | .then((infos) => { 26 | message += messages.USERCHECK.REPUTATION.DEFAULT[language]; 27 | 28 | if (infos.summary) { 29 | message += messages.USERCHECK.REPUTATION[infos.summary][language]; 30 | } 31 | 32 | if (infos.tags) { 33 | message += messages.USERCHECK.REPUTATION[infos.tags][language]; 34 | } 35 | 36 | if (infos.vacban) { 37 | message += messages.USERCHECK.REPUTATION[infos.vacban][language]; 38 | } 39 | 40 | if (infos.tradeban) { 41 | message += messages.USERCHECK.REPUTATION[infos.tradeban][language]; 42 | } 43 | 44 | message += '\n'; 45 | }) 46 | .catch((error) => { 47 | log.error(`An error occurred while getting user in Steamrep: ${error}`); 48 | }); 49 | 50 | customer.badge(id64, (error, botNSets, hisMaxSets) => { 51 | if (error) { 52 | chatMessage(client, sender, messages.ERROR.BADGES[3][language]); 53 | log.error(`An error occurred while getting badges: ${error}`); 54 | } else { 55 | message += messages.USERCHECK.SETSAVAILABLE[language] 56 | .replace('{SETS1}', hisMaxSets) 57 | .replace('{SETS2}', botNSets); 58 | } 59 | }); 60 | 61 | customer.loadInventory(id64, community, allCards, (err) => { 62 | if (err) { 63 | chatMessage( 64 | client, 65 | sender, 66 | messages.ERROR.LOADINVENTORY.THEM[1][language] 67 | ); 68 | } else { 69 | message += messages.USERCHECK.INVENTORY[language] 70 | .replace('{TOTALSETS}', customer.stock.totalSets) 71 | .replace('{CSKEYSTRADABLE}', customer.stock.csKeys.tradable) 72 | .replace('{HYDRAKEYSTRADABLE}', customer.stock.hydraKeys.tradable) 73 | .replace('{TFKEYSTRADABLE}', customer.stock.tfKeys.tradable) 74 | .replace( 75 | '{GEMSQUANTITYTRADABLE}', 76 | customer.stock.gemsQuantity.tradable 77 | ) 78 | .replace('{CSKEYSNOTRADABLE}', customer.stock.csKeys.notradable) 79 | .replace('{HYDRAKEYSNOTRADABLE}', customer.stock.hydraKeys.notradable) 80 | .replace('{TFKEYSNOTRADABLE}', customer.stock.tfKeys.notradable) 81 | .replace( 82 | '{GEMSQUANTITYNOTRADABLE}', 83 | customer.stock.gemsQuantity.notradable 84 | ); 85 | chatMessage(client, sender, message); 86 | } 87 | }); 88 | } else { 89 | chatMessage( 90 | client, 91 | sender, 92 | messages.ERROR.INPUT.INVALID.STEAMID64[language] 93 | ); 94 | } 95 | }; 96 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/WITHDRAWLEFTOVER/index.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-restricted-syntax */ 2 | /* eslint-disable no-labels */ 3 | /* eslint-disable no-continue */ 4 | const utils = require('../../../../Utils'); 5 | const messages = require('../../../../Config/messages'); 6 | const inventory = require('../../../../Components/inventory'); 7 | const chatMessage = require('../../../../Components/message'); 8 | const makeOffer = require('../../../../Components/offer'); 9 | const log = require('../../../../Components/log'); 10 | 11 | module.exports = (sender, client, users, community, manager) => { 12 | const language = utils.getLanguage(sender.getSteamID64(), users); 13 | 14 | log.adminChat(sender.getSteamID64(), language, '[ !WITHDRAWLEFTOVER ]'); 15 | const cards = []; 16 | chatMessage(client, sender, messages.REQUEST[language]); 17 | for (let i = 0; i < Object.keys(inventory.botSets).length; i += 1) { 18 | for (let j = 0; j < Object.values(inventory.botSets)[i].length; j += 1) { 19 | for ( 20 | let k = 0; 21 | k < Object.keys(Object.values(inventory.botSets)[i][j]).length; 22 | k += 1 23 | ) { 24 | cards.push( 25 | Object.values(Object.values(inventory.botSets)[i])[j][k].assetid 26 | ); 27 | } 28 | } 29 | } 30 | utils.getleftovercards( 31 | client.steamID.getSteamID64(), 32 | community, 33 | cards, 34 | (ERR, DATA) => { 35 | if (ERR) { 36 | log.error(`An error occurred while getting inventory: ${ERR}`); 37 | chatMessage(client, sender, messages.ERROR.LOADINVENTORY.US[language]); 38 | } else { 39 | const Cards = {}; 40 | const myCards = []; 41 | for (let j = 0; j < Object.keys(DATA).length; j += 1) { 42 | Cards[Object.keys(DATA)[j]] = Object.values(Object.values(DATA)[j]); 43 | } 44 | if (Object.keys(Cards).length === 0) { 45 | chatMessage( 46 | client, 47 | sender, 48 | messages.ERROR.OUTOFSTOCK.DEFAULT.LEFTOVER[language] 49 | ); 50 | } else { 51 | const cardsSent = {}; 52 | utils.sortSetsByAmount(Cards, (DDATA) => { 53 | firstLoop: for (let i = 0; i < DDATA.length; i += 1) { 54 | if (Cards[DDATA[i]]) { 55 | for (let j = 0; j < Cards[DDATA[i]].length; j += 1) { 56 | for (let k = 0; k < Cards[DDATA[i]][j].length; k += 1) { 57 | if ( 58 | (cardsSent[DDATA[i]] && cardsSent[DDATA[i]] > -1) || 59 | !cardsSent[DDATA[i]] 60 | ) { 61 | myCards.push(Cards[DDATA[i]][j]); 62 | if (!cardsSent[DDATA[i]]) { 63 | cardsSent[DDATA[i]] = 1; 64 | } else { 65 | cardsSent[DDATA[i]] += 1; 66 | } 67 | } else { 68 | continue firstLoop; 69 | } 70 | } 71 | } 72 | } else { 73 | continue; 74 | } 75 | } 76 | }); 77 | let amountofleftovers = 0; 78 | for (const prop in cardsSent) { 79 | if (Object.prototype.hasOwnProperty.call(cardsSent, prop)) { 80 | amountofleftovers += cardsSent[prop]; 81 | } 82 | } 83 | 84 | const message = messages.TRADE.SETMESSAGE[0].LEFTOVER[language]; 85 | makeOffer( 86 | client, 87 | users, 88 | manager, 89 | sender.getSteamID64(), 90 | [].concat(...myCards), 91 | [], 92 | '!WITHDRAWLEFTOVER', 93 | message, 94 | 0, 95 | amountofleftovers, 96 | 0, 97 | 0 98 | ); 99 | } 100 | } 101 | } 102 | ); 103 | }; 104 | -------------------------------------------------------------------------------- /src/Commands/Admin/GENERAL/PROFIT/index.js: -------------------------------------------------------------------------------- 1 | const moment = require('moment'); 2 | 3 | const messages = require('../../../../Config/messages'); 4 | const chatMessage = require('../../../../Components/message'); 5 | const log = require('../../../../Components/log'); 6 | const Profit = require('../../../../Components/profit'); 7 | const { filterCommands } = require('../../../../Utils'); 8 | const utils = require('../../../../Utils'); 9 | 10 | module.exports = async (sender, msg, client, users) => { 11 | const input = msg.substring('!PROFIT'.length).trim().toUpperCase(); 12 | const language = utils.getLanguage(sender.getSteamID64(), users); 13 | 14 | const period = () => { 15 | switch (utils.getPeriod(input)) { 16 | case 'DAILY': 17 | return { 18 | path: `Daily/${moment().format('DD-MM-YYYY')}`, 19 | period: 'DAILY', 20 | }; 21 | 22 | case 'MONTHLY': 23 | return { 24 | path: `Monthly/${moment().format('MM-YYYY')}`, 25 | period: 'MONTHLY', 26 | }; 27 | 28 | case 'YEARLY': 29 | return { 30 | path: `Yearly/${moment().format('YYYY')}`, 31 | period: 'YEARLY', 32 | }; 33 | 34 | default: 35 | return { 36 | path: `Monthly/${moment().format('MM-YYYY')}`, 37 | period: 'MONTHLY', 38 | }; 39 | } 40 | }; 41 | 42 | try { 43 | log.adminChat(sender.getSteamID64(), language, `[ !PROFIT ${input} ]`); 44 | chatMessage(client, sender, messages.REQUEST[language]); 45 | 46 | const profit = await Profit.read(period().path); 47 | let message = '/pre '; 48 | 49 | message += messages.PROFIT.RESPONSE[0][period().period][language]; 50 | message += messages.PROFIT.RESPONSE[1][language].replace( 51 | '{AMOUNT}', 52 | profit.totaltrades 53 | ); 54 | if (profit.status.sets > 0) { 55 | message += messages.PROFIT.SETS[language] 56 | .replace('{STATUS}', messages.PROFIT.PROFITED[language]) 57 | .replace('{AMOUNT}', profit.status.sets); 58 | } 59 | if (profit.status.csgo > 0) { 60 | message += messages.PROFIT.CSGO[language] 61 | .replace('{STATUS}', messages.PROFIT.PROFITED[language]) 62 | .replace('{AMOUNT}', profit.status.csgo); 63 | } 64 | if (profit.status.hydra > 0) { 65 | message += messages.PROFIT.HYDRA[language] 66 | .replace('{STATUS}', messages.PROFIT.PROFITED[language]) 67 | .replace('{AMOUNT}', profit.status.hydra); 68 | } 69 | if (profit.status.tf > 0) { 70 | message += messages.PROFIT.TF[language] 71 | .replace('{STATUS}', messages.PROFIT.PROFITED[language]) 72 | .replace('{AMOUNT}', profit.status.tf); 73 | } 74 | if (profit.status.gems > 0) { 75 | message += messages.PROFIT.GEMS[language] 76 | .replace('{STATUS}', messages.PROFIT.PROFITED[language]) 77 | .replace('{AMOUNT}', profit.status.gems); 78 | } 79 | message += messages.PROFIT.RESPONSE[2][language] 80 | .replace('{SETS1}', profit.sell.csgo.sets) 81 | .replace('{SETS2}', profit.sell.hydra.sets) 82 | .replace('{SETS3}', profit.sell.gems.sets) 83 | .replace('{SETS4}', profit.sell.tf.sets) 84 | .replace('{SETS5}', profit.buy.csgo.sets) 85 | .replace('{SETS6}', profit.buy.hydra.sets) 86 | .replace('{SETS7}', profit.buy.tf.sets) 87 | .replace('{SETS8}', profit.buy.gems.sets) 88 | .replace('{CSGOSELL}', profit.sell.csgo.currency) 89 | .replace('{HYDRASELL}', profit.sell.hydra.currency) 90 | .replace('{TFSELL}', profit.sell.tf.currency) 91 | .replace('{GEMSSELL}', profit.sell.gems.currency) 92 | .replace('{CSGOBUY}', profit.buy.csgo.currency) 93 | .replace('{HYDRABUY}', profit.buy.hydra.currency) 94 | .replace('{TFBUY}', profit.buy.tf.currency) 95 | .replace('{GEMSBUY}', profit.buy.gems.currency); 96 | 97 | message = filterCommands(message).join('\n'); 98 | 99 | chatMessage(client, sender, message); 100 | } catch (error) { 101 | log.error(`An error occurred while getting profit: ${error}`); 102 | chatMessage(client, sender, messages.PROFIT.ERROR[language]); 103 | } 104 | }; 105 | -------------------------------------------------------------------------------- /src/Components/user.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-restricted-syntax */ 2 | const fs = require('graceful-fs'); 3 | const log = require('./log'); 4 | const main = require('../Config/main'); 5 | const messages = require('../Config/messages'); 6 | const chatMessage = require('./message'); 7 | const { getDefaultLanguage } = require('../Utils'); 8 | const utils = require('../Utils'); 9 | 10 | const read = () => { 11 | let users = {}; 12 | if (!fs.existsSync('./Data/User/Users.json')) { 13 | fs.writeFile( 14 | './Data/User/Users.json', 15 | JSON.stringify(users), 16 | { 17 | flags: 'w', 18 | }, 19 | (ERR) => { 20 | if (ERR) { 21 | log.error(`An error occurred while writing UserData file: ${ERR}`); 22 | } 23 | } 24 | ); 25 | } else { 26 | try { 27 | users = JSON.parse(fs.readFileSync('./Data/User/Users.json')); 28 | } catch (error) { 29 | log.error(`An error occurred while getting UserData file: ${error}`); 30 | } 31 | } 32 | return users; 33 | }; 34 | 35 | const inactive = (client, users) => { 36 | const listUsers = users; 37 | function addUsers(obj, prop) { 38 | const user = obj; 39 | for (const p of prop) { 40 | user[p] = {}; 41 | user[p].idleforhours = 0; 42 | user[p].language = getDefaultLanguage(); 43 | } 44 | } 45 | 46 | function deleteUsers(obj, prop) { 47 | const user = obj; 48 | for (const p of prop) { 49 | if (p in user) delete user[p]; 50 | } 51 | } 52 | setInterval(() => { 53 | const c = []; 54 | const a = []; 55 | for (let i = 0; i < Object.keys(client.myFriends).length; i += 1) { 56 | if ( 57 | Object.prototype.hasOwnProperty.call( 58 | listUsers, 59 | Object.keys(client.myFriends)[i] 60 | ) === false 61 | ) { 62 | a.push(Object.keys(client.myFriends)[i]); 63 | } 64 | } 65 | if (a.length > 0) { 66 | addUsers(listUsers, a); 67 | } 68 | for (let i = 0; i < Object.keys(listUsers).length; i += 1) { 69 | if ( 70 | client.myFriends[Object.keys(listUsers)[i]] === undefined || 71 | client.myFriends[Object.keys(listUsers)[i]] === 5 72 | ) { 73 | c.push(Object.keys(listUsers)[i]); 74 | } 75 | if ( 76 | listUsers[Object.keys(listUsers)[i]].idleforhours >= 77 | main.maxDaysAdded * 24 && 78 | !main.admins.includes(Object.keys(listUsers)[i]) 79 | ) { 80 | chatMessage( 81 | client, 82 | Object.keys(listUsers)[i], 83 | messages.INACTIVE[ 84 | utils.getLanguage(Object.keys(listUsers)[i], listUsers) 85 | ] 86 | ); 87 | client.removeFriend(Object.keys(listUsers)[i]); 88 | c.push(Object.keys(listUsers)[i]); 89 | } else { 90 | listUsers[Object.keys(listUsers)[i]].idleforhours += 1; 91 | } 92 | } 93 | if (c.length > 0) { 94 | deleteUsers(listUsers, c); 95 | } 96 | fs.writeFile('./Data/User/Users.json', JSON.stringify(listUsers), (ERR) => { 97 | if (ERR) { 98 | log.error(`An error occurred while writing UserData file: ${ERR}`); 99 | } 100 | }); 101 | }, 1000 * 60 * 60); 102 | }; 103 | 104 | const spam = (client, users, userMsgs) => { 105 | for (let i = 0; i < Object.keys(userMsgs).length; i += 1) { 106 | if (userMsgs[Object.keys(userMsgs)[i]] === main.maxMsgPerSec) { 107 | chatMessage( 108 | client, 109 | Object.keys(userMsgs)[i], 110 | messages.SPAM[0][utils.getLanguage(Object.keys(userMsgs)[i], users)] 111 | ); 112 | } else if (userMsgs[Object.keys(userMsgs)[i]] > main.maxMsgPerSec) { 113 | chatMessage( 114 | client, 115 | Object.keys(userMsgs)[i], 116 | messages.SPAM[1][utils.getLanguage(Object.keys(userMsgs)[i], users)] 117 | ); 118 | client.removeFriend(Object.keys(userMsgs)[i]); 119 | for (let j = 0; j < main.admins.length; j += 1) { 120 | chatMessage( 121 | client, 122 | main.admins[j], 123 | messages.SPAM[2][utils.getLanguage(main.admins[j], users)].replace( 124 | '{STEAMID64}', 125 | Object.keys(userMsgs)[i] 126 | ) 127 | ); 128 | } 129 | } 130 | } 131 | 132 | return {}; 133 | }; 134 | 135 | module.exports = { 136 | inactive, 137 | read, 138 | spam, 139 | }; 140 | -------------------------------------------------------------------------------- /TUTORIAL.md: -------------------------------------------------------------------------------- 1 | # Linux (ubuntu) 2 | ## 1° Update ubuntu 3 |
4 | sudo apt update && sudo apt upgrade 5 |6 | 7 | ## 2° Install Node.js 8 |
9 | curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash - 10 | 11 | sudo apt-get install -y nodejs 12 |13 | 14 | ## 3° Download Bot files 15 |
16 | git clone https://github.com/Luc4sguilherme/Steam-levelup-BOT.git 17 |18 | 19 | ## 4° Install dependencies 20 |
21 | cd Steam-levelup-BOT 22 | 23 | npm install --production --force 24 |25 | 26 | ## 5° Getting your
shared_secret & identity_secret:
27 | - Read for information: Link
28 | - DO NOT SHARE YOUR CODES WITH ANYONE!!! These codes serve as your mobile authenticator, if someone that knows what they are doing gets a hold of these codes they could effectively take control of your account! Keep these codes completely private!
29 |
30 | ## 6° Create Steam Api Key
31 | 32 | https://steamcommunity.com/dev/apikey 33 |34 | 35 | ## 7° Create Steamladder Api Key 36 |
37 | https://steamladder.com/user/settings/api 38 |39 | 40 | ## 8° Setting the bot 41 | 42 | -
cd src/Config
43 |
44 | - mv main.example.js main.js
45 |
46 | - vim main.js
47 |
48 | - Press the key i
49 |
50 | - Fill in all empty fields
51 |
52 | - Press the key ESC
53 |
54 | - Type in keyboard :wq
55 |
56 | - Press Enter
57 |
58 | ## 9° Starting
59 | 60 | cd ~/Steam-levelup-BOT 61 | 62 | nohup npm start > log.txt 2> err.txt & 63 |64 | 65 | ## 10° Logs monitoring 66 |
67 | tail -f log.txt 68 | 69 | tail -f err.txt 70 |71 | 72 | 73 | 74 | # Windows 10 75 | ## 1° Install Node.js 76 |
77 | https://nodejs.org/dist/v14.17.4/node-v14.17.4-x64.msi 78 |79 | 80 | ## 2° Download Bot files 81 |
https://github.com/Luc4sguilherme/Steam-levelup-BOT/archive/master.zip82 | 83 | ## 3° Install dependencies 84 | - Unzip 85 | - run
install file
86 |
87 | ## 4° Install Steam Desktop Authenticator
88 | 89 | https://github.com/Jessecar96/SteamDesktopAuthenticator/archive/master.zip 90 |91 | 92 | ## 5° Setting Steam Desktop Authenticator 93 | - Click in
Setup New Account Button
94 | - Fill in the fields with the bot's steam account information
95 |
96 | ## 6° Getting your shared_secret & identity_secret:
97 | - Go to the SDA (Steam Desktop Authenticator) directory. If you have encryption disabled go to step 3.
98 | - Open SDA and hit "Manage Encryption". Fill in your encryption key and when asked to create a new one leave the text box blank. This will disable encryption.
99 | - Head over to the maFiles folder and open the file named after your accounts SteamID64.
100 | - Search the file for shared_secret:"XXXXXXXXXXXXXX=", instead of XXX it should have a code there, it always ends with =
101 | - Do the same for identity_secret, it will look similar.
102 | - DO NOT SHARE YOUR CODES WITH ANYONE!!! These codes serve as your mobile authenticator, if someone that knows what they are doing gets a hold of these codes they could effectively take control of your account! Keep these codes completely private!
103 |
104 | ## 7° Create Steam Api Key
105 | 106 | https://steamcommunity.com/dev/apikey 107 |108 | 109 | ## 8° Create Steamladder Api Key 110 |
111 | https://steamladder.com/user/settings/api 112 |113 | 114 | ## 9° Setting the bot 115 | - Navigate to
src/Config
116 | - Rename the main.example.js file to main.js
117 | - Open the main.js file
118 | - Fill in all empty fields
119 |
120 |
121 | ## 10° Starting
122 | - run start file
123 |
--------------------------------------------------------------------------------
/src/Commands/User/GENERAL/LEVEL/index.js:
--------------------------------------------------------------------------------
1 | const chatMessage = require('../../../../Components/message');
2 | const main = require('../../../../Config/main');
3 | const messages = require('../../../../Config/messages');
4 | const rates = require('../../../../Config/rates');
5 | const utils = require('../../../../Utils');
6 | const log = require('../../../../Components/log');
7 | const { filterCommands } = require('../../../../Utils');
8 |
9 | module.exports = (sender, msg, client, users) => {
10 | const language = utils.getLanguage(sender.getSteamID64(), users);
11 | const n = parseInt(msg.toUpperCase().replace('!LEVEL ', ''), 10);
12 | if (!Number.isNaN(n) && parseInt(n, 10) > 0) {
13 | log.userChat(sender.getSteamID64(), language, `[ !LEVEL ${n} ]`);
14 | if (n <= main.maxLevel) {
15 | utils.getBadges(
16 | sender.getSteamID64(),
17 | (ERR, DATA, CURRENTLEVEL, CURRENTLEVELXP) => {
18 | if (!ERR) {
19 | if (DATA) {
20 | if (CURRENTLEVEL >= 0) {
21 | if (n > CURRENTLEVEL) {
22 | let s = 0;
23 | let l = 0;
24 | for (let i = 0; i < n - CURRENTLEVEL; i += 1) {
25 | s += parseInt((CURRENTLEVEL + l) / 10, 10) + 1;
26 | l += 1;
27 | }
28 | const cs = Math.ceil(
29 | parseInt(
30 | ((s - Math.floor(CURRENTLEVELXP / 100)) /
31 | rates.csgo.sell) *
32 | 100,
33 | 10
34 | ) / 100
35 | );
36 | const hydra = Math.ceil(
37 | parseInt(
38 | ((s - Math.floor(CURRENTLEVELXP / 100)) /
39 | rates.hydra.sell) *
40 | 100,
41 | 10
42 | ) / 100
43 | );
44 | const tf = Math.ceil(
45 | parseInt(
46 | ((s - Math.floor(CURRENTLEVELXP / 100)) / rates.tf.sell) *
47 | 100,
48 | 10
49 | ) / 100
50 | );
51 | const gems = parseInt(
52 | (s - Math.floor(CURRENTLEVELXP / 100)) * rates.gems.sell,
53 | 10
54 | );
55 | chatMessage(
56 | client,
57 | sender,
58 | filterCommands(
59 | messages.LEVEL.RESPONSE[language]
60 |
61 | .replace('{level}', n)
62 | .replace(
63 | '{sets1}',
64 | s - Math.floor(CURRENTLEVELXP / 100)
65 | )
66 | .replace('{sets2}', cs * rates.csgo.sell)
67 | .replace('{sets3}', hydra * rates.hydra.sell)
68 | .replace('{sets4}', tf * rates.tf.sell)
69 | .replace(
70 | /{sets5}/g,
71 | s - Math.floor(CURRENTLEVELXP / 100)
72 | )
73 | .replace(/{cs}/g, cs)
74 | .replace(/{hydra}/g, hydra)
75 | .replace(/{tf}/g, tf)
76 | .replace('{gems}', gems)
77 | ).join('\n')
78 | );
79 | } else {
80 | chatMessage(
81 | client,
82 | sender,
83 | messages.ERROR.INPUT.AMOUNTLOW.LEVEL[language]
84 | );
85 | }
86 | } else {
87 | chatMessage(client, sender, messages.ERROR.LEVEL[1][language]);
88 | }
89 | } else {
90 | chatMessage(client, sender, messages.ERROR.LEVEL[0][language]);
91 | }
92 | } else {
93 | log.error(`An error occurred while getting badge data: ${ERR}`);
94 | chatMessage(client, sender, messages.ERROR.BADGES[1][language]);
95 | }
96 | }
97 | );
98 | } else {
99 | chatMessage(
100 | client,
101 | sender,
102 | messages.ERROR.INPUT.AMOUNTOVER.LEVEL[language].replace(
103 | '{LEVEL}',
104 | main.maxLevel
105 | )
106 | );
107 | }
108 | } else {
109 | chatMessage(client, sender, messages.ERROR.INPUT.INVALID.LEVEL[language]);
110 | }
111 | };
112 |
--------------------------------------------------------------------------------
/src/Commands/User/GEMS/CHECK/index.js:
--------------------------------------------------------------------------------
1 | const chatMessage = require('../../../../Components/message');
2 | const main = require('../../../../Config/main');
3 | const messages = require('../../../../Config/messages');
4 | const rates = require('../../../../Config/rates');
5 | const utils = require('../../../../Utils');
6 | const log = require('../../../../Components/log');
7 |
8 | module.exports = (sender, msg, client, users) => {
9 | const language = utils.getLanguage(sender.getSteamID64(), users);
10 | const n = parseInt(msg.toUpperCase().replace('!CHECKGEMS ', ''), 10);
11 |
12 | if (!Number.isNaN(n) && parseInt(n, 10) > 0) {
13 | if (n >= rates.gems.sell) {
14 | log.userChat(sender.getSteamID64(), language, `[ !CHECKGEMS ${n} ]`);
15 | if (main.maxCheck.gems >= n) {
16 | utils.getBadges(
17 | sender.getSteamID64(),
18 | (ERR, DATA, CURRENTLEVEL, CURRENTLEVELXP, TOTALXP) => {
19 | if (!ERR) {
20 | if (DATA) {
21 | if (CURRENTLEVEL >= 0) {
22 | const c = utils.getLevelExp(CURRENTLEVEL + 1);
23 | const d = (c - TOTALXP) / 100;
24 | const xpWon = (100 * n) / rates.gems.sell;
25 | const totalExp = TOTALXP + xpWon;
26 | let i = parseInt(CURRENTLEVEL, 10) - 1;
27 | let can = 0;
28 | do {
29 | i += 1;
30 | if (i - 1 > main.maxLevel) {
31 | chatMessage(
32 | client,
33 | sender,
34 | messages.ERROR.INPUT.AMOUNTOVER.GEMS[language].replace(
35 | '{GEMS}',
36 | main.maxCheck.gems
37 | )
38 | );
39 | can += 1;
40 | break;
41 | }
42 | } while (utils.getLevelExp(i) <= totalExp);
43 | if (!can) {
44 | const a = parseInt(n / rates.gems.sell, 10);
45 | let b;
46 | if (
47 | CURRENTLEVEL === 0 ||
48 | CURRENTLEVELXP === 0 ||
49 | d > n / rates.gems.sell ||
50 | d <= parseInt(n / rates.gems.sell, 10)
51 | ) {
52 | b = i - 1;
53 | } else {
54 | b = i - 2;
55 | }
56 | if (CURRENTLEVEL !== b) {
57 | chatMessage(
58 | client,
59 | sender,
60 | messages.CHECK.GEMS[0][language]
61 | .replace('{GEMS}', n)
62 | .replace(/{SETS}/g, a)
63 | .replace('{LEVEL}', b)
64 | );
65 | } else {
66 | chatMessage(
67 | client,
68 | sender,
69 | messages.CHECK.GEMS[1][language]
70 | .replace('{GEMS}', n)
71 | .replace(/{SETS}/g, a)
72 | .replace('{LEVEL}', b)
73 | );
74 | }
75 | }
76 | } else {
77 | chatMessage(
78 | client,
79 | sender,
80 | messages.ERROR.LEVEL[1][language]
81 | );
82 | }
83 | } else {
84 | chatMessage(client, sender, messages.ERROR.LEVEL[0][language]);
85 | }
86 | } else {
87 | log.error(`An error occurred while getting badge data: ${ERR}`);
88 | chatMessage(client, sender, messages.ERROR.BADGES[1][language]);
89 | }
90 | }
91 | );
92 | } else {
93 | chatMessage(
94 | client,
95 | sender,
96 | messages.ERROR.INPUT.AMOUNTOVER.GEMS[language].replace(
97 | '{GEMS}',
98 | main.maxCheck.gems
99 | )
100 | );
101 | }
102 | } else {
103 | chatMessage(
104 | client,
105 | sender,
106 | messages.ERROR.INPUT.AMOUNTLOW.GEMS[language]
107 | );
108 | }
109 | } else {
110 | chatMessage(
111 | client,
112 | sender,
113 | messages.ERROR.INPUT.INVALID.GEMS[language].replace(
114 | '{command}',
115 | `!CHECKGEMS ${rates.gems.sell}`
116 | )
117 | );
118 | }
119 | };
120 |
--------------------------------------------------------------------------------
/src/Config/main.example.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // Bot Steam Username
3 | userName: '',
4 |
5 | // Bot Steam Password
6 | passWord: '',
7 |
8 | // Bot Steam ID64
9 | steamID: '',
10 |
11 | // Bot Shared Secret for your Bot account (SDA)
12 | sharedSecret: '',
13 |
14 | // Bot Identity Secret for your Bot account (SDA)
15 | identitySecret: '',
16 |
17 | // Bot Steam API Key
18 | steamApiKey: '',
19 |
20 | // Steamladder API Key
21 | steamLadderApiKey: '',
22 |
23 | // Steam.supply support to setup your bot in cardbot catalog list!
24 | steamSupply: {
25 | apiKey: '',
26 | updateCardDB: false,
27 | updateCatalog: false,
28 | },
29 |
30 | // You can add multiple Administrators - example [ "SteamID64", "SteamID64" ]
31 | admins: [''],
32 |
33 | // Owners Profile link
34 | owner: '',
35 |
36 | // Video tutorial
37 | tutorial: '',
38 |
39 | // Leave blank to use local computer time
40 | timeZone: 'America/Sao_Paulo',
41 |
42 | // Set to true if you want bot to accept any donations (true or false)
43 | acceptDonations: true,
44 |
45 | // Setup bot to only handle foil cards instead of normal ones, it will also make bot recognize normal cards as leftovers.
46 | foilMode: false,
47 |
48 | // Setup the commands you want the bot to ignore
49 | ignoreCommands: [''],
50 |
51 | // Setup the currencies you want the bot to accept
52 | acceptedCurrencies: {
53 | TF2: true,
54 | CSGO: true,
55 | GEMS: true,
56 | HYDRA: true,
57 | },
58 |
59 | // Set to true if you want to handle suppliers (!SELL commands).
60 | handleSuppliers: true,
61 |
62 | // Setup the languages you want the bot to accept. Values ( true or false or 'DEFAULT' )
63 | // Set the value to 'DEFAULT' to be the primary language
64 | acceptedLanguages: {
65 | EN: 'DEFAULT',
66 | PT: true,
67 | ES: true,
68 | FR: true,
69 | DE: true,
70 | RU: true,
71 | JA: true,
72 | CN: true,
73 | },
74 |
75 | steamGroup: {
76 | // Set to true if you want to invite customers to a desired GroupID64
77 | doInvites: true,
78 | // Target Group link
79 | link: '',
80 | // Target Group ID64
81 | ID: '',
82 | // if you want to auto refuse all group invites, set this to true
83 | refuseInvites: true,
84 | },
85 |
86 | // If you want to automatically add rates to the bot name on startups, set to true, false otherwise. (It is necessary to define the botName variable)
87 | ratesInBotName: {
88 | status: false,
89 | currency: 'CSGO',
90 | },
91 |
92 | // Defines the name of the BOT on initializations.
93 | botName: '',
94 |
95 | // Set to true if you want to be warned in your steam chat about every sell/buy bot does
96 | getTradeMessages: true,
97 |
98 | comment: {
99 | // Set to true if you want the bot to comment on customers profile
100 | enabled: true,
101 | // Interval between user profile comments after negotiation. (in hours)
102 | interval: 24,
103 | },
104 |
105 | // Max days an customer can be on friend list without interact with bot.
106 | maxDaysAdded: 180,
107 |
108 | // The amount of messages users can send every second without getting removed.
109 | maxMsgPerSec: 2,
110 |
111 | // Max amount of sets, of each appid, that bot will try to buy
112 | maxStock: 15,
113 |
114 | // Max level you can request using !level
115 | maxLevel: 6666,
116 |
117 | // Max amount of sets that will be allowed in a trade
118 | maxBuy: 2500,
119 | maxSell: 1000,
120 |
121 | // Max amount of sets that will be allowed in a trade
122 | maxSets4Sets: 100,
123 |
124 | // Max amount that will be allowed in check commands
125 | maxCheck: {
126 | csgo: 10000,
127 | gems: 1000000,
128 | tf: 10000,
129 | hydra: 10000,
130 | },
131 |
132 | // Set to true to display logs, although even if this is false, logs will be saved on history folder...
133 | log: {
134 | warn: {
135 | enabled: true,
136 | color: 'yellowBright',
137 | },
138 | error: {
139 | enabled: true,
140 | color: 'redBright',
141 | },
142 | info: {
143 | enabled: true,
144 | color: 'greenBright',
145 | },
146 | userChat: {
147 | enabled: true,
148 | color: 'whiteBright',
149 | },
150 | adminChat: {
151 | enabled: true,
152 | color: 'blackBright',
153 | },
154 | tradeOffer: {
155 | enabled: true,
156 | color: 'blueBright',
157 | },
158 | },
159 |
160 | requester: {
161 | // Max amount of sets each trade will try to request to target
162 | amount: 100,
163 | // You can add multiple Target - example [ "SteamID64", "SteamID64" ]
164 | steamID64: [''],
165 | // Timer interval of requester in hours
166 | inverval: 24,
167 | // Set to true if you want to ignore the "maxStock"
168 | ignoreLimit: true,
169 | // True to send our leftovers
170 | sendLeftOvers: false,
171 | // True to enable, false to otherwise
172 | enabled: false,
173 | },
174 | };
175 |
--------------------------------------------------------------------------------
/src/Commands/Admin/SETS/DEPOSIT/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-restricted-syntax */
2 | const main = require('../../../../Config/main');
3 | const messages = require('../../../../Config/messages');
4 | const inventory = require('../../../../Components/inventory');
5 | const utils = require('../../../../Utils');
6 | const chatMessage = require('../../../../Components/message');
7 | const makeOffer = require('../../../../Components/offer');
8 | const { getSets } = require('../../../../Components/sets');
9 | const log = require('../../../../Components/log');
10 |
11 | module.exports = (sender, msg, client, users, community, allCards, manager) => {
12 | const language = utils.getLanguage(sender.getSteamID64(), users);
13 | const dataInput = msg.toUpperCase().replace('!DEPOSITSETS ', '');
14 | let amountofsets;
15 | let ignoreMaxStock = 0;
16 | if (dataInput.search(',') !== -1) {
17 | amountofsets = parseInt(dataInput.substring(0, dataInput.indexOf(',')), 10);
18 | ignoreMaxStock = parseInt(
19 | dataInput.substring(dataInput.indexOf(',') + 1),
20 | 10
21 | );
22 | } else {
23 | amountofsets = parseInt(dataInput, 10);
24 | }
25 |
26 | if (!Number.isNaN(amountofsets) && parseInt(amountofsets, 10) > 0) {
27 | log.adminChat(
28 | sender.getSteamID64(),
29 | language,
30 | `[ !DEPOSITSETS ${amountofsets} ]`
31 | );
32 | chatMessage(client, sender, messages.REQUEST[language]);
33 | let amountofB = amountofsets;
34 | inventory.getInventory(sender.getSteamID64(), community, (ERR1, DATA1) => {
35 | if (!ERR1) {
36 | const s = DATA1;
37 | const theirSets = [];
38 | getSets(s, allCards, (ERR2, DDATA) => {
39 | if (!ERR2) {
40 | utils.sortSetsByAmount(s, (DATA2) => {
41 | const setsSent = {};
42 | firsttLoop: for (let i = 0; i < DATA2.length; i += 1) {
43 | if (DDATA[DATA2[i]]) {
44 | for (let j = 0; j < DDATA[DATA2[i]].length; j += 1) {
45 | if (amountofB > 0) {
46 | if (!setsSent[DATA2[i]]) {
47 | setsSent[DATA2[i]] = 0;
48 | }
49 | if (
50 | ignoreMaxStock ||
51 | setsSent[DATA2[i]] +
52 | (inventory.botSets[DATA2[i]]
53 | ? inventory.botSets[DATA2[i]].length
54 | : 0) <
55 | main.maxStock
56 | ) {
57 | theirSets.push(DDATA[DATA2[i]][j]);
58 | amountofB -= 1;
59 | setsSent[DATA2[i]] += 1;
60 | } else {
61 | continue firsttLoop;
62 | }
63 | } else {
64 | continue firsttLoop;
65 | }
66 | }
67 | } else {
68 | continue;
69 | }
70 | }
71 | });
72 | if (amountofB > 0) {
73 | chatMessage(
74 | client,
75 | sender,
76 | messages.ERROR.OUTOFSTOCK.DEFAULT.SETS.THEM[0][language]
77 | );
78 | } else {
79 | const message = messages.TRADE.SETMESSAGE[0].SETS[
80 | language
81 | ].replace('{SETS}', amountofsets);
82 | makeOffer(
83 | client,
84 | users,
85 | manager,
86 | sender.getSteamID64(),
87 | [],
88 | [].concat(...theirSets),
89 | '!DEPOSITSETS',
90 | message,
91 | amountofsets,
92 | 0,
93 | 0,
94 | 0
95 | );
96 | }
97 | } else {
98 | chatMessage(
99 | client,
100 | sender,
101 | messages.ERROR.LOADINVENTORY.THEM[0][language]
102 | );
103 | log.error(`An error occurred while getting user sets: ${ERR2}`);
104 | }
105 | });
106 | } else if (ERR1.message.indexOf('profile is private') > -1) {
107 | chatMessage(
108 | client,
109 | sender,
110 | messages.ERROR.LOADINVENTORY.THEM[2][language]
111 | );
112 | log.error(`An error occurred while getting user inventory: ${ERR1}`);
113 | } else {
114 | chatMessage(
115 | client,
116 | sender,
117 | messages.ERROR.LOADINVENTORY.THEM[0][language]
118 | );
119 | log.error(`An error occurred while getting user inventory: ${ERR1}`);
120 | }
121 | });
122 | } else {
123 | chatMessage(
124 | client,
125 | sender,
126 | messages.ERROR.INPUT.INVALID.SETS[language].replace(
127 | '{command}',
128 | '!DEPOSITSETS 1'
129 | )
130 | );
131 | }
132 | };
133 |
--------------------------------------------------------------------------------
/src/Commands/User/GENERAL/CHECKONE/index.js:
--------------------------------------------------------------------------------
1 | const messages = require('../../../../Config/messages');
2 | const rates = require('../../../../Config/rates');
3 | const utils = require('../../../../Utils');
4 | const inventory = require('../../../../Components/inventory');
5 | const chatMessage = require('../../../../Components/message');
6 | const log = require('../../../../Components/log');
7 | const { filterCommands } = require('../../../../Utils');
8 |
9 | module.exports = (sender, client, users) => {
10 | const language = utils.getLanguage(sender.getSteamID64(), users);
11 |
12 | chatMessage(client, sender, messages.REQUEST[language]);
13 | log.userChat(sender.getSteamID64(), language, '[ !CHECKONE ]');
14 | utils.getBadges(
15 | sender.getSteamID64(),
16 | (ERR, DATA, CURRENTLEVEL, _, TOTALXP) => {
17 | if (!ERR) {
18 | const badges = {}; // List with badges that CAN still be crafted
19 | if (DATA) {
20 | for (let i = 0; i < Object.keys(DATA).length; i += 1) {
21 | if (DATA[Object.keys(DATA)[i]] < 6) {
22 | badges[Object.keys(DATA)[i]] = 5 - DATA[Object.keys(DATA)[i]];
23 | }
24 | }
25 |
26 | let hisMaxSets = 0;
27 |
28 | // Loop for sets he has never crafted
29 | for (let i = 0; i < Object.keys(inventory.botSets).length; i += 1) {
30 | if (
31 | Object.keys(badges).indexOf(Object.keys(inventory.botSets)[i]) < 0
32 | ) {
33 | if (
34 | inventory.botSets[Object.keys(inventory.botSets)[i]].length >= 1
35 | ) {
36 | hisMaxSets += 1;
37 | }
38 | }
39 | }
40 | if (hisMaxSets) {
41 | const cs = parseInt(hisMaxSets / rates.csgo.sell, 10);
42 | const hydra = parseInt(hisMaxSets / rates.hydra.sell, 10);
43 | const tf = parseInt(hisMaxSets / rates.tf.sell, 10);
44 | const gems = parseInt(hisMaxSets * rates.gems.sell, 10);
45 | let message = ' ';
46 | if (cs > 0) {
47 | message += messages.CHECKONE.CURRENCIES.CSGO[language]
48 | .replace(/{CSGO}/g, cs)
49 | .replace('{SETS1}', cs * rates.csgo.sell);
50 | }
51 | if (hydra > 0) {
52 | message += messages.CHECKONE.CURRENCIES.HYDRA[language]
53 | .replace(/{HYDRA}/g, hydra)
54 | .replace('{SETS2}', hydra * rates.hydra.sell);
55 | }
56 | if (tf > 0) {
57 | message += messages.CHECKONE.CURRENCIES.TF[language]
58 | .replace(/{TF}/g, tf)
59 | .replace('{SETS3}', tf * rates.tf.sell);
60 | }
61 | if (parseInt(hisMaxSets, 10) > 0) {
62 | message += messages.CHECKONE.CURRENCIES.GEMS[language]
63 | .replace('{GEMS}', gems)
64 | .replace('{SETS4}', hisMaxSets)
65 | .replace('{SETS5}', parseInt(hisMaxSets, 10));
66 | }
67 |
68 | message = filterCommands(message).join('\n');
69 |
70 | if (!message.includes('•')) {
71 | chatMessage(
72 | client,
73 | sender,
74 | messages.ERROR.OUTOFSTOCK.DEFAULT.SETS.US[1][language]
75 | );
76 | return;
77 | }
78 |
79 | if (CURRENTLEVEL >= 0) {
80 | const xpWon = 100 * hisMaxSets;
81 | const totalExp = TOTALXP + xpWon;
82 | let i = parseInt(CURRENTLEVEL, 10) - 1;
83 | do {
84 | i += 1;
85 | } while (utils.getLevelExp(i) <= totalExp);
86 | if (CURRENTLEVEL !== i - 1) {
87 | chatMessage(
88 | client,
89 | sender,
90 | messages.CHECKONE.RESPONSE[0][language]
91 | .replace('{SETS}', hisMaxSets)
92 | .replace('{LEVEL}', i - 1)
93 | .replace('{MESSAGE}', message)
94 | );
95 | } else {
96 | chatMessage(
97 | client,
98 | sender,
99 | messages.CHECKONE.RESPONSE[1][language]
100 | .replace('{SETS}', hisMaxSets)
101 | .replace('{LEVEL}', i - 1)
102 | .replace('{MESSAGE}', message)
103 | );
104 | }
105 | } else {
106 | chatMessage(client, sender, messages.ERROR.LEVEL[1][language]);
107 | }
108 | } else {
109 | chatMessage(
110 | client,
111 | sender,
112 | messages.ERROR.OUTOFSTOCK.DEFAULT.SETS.US[1][language]
113 | );
114 | }
115 | } else {
116 | chatMessage(client, sender, messages.ERROR.BADGES[0][language]);
117 | }
118 | } else {
119 | chatMessage(client, sender, messages.ERROR.BADGES[1][language]);
120 | log.error(`An error occurred while getting badges: ${ERR}`);
121 | }
122 | }
123 | );
124 | };
125 |
--------------------------------------------------------------------------------
/src/Components/profit/index.js:
--------------------------------------------------------------------------------
1 | const fs = require('graceful-fs');
2 | const moment = require('moment');
3 | const _ = require('lodash');
4 |
5 | const utils = require('../../Utils');
6 | const log = require('../log');
7 |
8 | const Profit = require('./constants/profit');
9 |
10 | const init = async (period) => {
11 | try {
12 | if (!fs.existsSync(`./Data/History/Profit/${period}.json`)) {
13 | await utils.writeFileAsync(
14 | `./Data/History/Profit/${period}.json`,
15 | JSON.stringify(Profit),
16 | {
17 | flags: 'w',
18 | }
19 | );
20 | }
21 | } catch (error) {
22 | log.error(`An error occurred while initializing profit file: ${error}`);
23 | }
24 | };
25 |
26 | const read = async (period) => {
27 | await init(period);
28 |
29 | return JSON.parse(
30 | await utils.readFileAsync(`./Data/History/Profit/${period}.json`)
31 | );
32 | };
33 |
34 | const write = async (profit, period) => {
35 | try {
36 | const add = (a, b) => _.defaultTo(_.add(a, b), undefined);
37 | const data = await read(period);
38 | const profited = _.mergeWith({}, data, profit, add);
39 |
40 | await utils.writeFileAsync(
41 | `./Data/History/Profit/${period}.json`,
42 | JSON.stringify(profited)
43 | );
44 | } catch (error) {
45 | log.error(`An error occurred while writing profit file: ${error}`);
46 | }
47 | };
48 |
49 | const calculate = async (offer) => {
50 | try {
51 | const profit = _.cloneDeep(Profit);
52 |
53 | if (offer.data('commandused').search(/BUY/) !== -1) {
54 | profit.totaltrades += 1;
55 | if (offer.data('commandused').search(/CSGO/) !== -1) {
56 | profit.buy.csgo.sets += parseInt(offer.data('amountofsets'), 10);
57 | profit.buy.csgo.currency += parseInt(offer.data('amountofkeys'), 10);
58 | profit.status.csgo += parseInt(offer.data('amountofkeys'), 10);
59 | profit.status.sets -= parseInt(offer.data('amountofsets'), 10);
60 | }
61 | if (offer.data('commandused').search(/HYDRA/) !== -1) {
62 | profit.buy.hydra.sets += parseInt(offer.data('amountofsets'), 10);
63 | profit.buy.hydra.currency += parseInt(offer.data('amountofkeys'), 10);
64 | profit.status.hydra += parseInt(offer.data('amountofkeys'), 10);
65 | profit.status.sets -= parseInt(offer.data('amountofsets'), 10);
66 | }
67 | if (offer.data('commandused').search(/TF/) !== -1) {
68 | profit.buy.tf.sets += parseInt(offer.data('amountofsets'), 10);
69 | profit.buy.tf.currency += parseInt(offer.data('amountofkeys'), 10);
70 | profit.status.tf += parseInt(offer.data('amountofkeys'), 10);
71 | profit.status.sets -= parseInt(offer.data('amountofsets'), 10);
72 | }
73 | if (offer.data('commandused').search(/GEMS/) !== -1) {
74 | profit.buy.gems.sets += parseInt(offer.data('amountofsets'), 10);
75 | profit.buy.gems.currency += parseInt(offer.data('amountofgems'), 10);
76 | profit.status.gems += parseInt(offer.data('amountofgems'), 10);
77 | profit.status.sets -= parseInt(offer.data('amountofsets'), 10);
78 | }
79 | }
80 | if (offer.data('commandused').search(/SELL/) !== -1) {
81 | profit.totaltrades += 1;
82 | if (offer.data('commandused').search(/CSGO/) !== -1) {
83 | profit.sell.csgo.sets += parseInt(offer.data('amountofsets'), 10);
84 | profit.sell.csgo.currency += parseInt(offer.data('amountofkeys'), 10);
85 | profit.status.csgo -= parseInt(offer.data('amountofkeys'), 10);
86 | profit.status.sets += parseInt(offer.data('amountofsets'), 10);
87 | }
88 | if (offer.data('commandused').search(/HYDRA/) !== -1) {
89 | profit.sell.hydra.sets += parseInt(offer.data('amountofsets'), 10);
90 | profit.sell.hydra.currency += parseInt(offer.data('amountofkeys'), 10);
91 | profit.status.hydra -= parseInt(offer.data('amountofkeys'), 10);
92 | profit.status.sets += parseInt(offer.data('amountofsets'), 10);
93 | }
94 | if (offer.data('commandused').search(/TF/) !== -1) {
95 | profit.sell.tf.sets += parseInt(offer.data('amountofsets'), 10);
96 | profit.sell.tf.currency += parseInt(offer.data('amountofkeys'), 10);
97 | profit.status.tf -= parseInt(offer.data('amountofkeys'), 10);
98 | profit.status.sets += parseInt(offer.data('amountofsets'), 10);
99 | }
100 | if (offer.data('commandused').search(/GEMS/) !== -1) {
101 | profit.sell.gems.sets += parseInt(offer.data('amountofsets'), 10);
102 | profit.sell.gems.currency += parseInt(offer.data('amountofgems'), 10);
103 | profit.status.gems -= parseInt(offer.data('amountofgems'), 10);
104 | profit.status.sets += parseInt(offer.data('amountofsets'), 10);
105 | }
106 | }
107 |
108 | await write(profit, `Daily/${moment().format('DD-MM-YYYY')}`);
109 | await write(profit, `Monthly/${moment().format('MM-YYYY')}`);
110 | await write(profit, `Yearly/${moment().format('YYYY')}`);
111 | } catch (error) {
112 | log.error(`An error occurred while calculating profit: ${error}`);
113 | }
114 | };
115 |
116 | module.exports = { calculate, read };
117 |
--------------------------------------------------------------------------------
/src/Commands/User/GENERAL/SELLCHECK/index.js:
--------------------------------------------------------------------------------
1 | const main = require('../../../../Config/main');
2 | const messages = require('../../../../Config/messages');
3 | const rates = require('../../../../Config/rates');
4 | const inventory = require('../../../../Components/inventory');
5 | const chatMessage = require('../../../../Components/message');
6 | const { getSets } = require('../../../../Components/sets');
7 | const log = require('../../../../Components/log');
8 | const { filterCommands } = require('../../../../Utils');
9 | const utils = require('../../../../Utils');
10 |
11 | module.exports = (sender, client, users, community, allCards) => {
12 | const language = utils.getLanguage(sender.getSteamID64(), users);
13 |
14 | chatMessage(client, sender, messages.REQUEST[language]);
15 | log.userChat(sender.getSteamID64(), language, '[ !SELLCHECK ]');
16 | inventory.getInventory(sender.getSteamID64(), community, (ERR1, DATA) => {
17 | if (!ERR1) {
18 | const s = DATA;
19 | getSets(s, allCards, (ERR2, DDATA) => {
20 | if (!ERR2) {
21 | let userNSets = 0;
22 | for (let i = 0; i < Object.keys(DDATA).length; i += 1) {
23 | if (!inventory.botSets[Object.keys(DDATA)[i]]) {
24 | if (DDATA[Object.keys(DDATA)[i]].length >= main.maxStock) {
25 | userNSets += main.maxStock;
26 | } else {
27 | userNSets += DDATA[Object.keys(DDATA)[i]].length;
28 | }
29 | } else if (
30 | inventory.botSets[Object.keys(DDATA)[i]].length < main.maxStock
31 | ) {
32 | if (DDATA[Object.keys(DDATA)[i]].length >= main.maxStock) {
33 | userNSets +=
34 | main.maxStock -
35 | inventory.botSets[Object.keys(DDATA)[i]].length;
36 | } else if (
37 | DDATA[Object.keys(DDATA)[i]].length +
38 | inventory.botSets[Object.keys(DDATA)[i]].length <=
39 | main.maxStock
40 | ) {
41 | userNSets += DDATA[Object.keys(DDATA)[i]].length;
42 | } else if (DDATA[Object.keys(DDATA)[i]].length > 0) {
43 | userNSets +=
44 | main.maxStock -
45 | inventory.botSets[Object.keys(DDATA)[i]].length;
46 | }
47 | }
48 | }
49 |
50 | if (userNSets) {
51 | const cs = parseInt(userNSets / rates.csgo.buy, 10);
52 | const hydra = parseInt(userNSets / rates.hydra.buy, 10);
53 | const tf = parseInt(userNSets / rates.tf.buy, 10);
54 | const gems = parseInt(userNSets * rates.gems.buy, 10);
55 | let message = ' ';
56 | if (cs > 0) {
57 | message += messages.SELLCHECK.CURRENCIES.CSGO[language]
58 | .replace(/{CSGO}/g, cs)
59 | .replace('{SETS1}', cs * rates.csgo.buy);
60 | }
61 | if (hydra > 0) {
62 | message += messages.SELLCHECK.CURRENCIES.HYDRA[language]
63 | .replace(/{HYDRA}/g, hydra)
64 | .replace('{SETS2}', hydra * rates.hydra.buy);
65 | }
66 | if (tf > 0) {
67 | message += messages.SELLCHECK.CURRENCIES.TF[language]
68 | .replace(/{TF}/g, tf)
69 | .replace('{SETS3}', tf * rates.tf.buy);
70 | }
71 | if (parseInt(userNSets, 10) > 0) {
72 | message += messages.SELLCHECK.CURRENCIES.GEMS[language]
73 | .replace('{GEMS}', gems)
74 | .replace('{SETS4}', userNSets)
75 | .replace('{SETS5}', parseInt(userNSets, 10));
76 | }
77 |
78 | message = filterCommands(message).join('\n');
79 |
80 | if (!message.includes('•')) {
81 | chatMessage(
82 | client,
83 | sender,
84 | messages.ERROR.OUTOFSTOCK.DEFAULT.SETS.THEM[0][language]
85 | );
86 | return;
87 | }
88 |
89 | chatMessage(
90 | client,
91 | sender,
92 | messages.SELLCHECK.RESPONSE[language]
93 | .replace('{SETS}', userNSets)
94 | .replace('{MESSAGE}', message)
95 | );
96 | } else {
97 | chatMessage(
98 | client,
99 | sender,
100 | messages.ERROR.OUTOFSTOCK.DEFAULT.SETS.THEM[0][language]
101 | );
102 | }
103 | } else {
104 | chatMessage(
105 | client,
106 | sender,
107 | messages.ERROR.LOADINVENTORY.THEM[0][language]
108 | );
109 | log.error(`An error occurred while getting user sets: ${ERR2}`);
110 | }
111 | });
112 | } else if (ERR1.message.indexOf('profile is private') > -1) {
113 | chatMessage(
114 | client,
115 | sender,
116 | messages.ERROR.LOADINVENTORY.THEM[2][language]
117 | );
118 | log.error(`An error occurred while getting user inventory: ${ERR1}`);
119 | } else {
120 | chatMessage(
121 | client,
122 | sender,
123 | messages.ERROR.LOADINVENTORY.THEM[0][language]
124 | );
125 | log.error(`An error occurred while getting user inventory: ${ERR1}`);
126 | }
127 | });
128 | };
129 |
--------------------------------------------------------------------------------
/src/Commands/User/TF/BUYANY/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-restricted-syntax */
2 | const main = require('../../../../Config/main');
3 | const messages = require('../../../../Config/messages');
4 | const rates = require('../../../../Config/rates');
5 | const utils = require('../../../../Utils');
6 | const acceptedCurrencies = require('../../../../Config/currencies');
7 | const inventory = require('../../../../Components/inventory');
8 | const chatMessage = require('../../../../Components/message');
9 | const makeOffer = require('../../../../Components/offer');
10 | const log = require('../../../../Components/log');
11 |
12 | module.exports = (sender, msg, client, users, manager) => {
13 | const language = utils.getLanguage(sender.getSteamID64(), users);
14 | const n = parseInt(msg.toUpperCase().replace('!BUYANYTF ', ''), 10);
15 | const amountofsets = n * rates.tf.sell;
16 | const maxKeys = parseInt(main.maxBuy / rates.tf.sell, 10);
17 |
18 | if (!Number.isNaN(n) && n > 0) {
19 | log.userChat(sender.getSteamID64(), language, `[ !BUYANYTF ${n} ]`);
20 | if (n <= maxKeys) {
21 | const theirKeys = [];
22 | const mySets = [];
23 | chatMessage(client, sender, messages.REQUEST[language]);
24 | manager.getUserInventoryContents(
25 | sender.getSteamID64(),
26 | 440,
27 | 2,
28 | true,
29 | (ERR, INV) => {
30 | if (!ERR) {
31 | let amountofB = amountofsets;
32 | for (let i = 0; i < INV.length; i += 1) {
33 | if (
34 | theirKeys.length < n &&
35 | acceptedCurrencies.tf.indexOf(INV[i].market_hash_name) >= 0
36 | ) {
37 | theirKeys.push(INV[i]);
38 | }
39 | }
40 | if (theirKeys.length !== n) {
41 | chatMessage(
42 | client,
43 | sender,
44 | messages.ERROR.OUTOFSTOCK.DEFAULT.TF.THEM[0][language]
45 | );
46 | } else {
47 | utils.sortSetsByAmount(inventory.botSets, (DATA) => {
48 | const setsSent = {};
49 | firstLoop: for (let i = 0; i < DATA.length; i += 1) {
50 | if (inventory.botSets[DATA[i]]) {
51 | for (
52 | let j = 0;
53 | j < inventory.botSets[DATA[i]].length;
54 | j += 1
55 | ) {
56 | if (amountofB > 0) {
57 | if (
58 | (setsSent[DATA[i]] && setsSent[DATA[i]] > -1) ||
59 | !setsSent[DATA[i]]
60 | ) {
61 | mySets.push(inventory.botSets[DATA[i]][j]);
62 | amountofB -= 1;
63 | if (!setsSent[DATA[i]]) {
64 | setsSent[DATA[i]] = 1;
65 | } else {
66 | setsSent[DATA[i]] += 1;
67 | }
68 | } else {
69 | continue firstLoop;
70 | }
71 | } else {
72 | continue firstLoop;
73 | }
74 | }
75 | } else {
76 | continue;
77 | }
78 | }
79 | });
80 | if (amountofB > 0) {
81 | chatMessage(
82 | client,
83 | sender,
84 | messages.ERROR.OUTOFSTOCK.DEFAULT.SETS.US[0][language]
85 | );
86 | } else {
87 | const message = messages.TRADE.SETMESSAGE[1].TF[language]
88 | .replace('{SETS}', amountofsets)
89 | .replace('{TF}', n);
90 | makeOffer(
91 | client,
92 | users,
93 | manager,
94 | sender.getSteamID64(),
95 | [].concat(...mySets),
96 | theirKeys,
97 | '!BUYANYTF',
98 | message,
99 | amountofsets,
100 | 0,
101 | n,
102 | 0
103 | );
104 | }
105 | }
106 | } else if (ERR.message.indexOf('profile is private') > -1) {
107 | chatMessage(
108 | client,
109 | sender,
110 | messages.ERROR.LOADINVENTORY.THEM[2][language]
111 | );
112 | log.error(`An error occurred while getting user inventory: ${ERR}`);
113 | } else {
114 | chatMessage(
115 | client,
116 | sender,
117 | messages.ERROR.LOADINVENTORY.THEM[0][language]
118 | );
119 | log.error(`An error occurred while getting user inventory: ${ERR}`);
120 | }
121 | }
122 | );
123 | } else {
124 | chatMessage(
125 | client,
126 | sender,
127 | messages.ERROR.INPUT.AMOUNTOVER.TF[language].replace('{KEYS}', maxKeys)
128 | );
129 | }
130 | } else {
131 | chatMessage(
132 | client,
133 | sender,
134 | messages.ERROR.INPUT.INVALID.TF[language].replace(
135 | '{command}',
136 | '!BUYANYTF 1'
137 | )
138 | );
139 | }
140 | };
141 |
--------------------------------------------------------------------------------
/src/Commands/User/CSGO/BUYANY/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-restricted-syntax */
2 | const main = require('../../../../Config/main');
3 | const messages = require('../../../../Config/messages');
4 | const rates = require('../../../../Config/rates');
5 | const utils = require('../../../../Utils');
6 | const acceptedCurrencies = require('../../../../Config/currencies');
7 | const inventory = require('../../../../Components/inventory');
8 | const chatMessage = require('../../../../Components/message');
9 | const makeOffer = require('../../../../Components/offer');
10 | const log = require('../../../../Components/log');
11 |
12 | module.exports = (sender, msg, client, users, manager) => {
13 | const language = utils.getLanguage(sender.getSteamID64(), users);
14 | const n = parseInt(msg.toUpperCase().replace('!BUYANYCSGO ', ''), 10);
15 | const amountofsets = n * rates.csgo.sell;
16 | const maxKeys = parseInt(main.maxBuy / rates.csgo.sell, 10);
17 |
18 | if (!Number.isNaN(n) && n > 0) {
19 | log.userChat(sender.getSteamID64(), language, `[ !BUYANYCSGO ${n} ]`);
20 | if (n <= maxKeys) {
21 | const theirKeys = [];
22 | const mySets = [];
23 | chatMessage(client, sender, messages.REQUEST[language]);
24 | manager.getUserInventoryContents(
25 | sender.getSteamID64(),
26 | 730,
27 | 2,
28 | true,
29 | (ERR, INV) => {
30 | if (!ERR) {
31 | let amountofB = amountofsets;
32 | for (let i = 0; i < INV.length; i += 1) {
33 | if (
34 | theirKeys.length < n &&
35 | acceptedCurrencies.csgo.indexOf(INV[i].market_hash_name) >= 0
36 | ) {
37 | theirKeys.push(INV[i]);
38 | }
39 | }
40 | if (theirKeys.length !== n) {
41 | chatMessage(
42 | client,
43 | sender,
44 | messages.ERROR.OUTOFSTOCK.DEFAULT.CSGO.THEM[0][language]
45 | );
46 | } else {
47 | utils.sortSetsByAmount(inventory.botSets, (DATA) => {
48 | const setsSent = {};
49 | firstLoop: for (let i = 0; i < DATA.length; i += 1) {
50 | if (inventory.botSets[DATA[i]]) {
51 | for (
52 | let j = 0;
53 | j < inventory.botSets[DATA[i]].length;
54 | j += 1
55 | ) {
56 | if (amountofB > 0) {
57 | if (
58 | (setsSent[DATA[i]] && setsSent[DATA[i]] > -1) ||
59 | !setsSent[DATA[i]]
60 | ) {
61 | mySets.push(inventory.botSets[DATA[i]][j]);
62 | amountofB -= 1;
63 | if (!setsSent[DATA[i]]) {
64 | setsSent[DATA[i]] = 1;
65 | } else {
66 | setsSent[DATA[i]] += 1;
67 | }
68 | } else {
69 | continue firstLoop;
70 | }
71 | } else {
72 | continue firstLoop;
73 | }
74 | }
75 | } else {
76 | continue;
77 | }
78 | }
79 | });
80 | if (amountofB > 0) {
81 | chatMessage(
82 | client,
83 | sender,
84 | messages.ERROR.OUTOFSTOCK.DEFAULT.SETS.US[0][language]
85 | );
86 | } else {
87 | const message = messages.TRADE.SETMESSAGE[1].CSGO[language]
88 | .replace('{SETS}', amountofsets)
89 | .replace('{CSGO}', n);
90 | makeOffer(
91 | client,
92 | users,
93 | manager,
94 | sender.getSteamID64(),
95 | [].concat(...mySets),
96 | theirKeys,
97 | '!BUYANYCSGO',
98 | message,
99 | amountofsets,
100 | 0,
101 | n,
102 | 0
103 | );
104 | }
105 | }
106 | } else if (ERR.message.indexOf('profile is private') > -1) {
107 | chatMessage(
108 | client,
109 | sender,
110 | messages.ERROR.LOADINVENTORY.THEM[2][language]
111 | );
112 | log.error(`An error occurred while getting user inventory: ${ERR}`);
113 | } else {
114 | chatMessage(
115 | client,
116 | sender,
117 | messages.ERROR.LOADINVENTORY.THEM[0][language]
118 | );
119 | log.error(`An error occurred while getting user inventory: ${ERR}`);
120 | }
121 | }
122 | );
123 | } else {
124 | chatMessage(
125 | client,
126 | sender,
127 | messages.ERROR.INPUT.AMOUNTOVER.CSGO[language].replace(
128 | '{KEYS}',
129 | maxKeys
130 | )
131 | );
132 | }
133 | } else {
134 | chatMessage(
135 | client,
136 | sender,
137 | messages.ERROR.INPUT.INVALID.CSGO[language].replace(
138 | '{command}',
139 | '!BUYANYCSGO 1'
140 | )
141 | );
142 | }
143 | };
144 |
--------------------------------------------------------------------------------
/src/Commands/User/HYDRA/BUYANY/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-restricted-syntax */
2 | const main = require('../../../../Config/main');
3 | const messages = require('../../../../Config/messages');
4 | const rates = require('../../../../Config/rates');
5 | const utils = require('../../../../Utils');
6 | const acceptedCurrencies = require('../../../../Config/currencies');
7 | const inventory = require('../../../../Components/inventory');
8 | const chatMessage = require('../../../../Components/message');
9 | const makeOffer = require('../../../../Components/offer');
10 | const log = require('../../../../Components/log');
11 |
12 | module.exports = (sender, msg, client, users, manager) => {
13 | const language = utils.getLanguage(sender.getSteamID64(), users);
14 | const n = parseInt(msg.toUpperCase().replace('!BUYANYHYDRA ', ''), 10);
15 | const amountofsets = n * rates.hydra.sell;
16 | const maxKeys = parseInt(main.maxBuy / rates.hydra.sell, 10);
17 |
18 | if (!Number.isNaN(n) && n > 0) {
19 | log.userChat(sender.getSteamID64(), language, `[ !BUYANYHYDRA ${n} ]`);
20 | if (n <= maxKeys) {
21 | const theirKeys = [];
22 | const mySets = [];
23 | chatMessage(client, sender, messages.REQUEST[language]);
24 | manager.getUserInventoryContents(
25 | sender.getSteamID64(),
26 | 730,
27 | 2,
28 | true,
29 | (ERR, INV) => {
30 | if (!ERR) {
31 | let amountofB = amountofsets;
32 | for (let i = 0; i < INV.length; i += 1) {
33 | if (
34 | theirKeys.length < n &&
35 | acceptedCurrencies.hydra.indexOf(INV[i].market_hash_name) >= 0
36 | ) {
37 | theirKeys.push(INV[i]);
38 | }
39 | }
40 | if (theirKeys.length !== n) {
41 | chatMessage(
42 | client,
43 | sender,
44 | messages.ERROR.OUTOFSTOCK.DEFAULT.HYDRA.THEM[0][language]
45 | );
46 | } else {
47 | utils.sortSetsByAmount(inventory.botSets, (DATA) => {
48 | const setsSent = {};
49 | firstLoop: for (let i = 0; i < DATA.length; i += 1) {
50 | if (inventory.botSets[DATA[i]]) {
51 | for (
52 | let j = 0;
53 | j < inventory.botSets[DATA[i]].length;
54 | j += 1
55 | ) {
56 | if (amountofB > 0) {
57 | if (
58 | (setsSent[DATA[i]] && setsSent[DATA[i]] > -1) ||
59 | !setsSent[DATA[i]]
60 | ) {
61 | mySets.push(inventory.botSets[DATA[i]][j]);
62 | amountofB -= 1;
63 | if (!setsSent[DATA[i]]) {
64 | setsSent[DATA[i]] = 1;
65 | } else {
66 | setsSent[DATA[i]] += 1;
67 | }
68 | } else {
69 | continue firstLoop;
70 | }
71 | } else {
72 | continue firstLoop;
73 | }
74 | }
75 | } else {
76 | continue;
77 | }
78 | }
79 | });
80 | if (amountofB > 0) {
81 | chatMessage(
82 | client,
83 | sender,
84 | messages.ERROR.OUTOFSTOCK.DEFAULT.SETS.US[0][language]
85 | );
86 | } else {
87 | const message = messages.TRADE.SETMESSAGE[1].HYDRA[language]
88 | .replace('{SETS}', amountofsets)
89 | .replace('{HYDRA}', n);
90 | makeOffer(
91 | client,
92 | users,
93 | manager,
94 | sender.getSteamID64(),
95 | [].concat(...mySets),
96 | theirKeys,
97 | '!BUYANYHYDRA',
98 | message,
99 | amountofsets,
100 | 0,
101 | n,
102 | 0
103 | );
104 | }
105 | }
106 | } else if (ERR.message.indexOf('profile is private') > -1) {
107 | chatMessage(
108 | client,
109 | sender,
110 | messages.ERROR.LOADINVENTORY.THEM[2][language]
111 | );
112 | log.error(`An error occurred while getting user inventory: ${ERR}`);
113 | } else {
114 | chatMessage(
115 | client,
116 | sender,
117 | messages.ERROR.LOADINVENTORY.THEM[0][language]
118 | );
119 | log.error(`An error occurred while getting user inventory: ${ERR}`);
120 | }
121 | }
122 | );
123 | } else {
124 | chatMessage(
125 | client,
126 | sender,
127 | messages.ERROR.INPUT.AMOUNTOVER.HYDRA[language].replace(
128 | '{KEYS}',
129 | maxKeys
130 | )
131 | );
132 | }
133 | } else {
134 | chatMessage(
135 | client,
136 | sender,
137 | messages.ERROR.INPUT.INVALID.HYDRA[language].replace(
138 | '{command}',
139 | '!BUYANYHYDRA 1'
140 | )
141 | );
142 | }
143 | };
144 |
--------------------------------------------------------------------------------
/src/Commands/Admin/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-undef */
2 | /* eslint-disable no-restricted-syntax */
3 | /* eslint-disable consistent-return */
4 | const ADMIN = require('./GENERAL/ADMIN');
5 | const AUTHCODE = require('./GENERAL/AUTHCODE');
6 | const BLOCK = require('./GENERAL/BLOCK');
7 | const BROADCAST = require('./GENERAL/BROADCAST');
8 | const DIE = require('./GENERAL/DIE');
9 | const PROFIT = require('./GENERAL/PROFIT');
10 | const RELOAD = require('./GENERAL/RELOAD');
11 | const REQUESTER = require('./GENERAL/REQUESTER');
12 | const RESTART = require('./GENERAL/RESTART');
13 | const CANCEL = require('./GENERAL/CANCEL');
14 | const RESTOCK = require('./GENERAL/RESTOCK');
15 | const ROLLBACK = require('./GENERAL/ROLLBACK');
16 | const UNBLOCK = require('./GENERAL/UNBLOCK');
17 | const UNPACK = require('./GENERAL/UNPACK');
18 | const USERCHECK = require('./GENERAL/USERCHECK');
19 | const MYSTATS = require('./GENERAL/MYSTATS');
20 | const WITHDRAWBOOSTER = require('./BOOSTER/WITHDRAW');
21 | const WITHDRAWCSGO = require('./CSGO/WITHDRAW');
22 | const WITHDRAWGEMS = require('./GEMS/WITHDRAW');
23 | const WITHDRAWHYDRA = require('./HYDRA/WITHDRAW');
24 | const WITHDRAWTF = require('./TF/WITHDRAW');
25 | const WITHDRAWSETS = require('./SETS/WITHDRAW');
26 | const WITHDRAWLEFTOVER = require('./GENERAL/WITHDRAWLEFTOVER');
27 | const DEPOSITBOOSTER = require('./BOOSTER/DEPOSIT');
28 | const DEPOSITCSGO = require('./CSGO/DEPOSIT');
29 | const DEPOSITGEMS = require('./GEMS/DEPOSIT');
30 | const DEPOSITHYDRA = require('./HYDRA/DEPOSIT');
31 | const DEPOSITTF = require('./TF/DEPOSIT');
32 | const DEPOSITSETS = require('./SETS/DEPOSIT');
33 | const main = require('../../Config/main');
34 |
35 | function admin(sender, msg, client, users, community, allCards, manager) {
36 | const input = msg.toUpperCase().split(' ')[0];
37 | const ignoreCommands = main.ignoreCommands.map((el) => el.toUpperCase());
38 | const { acceptedCurrencies } = main;
39 |
40 | if (ignoreCommands.includes(input)) {
41 | return 'UNKNOW';
42 | }
43 |
44 | for (const key in acceptedCurrencies) {
45 | if (typeof acceptedCurrencies[key] !== 'boolean') {
46 | throw new Error(
47 | 'Error in configuring accepted currencies: not is boolean'
48 | );
49 | } else if (
50 | input.includes(key.replace('2', '')) &&
51 | !acceptedCurrencies[key]
52 | ) {
53 | return 'UNKNOW';
54 | }
55 | }
56 |
57 | switch (input) {
58 | case '!ADMIN':
59 | ADMIN(sender, client, users);
60 | break;
61 | case '!AUTHCODE':
62 | AUTHCODE(sender, client, users);
63 | break;
64 | case '!BLOCK':
65 | BLOCK(sender, msg, client, users);
66 | break;
67 | case '!BROADCAST':
68 | BROADCAST(sender, msg, client, users);
69 | break;
70 | case '!DIE':
71 | DIE(sender, client, users);
72 | break;
73 | case '!PROFIT':
74 | PROFIT(sender, msg, client, users);
75 | break;
76 | case '!RELOAD':
77 | RELOAD(sender, client, users, community, allCards);
78 | break;
79 | case '!REQUESTER':
80 | REQUESTER(sender, client, users, community, allCards, manager);
81 | break;
82 | case '!RESTART':
83 | RESTART(sender, client, users);
84 | break;
85 | case '!CANCEL':
86 | CANCEL(sender, msg, client, users, manager);
87 | break;
88 | case '!RESTOCK':
89 | RESTOCK(sender, client, users, community, allCards, manager);
90 | break;
91 | case '!ROLLBACK':
92 | ROLLBACK(sender, msg, client, users, community, manager);
93 | break;
94 | case '!UNBLOCK':
95 | UNBLOCK(sender, msg, client, users);
96 | break;
97 | case '!UNPACK':
98 | UNPACK(sender, client, users, community, manager);
99 | break;
100 | case '!USERCHECK':
101 | USERCHECK(sender, msg, client, users, community, allCards);
102 | break;
103 | case '!MYSTATS':
104 | MYSTATS(sender, client, users, community, allCards);
105 | break;
106 | case '!WITHDRAWLEFTOVER':
107 | WITHDRAWLEFTOVER(sender, client, users, community, manager);
108 | break;
109 | case '!WITHDRAWBOOSTER':
110 | WITHDRAWBOOSTER(sender, msg, client, users, manager);
111 | break;
112 | case '!WITHDRAWCSGO':
113 | WITHDRAWCSGO(sender, msg, client, users, manager);
114 | break;
115 | case '!WITHDRAWGEMS':
116 | WITHDRAWGEMS(sender, msg, client, users, manager);
117 | break;
118 | case '!WITHDRAWHYDRA':
119 | WITHDRAWHYDRA(sender, msg, client, users, manager);
120 | break;
121 | case '!WITHDRAWTF':
122 | WITHDRAWTF(sender, msg, client, users, manager);
123 | break;
124 | case '!WITHDRAWSETS':
125 | WITHDRAWSETS(sender, msg, client, users, manager);
126 | break;
127 | case '!DEPOSITBOOSTER':
128 | DEPOSITBOOSTER(sender, msg, client, users, manager);
129 | break;
130 | case '!DEPOSITCSGO':
131 | DEPOSITCSGO(sender, msg, client, users, manager);
132 | break;
133 | case '!DEPOSITGEMS':
134 | DEPOSITGEMS(sender, msg, client, users, manager);
135 | break;
136 | case '!DEPOSITHYDRA':
137 | DEPOSITHYDRA(sender, msg, client, users, manager);
138 | break;
139 | case '!DEPOSITTF':
140 | DEPOSITTF(sender, msg, client, users, manager);
141 | break;
142 | case '!DEPOSITSETS':
143 | DEPOSITSETS(sender, msg, client, users, community, allCards, manager);
144 | break;
145 | default:
146 | return 'UNKNOW';
147 | }
148 | }
149 |
150 | module.exports = admin;
151 |
--------------------------------------------------------------------------------
/src/Components/request.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-restricted-syntax */
2 | const main = require('../Config/main');
3 | const utils = require('../Utils');
4 | const log = require('./log');
5 | const { getSets } = require('./sets');
6 |
7 | module.exports = (ID64, community, allCards, manager, inventory, callback) => {
8 | if (ID64) {
9 | log.warn(`Auto Request to #${ID64}`);
10 | inventory.getInventory(ID64, community, (ERR1, DATA1) => {
11 | if (!ERR1) {
12 | const s = DATA1;
13 | getSets(s, allCards, (ERR2, DATA2) => {
14 | log.warn('SETS LOADED');
15 | if (!ERR2) {
16 | let userNSets = 0;
17 | for (let i = 0; i < Object.keys(DATA2).length; i += 1) {
18 | userNSets += DATA2[Object.keys(DATA2)[i]].length;
19 | }
20 | log.warn('Creating trade offer');
21 | const t = manager.createOffer(ID64);
22 | let amountofB = main.requester.amount
23 | ? main.requester.amount
24 | : userNSets;
25 | const setsSent = {};
26 | const cardsSent = {};
27 | const Cards = {};
28 | for (let j = 0; j < Object.keys(DATA1).length; j += 1) {
29 | Cards[Object.keys(DATA1)[j]] = Object.values(
30 | Object.values(DATA1)[j]
31 | );
32 | }
33 | utils.sortSetsByAmountB(s, (DATA3) => {
34 | firstLoop: for (let i = 0; i < DATA3.length; i += 1) {
35 | if (DATA2[DATA3[i]]) {
36 | for (let j = 0; j < DATA2[DATA3[i]].length; j += 1) {
37 | if (amountofB > 0) {
38 | if (!setsSent[DATA3[i]]) {
39 | setsSent[DATA3[i]] = 0;
40 | }
41 | if (
42 | main.requester.ignoreLimit
43 | ? true
44 | : setsSent[DATA3[i]] +
45 | (inventory.botSets[DATA3[i]]
46 | ? inventory.botSets[DATA3[i]].length
47 | : 0) <
48 | main.maxStock
49 | ) {
50 | t.addTheirItems(DATA2[DATA3[i]][j]);
51 | amountofB -= 1;
52 | setsSent[DATA3[i]] += 1;
53 | } else {
54 | continue firstLoop;
55 | }
56 | } else {
57 | continue firstLoop;
58 | }
59 | }
60 | } else if (main.requester.sendLeftOvers) {
61 | if (Cards[DATA3[i]]) {
62 | for (let j = 0; j < Cards[DATA3[i]].length; j += 1) {
63 | for (let k = 0; k < Cards[DATA3[i]][j].length; k += 1) {
64 | if (
65 | (cardsSent[DATA3[i]] && cardsSent[DATA3[i]] > -1) ||
66 | !cardsSent[DATA3[i]]
67 | ) {
68 | t.addTheirItems(Cards[DATA3[i]][j]);
69 | if (!cardsSent[DATA3[i]]) {
70 | cardsSent[DATA3[i]] = 1;
71 | } else {
72 | cardsSent[DATA3[i]] += 1;
73 | }
74 | } else {
75 | continue firstLoop;
76 | }
77 | }
78 | }
79 | } else {
80 | continue;
81 | }
82 | } else {
83 | continue;
84 | }
85 | }
86 | });
87 | let amountofSets = 0;
88 | let amountofleftovers = 0;
89 | for (const key in setsSent) {
90 | if (Object.prototype.hasOwnProperty.call(setsSent, key)) {
91 | amountofSets += setsSent[key];
92 | }
93 | }
94 | for (const key in cardsSent) {
95 | if (Object.prototype.hasOwnProperty.call(cardsSent, key)) {
96 | amountofleftovers += cardsSent[key];
97 | }
98 | }
99 | callback(true);
100 | if (
101 | (main.requester.sendLeftOvers && amountofleftovers > 0) ||
102 | amountofSets > 0
103 | ) {
104 | log.warn('Sending trade offer');
105 | t.data('commandused', 'AUTOREQUEST');
106 | t.data('amountofsets', amountofSets.toString());
107 | t.data('amountofleftovers', amountofleftovers.toString());
108 | t.data('amountofgems', 0);
109 | t.data('amountofkeys', 0);
110 | t.setMessage('Auto Request');
111 | t.send((ERR3) => {
112 | if (ERR3) {
113 | log.error(
114 | `An error occurred while sending trade offer: ${ERR3}`
115 | );
116 | } else {
117 | log.warn(`offer #${t.id} sent successfully`);
118 | }
119 | });
120 | } else {
121 | log.warn("Didn't find cards to requests.");
122 | }
123 | } else {
124 | log.error(`An error occurred while getting user sets: ${ERR2}`);
125 | }
126 | });
127 | } else {
128 | log.error(`An error occurred while getting user inventory: ${ERR1}`);
129 | }
130 | });
131 | } else {
132 | log.error('An error occurred while auto request: target is not defined');
133 | }
134 | };
135 |
--------------------------------------------------------------------------------
/src/Commands/User/GEMS/BUYANY/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-restricted-syntax */
2 | const main = require('../../../../Config/main');
3 | const messages = require('../../../../Config/messages');
4 | const rates = require('../../../../Config/rates');
5 | const utils = require('../../../../Utils');
6 | const acceptedCurrencies = require('../../../../Config/currencies');
7 | const inventory = require('../../../../Components/inventory');
8 | const chatMessage = require('../../../../Components/message');
9 | const makeOffer = require('../../../../Components/offer');
10 | const log = require('../../../../Components/log');
11 |
12 | module.exports = (sender, msg, client, users, manager) => {
13 | const language = utils.getLanguage(sender.getSteamID64(), users);
14 | const amountofsets = parseInt(
15 | msg.toUpperCase().replace('!BUYANYGEMS ', ''),
16 | 10
17 | );
18 |
19 | if (!Number.isNaN(amountofsets) && amountofsets > 0) {
20 | log.userChat(
21 | sender.getSteamID64(),
22 | language,
23 | `[ !BUYANYGEMS ${amountofsets} ]`
24 | );
25 | if (amountofsets <= main.maxBuy) {
26 | const theirGems = [];
27 | const mySets = [];
28 | let amountTheirGems = 0;
29 | chatMessage(client, sender, messages.REQUEST[language]);
30 | manager.getUserInventoryContents(
31 | sender.getSteamID64(),
32 | 753,
33 | 6,
34 | true,
35 | (ERR, INV) => {
36 | if (!ERR) {
37 | let amountofB = amountofsets;
38 | let need = amountofsets * rates.gems.sell;
39 | const inv = INV;
40 | for (let i = 0; i < inv.length; i += 1) {
41 | if (need !== 0) {
42 | if (
43 | acceptedCurrencies.steamGems.indexOf(
44 | inv[i].market_hash_name
45 | ) >= 0
46 | ) {
47 | inv[i].amount = need <= inv[i].amount ? need : inv[i].amount;
48 | need -= inv[i].amount;
49 | amountTheirGems += inv[i].amount;
50 | theirGems.push(inv[i]);
51 | }
52 | } else {
53 | break;
54 | }
55 | }
56 | if (amountTheirGems < amountofsets * rates.gems.sell) {
57 | chatMessage(
58 | client,
59 | sender,
60 | messages.ERROR.OUTOFSTOCK.DEFAULT.GEMS.THEM[0][language]
61 | );
62 | } else {
63 | utils.sortSetsByAmount(inventory.botSets, (DATA) => {
64 | const setsSent = {};
65 | firstLoop: for (let i = 0; i < DATA.length; i += 1) {
66 | if (inventory.botSets[DATA[i]]) {
67 | for (
68 | let j = 0;
69 | j < inventory.botSets[DATA[i]].length;
70 | j += 1
71 | ) {
72 | if (amountofB > 0) {
73 | if (
74 | (setsSent[DATA[i]] && setsSent[DATA[i]] > -1) ||
75 | !setsSent[DATA[i]]
76 | ) {
77 | mySets.push(inventory.botSets[DATA[i]][j]);
78 | amountofB -= 1;
79 | if (!setsSent[DATA[i]]) {
80 | setsSent[DATA[i]] = 1;
81 | } else {
82 | setsSent[DATA[i]] += 1;
83 | }
84 | } else {
85 | continue firstLoop;
86 | }
87 | } else {
88 | continue firstLoop;
89 | }
90 | }
91 | } else {
92 | continue;
93 | }
94 | }
95 | });
96 | if (amountofB > 0) {
97 | chatMessage(
98 | client,
99 | sender,
100 | messages.ERROR.OUTOFSTOCK.DEFAULT.SETS.US[0][language]
101 | );
102 | } else {
103 | const message = messages.TRADE.SETMESSAGE[1].GEMS[language]
104 | .replace('{SETS}', amountofsets)
105 | .replace('{GEMS}', rates.gems.sell * amountofsets);
106 | makeOffer(
107 | client,
108 | users,
109 | manager,
110 | sender.getSteamID64(),
111 | [].concat(...mySets),
112 | theirGems,
113 | '!BUYANYGEMS',
114 | message,
115 | amountofsets,
116 | 0,
117 | 0,
118 | amountofsets * rates.gems.sell
119 | );
120 | }
121 | }
122 | } else if (ERR.message.indexOf('profile is private') > -1) {
123 | chatMessage(
124 | client,
125 | sender,
126 | messages.ERROR.LOADINVENTORY.THEM[2][language]
127 | );
128 | log.error(`An error occurred while getting user inventory: ${ERR}`);
129 | } else {
130 | chatMessage(
131 | client,
132 | sender,
133 | messages.ERROR.LOADINVENTORY.THEM[0][language]
134 | );
135 | log.error(`An error occurred while getting user inventory: ${ERR}`);
136 | }
137 | }
138 | );
139 | } else {
140 | chatMessage(
141 | client,
142 | sender,
143 | messages.ERROR.INPUT.AMOUNTOVER.SETS[language].replace(
144 | '{SETS}',
145 | main.maxBuy
146 | )
147 | );
148 | }
149 | } else {
150 | chatMessage(
151 | client,
152 | sender,
153 | messages.ERROR.INPUT.INVALID.SETS[language].replace(
154 | '{command}',
155 | '!BUYANYGEMS 1'
156 | )
157 | );
158 | }
159 | };
160 |
--------------------------------------------------------------------------------
/src/Components/log.js:
--------------------------------------------------------------------------------
1 | const fs = require('graceful-fs');
2 | const colour = require('cli-color');
3 | const moment = require('moment');
4 |
5 | const main = require('../Config/main');
6 | const utils = require('../Utils');
7 |
8 | const log = {};
9 |
10 | log.warn = (data) => {
11 | const text = `${utils.date1()} @ [ WARN ] ${data}`;
12 | if (main.log.warn.enabled) {
13 | console.log(colour[main.log.warn.color](text));
14 | }
15 | fs.appendFile(
16 | `./Data/History/Warn/log-${utils.date2()}.txt`,
17 | `${text}\r\n`,
18 | {
19 | flags: 'a',
20 | },
21 | (ERR) => {
22 | if (ERR) {
23 | log.error(`An error occurred while writing warn logs file: ${ERR}`);
24 | }
25 | }
26 | );
27 | };
28 |
29 | log.error = (data) => {
30 | const text = `${utils.date1()} @ [ ERROR ] ${data}`;
31 | if (main.log.error.enabled) {
32 | console.log(colour[main.log.error.color](text));
33 | }
34 | fs.appendFile(
35 | `./Data/History/Error/log-${utils.date2()}.txt`,
36 | `${text}\r\n`,
37 | {
38 | flags: 'a',
39 | },
40 | (ERR) => {
41 | if (ERR) {
42 | log.error(`An error occurred while writing Error logs file: ${ERR}`);
43 | }
44 | }
45 | );
46 | };
47 |
48 | log.info = (data) => {
49 | const text = `${utils.date1()} @ [ INFO ] ${data}`;
50 | if (main.log.info.enabled) {
51 | console.log(colour[main.log.info.color](text));
52 | }
53 | fs.appendFile(
54 | `./Data/History/Info/log-${utils.date2()}.txt`,
55 | `${text}\r\n`,
56 | {
57 | flags: 'a',
58 | },
59 | (ERR) => {
60 | if (ERR) {
61 | log.error(`An error occurred while writing Info logs file: ${ERR}`);
62 | }
63 | }
64 | );
65 | };
66 |
67 | log.userChat = (id64, userLang, data) => {
68 | const text = `${utils.date1()} @ [ USERCHAT: ${id64}][ ${userLang} ]${data}`;
69 | if (main.log.userChat.enabled) {
70 | console.log(colour[main.log.userChat.color](text));
71 | }
72 | fs.appendFile(
73 | `./Data/History/UserChat/log-${utils.date2()}.txt`,
74 | `${text}\r\n`,
75 | {
76 | flags: 'a',
77 | },
78 | (ERR) => {
79 | if (ERR) {
80 | log.error(`An error occurred while writing UserChat logs file: ${ERR}`);
81 | }
82 | }
83 | );
84 | };
85 |
86 | log.adminChat = (id64, userLang, data) => {
87 | const text = `${utils.date1()} @ [ ADMINCHAT: ${id64}][ ${userLang} ]${data}`;
88 | if (main.log.adminChat.enabled) {
89 | console.log(colour[main.log.adminChat.color](text));
90 | }
91 | fs.appendFile(
92 | `./Data/History/AdminChat/log-${utils.date2()}.txt`,
93 | `${text}\r\n`,
94 | {
95 | flags: 'a',
96 | },
97 | (ERR) => {
98 | if (ERR) {
99 | log.error(
100 | `An error occurred while writing AdminChat logs file: ${ERR}`
101 | );
102 | }
103 | }
104 | );
105 | };
106 |
107 | log.tradeoffer = (data) => {
108 | const text = `${utils.date1()} @ [ TRADEOFFER ] ${data}`;
109 | if (main.log.tradeOffer.enabled) {
110 | console.log(colour[main.log.tradeOffer.color](text));
111 | }
112 | fs.appendFile(
113 | `./Data/History/TradeOffer/log-${utils.date2()}.txt`,
114 | `${text}\r\n`,
115 | {
116 | flags: 'a',
117 | },
118 | (ERR) => {
119 | if (ERR) {
120 | log.error(
121 | `An error occurred while writing Tradeoffer logs file: ${ERR}`
122 | );
123 | }
124 | }
125 | );
126 | };
127 |
128 | log.botChatFullMessages = (id64, msg) => {
129 | const separator =
130 | '==========================================================';
131 | const dir = `./Data/ChatLogs/BotLogs/${utils.date2()}`;
132 | const timeZone = new Date(utils.timeZone());
133 | const time = `${`0${timeZone.getHours()}`.slice(
134 | -2
135 | )}:${`0${timeZone.getMinutes()}`.slice(
136 | -2
137 | )}:${`0${timeZone.getSeconds()}`.slice(-2)}`;
138 |
139 | if (!fs.existsSync(dir)) {
140 | fs.mkdirSync(dir);
141 | }
142 |
143 | fs.appendFile(
144 | `${dir}/${id64}.txt`,
145 | `${separator} ${time} ${separator}
146 | ${msg} \r\n\r\n`,
147 | {
148 | flags: 'a',
149 | },
150 | (ERR) => {
151 | if (ERR) {
152 | log.error(`An error occurred while writing Bot ChatLogs file: ${ERR}`);
153 | }
154 | }
155 | );
156 | };
157 |
158 | log.userChatFullMessages = (id64, msg) => {
159 | const dir = `./Data/ChatLogs/UserLogs/${utils.date2()}`;
160 | const timeZone = new Date(utils.timeZone());
161 | const time = `${`0${timeZone.getHours()}`.slice(
162 | -2
163 | )}:${`0${timeZone.getMinutes()}`.slice(
164 | -2
165 | )}:${`0${timeZone.getSeconds()}`.slice(-2)}`;
166 |
167 | if (!fs.existsSync(dir)) {
168 | fs.mkdirSync(dir);
169 | }
170 |
171 | fs.appendFile(
172 | `${dir}/${id64}.txt`,
173 | `${time} --> ${msg} \r\n`,
174 | {
175 | flags: 'a',
176 | },
177 | (ERR) => {
178 | if (ERR) {
179 | log.error(`An error occurred while writing User ChatLogs file: ${ERR}`);
180 | }
181 | }
182 | );
183 | };
184 |
185 | log.tradesHistory = (offer) => {
186 | const itemsSent = offer.itemsToGive.map(utils.getOfferItemInfo);
187 | const itemsReceived = offer.itemsToReceive.map(utils.getOfferItemInfo);
188 |
189 | let data = `Command: ${offer.data('commandused')}`;
190 | if (offer.data('amountofsets')) {
191 | data += `\nSets: ${offer.data('amountofsets')}`;
192 | }
193 | if (offer.data('amountofleftovers')) {
194 | data += `\nLeftovers: ${offer.data('amountofleftovers')}`;
195 | }
196 | if (offer.data('amountofkeys')) {
197 | data += `\nKeys: ${offer.data('amountofkeys')}`;
198 | }
199 | if (offer.data('amountofgems')) {
200 | data += `\nGems: ${offer.data('amountofgems')}`;
201 | }
202 |
203 | data += `\nSteamID: ${offer.partner.getSteamID64()}`;
204 | data += `\nOfferID: ${offer.id}`;
205 | data += `\nCreatedDate: ${moment(offer.created).toISOString()}`;
206 | data += `\nCompletedDate: ${moment(offer.updated).toISOString()}`;
207 | data += `\nItemsSent: ${JSON.stringify(itemsSent, null, 2)}`;
208 | data += `\nItemsReceived: ${JSON.stringify(itemsReceived, null, 2)}`;
209 |
210 | fs.writeFile(
211 | `./Data/AcceptedTrades/${offer.id}-${offer.partner.getSteamID64()}.txt`,
212 | data,
213 | (ERR) => {
214 | if (ERR) {
215 | log.error(`An error occurred while writing trade file: ${ERR}`);
216 | }
217 | }
218 | );
219 | };
220 |
221 | module.exports = log;
222 |
--------------------------------------------------------------------------------