Skip to content

Commit

Permalink
add an option to customize playing game name
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 committed Jul 17, 2020
1 parent 89821d3 commit dfa03ab
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ What the trade partner will received: "Dueling Mini-Game, Secret Saxton are not


### Others
- `CUSTOM_PLAYING_GAME_NAME` - Custom name of the game your bot is playing. Limited to only 45 characters. Example: https://gyazo.com/308e4e05bf4c49929520df4e0064864c.

- `CUSTOM_WELCOME_MESSAGE` - Your custom WELCOME_MESSAGE note. Two parameters: `%name%` (display trade partner name) and `%admin%` (if admin, it will use "!help", else "!how2trade").
- `CUSTOM_I_DONT_KNOW_WHAT_YOU_MEAN` - Your custom note when people sends wrong command.
- `CUSTOM_HOW2TRADE_MESSAGE` - Your custom HOW2TRADE note.
Expand Down
21 changes: 18 additions & 3 deletions src/classes/MyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export = class MyHandler extends Handler {

private autoRelistNotBuyingKeys = 0;

private customGameName: string;

recentlySentMessage: UnknownDictionary<number> = {};

constructor(bot: Bot) {
Expand Down Expand Up @@ -124,6 +126,19 @@ export = class MyHandler extends Handler {
this.invalidValueExceptionSKU = [';5;u', ';11;australium'];
}

if (process.env.CUSTOM_PLAYING_GAME_NAME === 'tf2-automatic') {
this.customGameName = process.env.CUSTOM_PLAYING_GAME_NAME;
} else {
if (process.env.CUSTOM_PLAYING_GAME_NAME.length <= 45) {
this.customGameName = process.env.CUSTOM_PLAYING_GAME_NAME + ' - tf2-automatic';
} else {
log.warn(
'Your custom game playing name is more than 45 characters, resetting to only "tf2-automatic"...'
);
this.customGameName = 'tf2-automatic';
}
}

const exceptionRefFromEnv = exceptionRef === 0 || isNaN(exceptionRef) ? 0 : exceptionRef;
this.invalidValueException = Currencies.toScrap(exceptionRefFromEnv);

Expand Down Expand Up @@ -254,7 +269,7 @@ export = class MyHandler extends Handler {
')'
);

this.bot.client.gamesPlayed(['tf2-automatic', 440]);
this.bot.client.gamesPlayed([this.customGameName, 440]);
this.bot.client.setPersona(SteamUser.EPersonaState.Online);

// Smelt / combine metal if needed
Expand Down Expand Up @@ -304,7 +319,7 @@ export = class MyHandler extends Handler {
onLoggedOn(): void {
if (this.bot.isReady()) {
this.bot.client.setPersona(SteamUser.EPersonaState.Online);
this.bot.client.gamesPlayed(['tf2-automatic', 440]);
this.bot.client.gamesPlayed([this.customGameName, 440]);
}
}

Expand Down Expand Up @@ -2808,6 +2823,6 @@ Autokeys status:-

onTF2QueueCompleted(): void {
log.debug('Queue finished');
this.bot.client.gamesPlayed(['tf2-automatic', 440]);
this.bot.client.gamesPlayed([this.customGameName, 440]);
}
};
2 changes: 2 additions & 0 deletions template.ecosystem.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
"DUPE_CHECK_FAILED_NOTE": "",
"ADDITIONAL_NOTE": "",

"CUSTOM_PLAYING_GAME_NAME": "tf2-automatic",

"CUSTOM_WELCOME_MESSAGE": "",
"CUSTOM_I_DONT_KNOW_WHAT_YOU_MEAN": "",
"CUSTOM_HOW2TRADE_MESSAGE": "",
Expand Down
2 changes: 2 additions & 0 deletions template.env
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ DUPE_ITEMS_NOTE=""
DUPE_CHECK_FAILED_NOTE=""
ADDITIONAL_NOTE=""

CUSTOM_PLAYING_GAME_NAME="tf2-automatic"

CUSTOM_WELCOME_MESSAGE=""
CUSTOM_I_DONT_KNOW_WHAT_YOU_MEAN=""
CUSTOM_HOW2TRADE_MESSAGE=""
Expand Down

0 comments on commit dfa03ab

Please sign in to comment.