Skip to content

Commit

Permalink
add !refreshautokeys command
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 committed Aug 2, 2020
1 parent e9c5ca5 commit f359180
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The original tf2-automatic repository already have a lot of features, but some f
- automatically restart your bot on queue problem, and automatically relist if backpack.tf does not synchronized with your bot listings on Autokeys (sometimes it's set to automatically buy keys, but at backpack.tf, it's listed to sell.)
- use emojis on almost all messages
- list out every items on each offer review reasons
- New added commands: "!pure", "!time", "!delete", "!check", "!block", "!unblock", "!autokeys", "!inventory", "!adjustrate", "!relist", "!craftweapon" and "!uncraftweapon" commands
- New added commands: "!pure", "!time", "!delete", "!check", "!block", "!unblock", "!autokeys", "!refreshautokeys", "!inventory", "!relist", "!craftweapon" and "!uncraftweapon" commands
- and more to come!

## Added features
Expand Down
15 changes: 15 additions & 0 deletions src/classes/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const ADMIN_COMMANDS: string[] = [
'!restart - Restart the bot 🔄',
'!version - Get version that the bot is running',
'!autokeys - Get info on your current autoBuy/Sell Keys settings 🔑',
'!resfreshautokeys - Refresh your autokeys settings.',
'!avatar <image_URL> - Change avatar',
'!name <new_name> - Change name',
'!block <steamid> - Block a specific user',
Expand Down Expand Up @@ -136,6 +137,8 @@ export = class Commands {
this.timeCommand(steamID);
} else if (command === 'autokeys' && isAdmin) {
this.autoKeysCommand(steamID);
} else if (command === 'refreshautokeys' && isAdmin) {
this.refreshAutokeysCommand(steamID);
} else if (command === 'craftweapon') {
this.craftweaponCommand(steamID);
} else if (command === 'uncraftweapon') {
Expand Down Expand Up @@ -575,6 +578,18 @@ export = class Commands {
this.bot.sendMessage(steamID, '/pre ' + reply);
}

private refreshAutokeysCommand(steamID: SteamID): void {
const autokeys = (this.bot.handler as MyHandler).getUserAutokeys();

if (autokeys.enabled === false) {
this.bot.sendMessage(steamID, `This feature is disabled.`);
return;
}

(this.bot.handler as MyHandler).refreshAutokeys();
this.bot.sendMessage(steamID, '✅ Successfully refreshed Autokeys.');
}

private rateCommand(steamID: SteamID): void {
const keyPrice = this.bot.pricelist.getKeyPrice().toString();

Expand Down
13 changes: 13 additions & 0 deletions src/classes/MyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2210,6 +2210,19 @@ Autokeys status:-
});
}

refreshAutokeys(): void {
this.removeAutoKeys();
this.isBuyingKeys = false;
this.isBankingKeys = false;
this.checkAutokeysStatus = false;
this.checkAlertOnLowPure = false;
this.alreadyUpdatedToBank = false;
this.alreadyUpdatedToBuy = false;
this.alreadyUpdatedToSell = false;
this.sleep(2000);
this.autokeys();
}

private keepMetalSupply(): void {
if (process.env.DISABLE_CRAFTING === 'true') {
return;
Expand Down

0 comments on commit f359180

Please sign in to comment.