Skip to content

Commit

Permalink
Modificado src para app
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfiorette committed Mar 17, 2021
1 parent 5ccda62 commit 667ece4
Show file tree
Hide file tree
Showing 13 changed files with 4,400 additions and 1,234 deletions.
Empty file removed .env
Empty file.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
build
dist
.vscode
3 changes: 3 additions & 0 deletions app/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-typescript"]
}
1 change: 1 addition & 0 deletions src/@types/modules.d.ts → app/@types/modules.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
declare module 'steam-user';
declare module 'steamcommunity';
declare module 'steam-tradeoffer-manager';
File renamed without changes.
4,288 changes: 4,288 additions & 0 deletions app/package-lock.json

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions package.json → app/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "steam-trade",
"name": "steam-trade-app",
"version": "1.0.0",
"description": "An automated steam trade client!",
"main": "src/index.ts",
"private": true,
"scripts": {
"start": "docker-compose up"
"build": "babel src -d build --copy-files --extensions .ts",
"qrun": "npm run build && node build"
},
"repository": {
"type": "git",
Expand All @@ -25,6 +26,10 @@
"steamcommunity": "^3.42.0"
},
"devDependencies": {
"@babel/cli": "^7.13.10",
"@babel/core": "^7.13.10",
"@babel/preset-env": "^7.13.10",
"@babel/preset-typescript": "^7.13.0",
"@types/node": "^14.14.35",
"@types/steam-totp": "^2.1.0",
"typescript": "^4.2.3"
Expand Down
36 changes: 36 additions & 0 deletions app/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import config from '../../config.json';
import SteamUser from 'steam-user';
import SteamCommunity from 'steamcommunity';
import SteamTotp from 'steam-totp';
import TradeOfferManager from 'steam-tradeoffer-manager';
import { info, Ad } from './logger';

Ad.startup();

const client = new SteamUser();
const community = new SteamCommunity();

const manager = new TradeOfferManager({
steam: client,
community,
language: 'en'
});

info('TradeOfferManager is ready');

const { username, sharedSecret, password } = config.steam;
const { gameId } = config.info;

client.logOn({
accountName: username,
password: password,
twoFactorCode: SteamTotp.generateAuthCode(sharedSecret)
});

client.on('loggedOn', () => {
info(`Logged into steam with username ${username}`);
client.setPersona(1);
client.gamesPlayed(gameId);
});

info('App initialized');
35 changes: 35 additions & 0 deletions app/src/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { enable } from 'colors';

enable();

function printAll(prefix: string, color: string | undefined, ...message: string[]) {
message.forEach((msg) => console.log(`[${prefix}]`.blue, color ? msg[color] : msg));
}

export function info(...message: string[]) {
printAll('INFO', 'green', ...message);
}

export function warn(...message: string[]) {
printAll('WARN', 'yellow', ...message);
}

export function error(...message: string[]) {
printAll('ERROR', 'red', ...message);
}

export function log(...message: string[]) {
printAll('#', undefined, ...message);
}

export namespace Ad {
export function startup() {
log(
'This bot was developed by Arthur Fiorette'.white,
'Visit us on GitHub!'.white,
'https://github.com/ArthurFiorette/steam-trader'.white,
'',
'Loading...'.green
);
}
}
18 changes: 9 additions & 9 deletions tsconfig.json → app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
"noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
"noUnusedLocals": true /* Report errors on unused locals. */,
"noUnusedParameters": true /* Report errors on unused parameters. */,
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
Expand All @@ -47,9 +47,9 @@
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
"typeRoots": ["node_modules/@types", "src/@types"], /* List of folders to include type definitions from. */
"typeRoots": ["node_modules/@types", "app/@types"] /* List of folders to include type definitions from. */,
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
Expand All @@ -67,7 +67,7 @@
/* Advanced Options */
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"resolveJsonModule": true
},
"include": ["src"]
"resolveJsonModule": true,
"suppressImplicitAnyIndexErrors": true
}
}
16 changes: 16 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"help": "Need help? https://github.com/ArthurFiorette/steam-trader",
"steam": {
"username": "username",
"password": "password",
"sharedSecret": "shared secret",
"identitySecret": "identity secret"
},
"info": {
"gameId": 730
},
"trading": {
"trashValue": 0.04,
"ownerId": 76561198850668121
}
}
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
app:
build: src/
ports: '1227:1227'
build: app/
ports: '${PORT}:1227'
env_file:
- '.env'
- './app/.env'
Loading

0 comments on commit 667ece4

Please sign in to comment.