Skip to content

Commit

Permalink
Error messages refactoring
Browse files Browse the repository at this point in the history
Resolves #5
  • Loading branch information
David Arutiunian committed Jan 24, 2019
1 parent 8c9647c commit 6cf09dd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/entities/steam-bot/SteamBot.ts
Expand Up @@ -111,16 +111,16 @@ export class SteamBot extends EventEmitter {
this.client.webLogOn();
} else {
if (!config.bot.sharedSecret) {
this.emit(EBotEvents.ERROR, new Error('No `sharedSecret` specified for bot!'));
this.emit(EBotEvents.ERROR, new Error('No `STEAM_SHARED_SECRET` specified for bot!'));
return;
}
const tfa = this.totp.getAuthCode(config.bot.sharedSecret);
if (!config.bot.accountName) {
this.emit(EBotEvents.ERROR, new Error('No `accountName` specified for bot!'));
this.emit(EBotEvents.ERROR, new Error('No `STEAM_ACCOUNT_NAME` specified for bot!'));
return;
}
if (!config.bot.password) {
this.emit(EBotEvents.ERROR, new Error('No `accountName` specified for bot!'));
this.emit(EBotEvents.ERROR, new Error('No `STEAM_ACCOUNT_NAME` specified for bot!'));
return;
}
this.client.logOn({
Expand Down
Expand Up @@ -52,7 +52,7 @@ export class SteamOfferController {

private getNextReceivedItem(item: object): object | undefined {
if (!config.bot.steamId) {
this.bot.emit(EBotEvents.ERROR, new Error('No `steamId` specified for bot!'));
this.bot.emit(EBotEvents.ERROR, new Error('No `STEAM_ID` specified for bot!'));
return;
}
return {
Expand Down
8 changes: 4 additions & 4 deletions src/entities/steam-bot/controllers/steam-user/SteamUser.ts
Expand Up @@ -37,7 +37,7 @@ export class SteamUserController {

public onSteamGuard(_domain: unknown, callback: (code: string) => void): void {
if (!config.bot.sharedSecret) {
this.bot.emit(EBotEvents.ERROR, new Error('No `sharedSecret` specified for bot!'));
this.bot.emit(EBotEvents.ERROR, new Error('No `STEAM_SHARED_SECRET` specified for bot!'));
return;
}
const code = this.bot.totp.getAuthCode(config.bot.sharedSecret);
Expand All @@ -54,7 +54,7 @@ export class SteamUserController {
this.bot.client.setPersona(SteamUser.EPersonaState.Online);
setTimeout(() => {
if (!config.bot.steamId) {
this.bot.emit(EBotEvents.ERROR, new Error('No `steamId` specified for bot!'));
this.bot.emit(EBotEvents.ERROR, new Error('No `STEAM_ID` specified for bot!'));
return;
}
this.bot.client.getPersonas([config.bot.steamId], this.onGetPersonas);
Expand All @@ -67,12 +67,12 @@ export class SteamUserController {
if (!this.bot.statuses[EBotStatuses.BLOCKED]) {
this.bot.client.gamesPlayed([config.app.game]);
} else {
this.bot.emit(EBotEvents.ERROR, new Error('Bot got `blocked` state!'));
this.bot.emit(EBotEvents.ERROR, new Error('SteamBot got `BLOCKED` state!'));
return;
}
setTimeout(() => {
if (!config.bot.steamId) {
this.bot.emit(EBotEvents.ERROR, new Error('No `steamId` specified for bot!'));
this.bot.emit(EBotEvents.ERROR, new Error('No `STEAM_ID` specified for bot!'));
return;
}
this.bot.client.getPersonas([config.bot.steamId], this.onGetPersonasSecondTime);
Expand Down
4 changes: 2 additions & 2 deletions src/services/steam-bot/SteamBot.ts
Expand Up @@ -61,7 +61,7 @@ export function processMarketItem(

export function getNextMyItem(item: object): object | undefined {
if (!config.bot.steamId) {
logger.error(ServerSanitizer.message(), new Error('No `steamId` specified for bot!'));
logger.error(ServerSanitizer.message(), new Error('No `STEAM_ID` specified for bot!'));
return;
}
return {
Expand All @@ -88,7 +88,7 @@ export function getNextMyItem(item: object): object | undefined {

export function getNextTheirItem(item: object): object | undefined {
if (!config.bot.steamId) {
logger.error(ServerSanitizer.message(), new Error('No `steamId` specified for bot!'));
logger.error(ServerSanitizer.message(), new Error('No `STEAM_ID` specified for bot!'));
return;
}
return {
Expand Down
2 changes: 1 addition & 1 deletion src/services/steam-totp/SteamTotp.ts
Expand Up @@ -19,7 +19,7 @@ export class SteamTotp {
public getConfirmationKeys(): [number, string, string] {
const time = Math.floor(Date.now() / 1000);
if (!config.bot.identitySecret) {
throw new Error('No `identitySecret` specified for bot!');
throw new Error('No `STEAM_IDENTITY_SECRET` specified for bot!');
}
const confKey = SteamTotpPkg.getConfirmationKey(config.bot.identitySecret, time, 'conf');
const allowKey = SteamTotpPkg.getConfirmationKey(config.bot.identitySecret, time, 'allow');
Expand Down

0 comments on commit 6cf09dd

Please sign in to comment.