Unverified Commit 5aa19523 authored by Bradley Hilton's avatar Bradley Hilton
Browse files

Make the asciiart rocketlet configurable for which ones to add

parent c9bad65e
......@@ -5276,14 +5276,14 @@
}
},
"temporary-rocketlets-server": {
"version": "0.1.32",
"resolved": "https://registry.npmjs.org/temporary-rocketlets-server/-/temporary-rocketlets-server-0.1.32.tgz",
"integrity": "sha512-8x0d0iWJ7sYb8T6kiTKTEP95vNsMeELx7cgMg/fFbRRr55boYG9en2srWDJ6NPw7UTuEx8qkDp0dsj2uMCmE7A==",
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/temporary-rocketlets-server/-/temporary-rocketlets-server-0.2.1.tgz",
"integrity": "sha512-4E5YVOhQ1tHo7a+2b7128btv4atm/eaMJxm2FR1nyZatTqLWSDzG+n9bwxlpA9QM8SoznDaONuaQuW/Qu3hlHA==",
"requires": {
"adm-zip": "0.4.7",
"semver": "5.4.1",
"stack-trace": "0.0.10",
"temporary-rocketlets-ts-definition": "0.6.31",
"temporary-rocketlets-ts-definition": "0.6.33",
"typescript": "2.4.1",
"uuid": "3.1.0"
},
......@@ -5296,9 +5296,9 @@
}
},
"temporary-rocketlets-ts-definition": {
"version": "0.6.31",
"resolved": "https://registry.npmjs.org/temporary-rocketlets-ts-definition/-/temporary-rocketlets-ts-definition-0.6.31.tgz",
"integrity": "sha512-pR0Z83vMmliVAkanMpfgrpncKvAjaL4HO7Zqsrkht+dEmTuo4BgGlC9lmUo1tB6sV2TOSP8oACGbzL4Y6SQwdg==",
"version": "0.6.33",
"resolved": "https://registry.npmjs.org/temporary-rocketlets-ts-definition/-/temporary-rocketlets-ts-definition-0.6.33.tgz",
"integrity": "sha512-N0076Goa3HOixDWw4u+WcPF4TvQs+hk/ACgBTPw8P8Wh46oxvMDnJ3P03/k8LIGOpFDntGXGgEoy2rR2xFEbPQ==",
"requires": {
"reflect-metadata": "0.1.10"
}
......
......@@ -4,15 +4,134 @@ import { ShrugCommand } from './commands/ShrugCommand';
import { TableflipCommand } from './commands/TableflipCommand';
import { UnflipCommand } from './commands/UnflipCommand';
import { IConfigurationExtend } from 'temporary-rocketlets-ts-definition/accessors';
import {
IConfigurationExtend,
IConfigurationModify,
IEnvironmentRead,
IHttp,
IRead,
} from 'temporary-rocketlets-ts-definition/accessors';
import { Rocketlet } from 'temporary-rocketlets-ts-definition/Rocketlet';
import { ISetting, SettingType } from 'temporary-rocketlets-ts-definition/settings';
export class AsciiArtCommandsRocketlet extends Rocketlet {
private gimmeId = 'gimmie_cmd';
private lennyId = 'lenny_cmd';
private shrugId = 'shrug_cmd';
private flipId = 'flip_cmd';
private unflipId = 'unflip_cmd';
public onEnable(environmentRead: IEnvironmentRead, configModify: IConfigurationModify): boolean {
const sets = environmentRead.getSettings();
this.enableOrDisableCommand(this.gimmeId, sets.getValueById(this.gimmeId), configModify);
this.enableOrDisableCommand(this.lennyId, sets.getValueById(this.lennyId), configModify);
this.enableOrDisableCommand(this.shrugId, sets.getValueById(this.shrugId), configModify);
this.enableOrDisableCommand(this.flipId, sets.getValueById(this.flipId), configModify);
this.enableOrDisableCommand(this.unflipId, sets.getValueById(this.unflipId), configModify);
return true;
}
public onSettingUpdated(setting: ISetting, configModify: IConfigurationModify, read: IRead, http: IHttp): void {
this.enableOrDisableCommand(setting.id, setting.value as boolean, configModify);
}
protected extendConfiguration(configuration: IConfigurationExtend): void {
configuration.settings.provideSetting({
id: this.gimmeId,
type: SettingType.BOOLEAN,
packageValue: true,
required: false,
public: false,
i18nLabel: 'Enable_Gimme_Command',
i18nDescription: 'Enable_Gimme_Command_Description',
});
configuration.settings.provideSetting({
id: this.lennyId,
type: SettingType.BOOLEAN,
packageValue: true,
required: false,
public: false,
i18nLabel: 'Enable_Lenny_Command',
i18nDescription: 'Enable_Lenny_Command_Description',
});
configuration.settings.provideSetting({
id: this.shrugId,
type: SettingType.BOOLEAN,
packageValue: true,
required: false,
public: false,
i18nLabel: 'Enable_Shrug_Command',
i18nDescription: 'Enable_Shrug_Command_Description',
});
configuration.settings.provideSetting({
id: this.flipId,
type: SettingType.BOOLEAN,
packageValue: true,
required: false,
public: false,
i18nLabel: 'Enable_Tableflip_Command',
i18nDescription: 'Enable_Tableflip_Command_Description',
});
configuration.settings.provideSetting({
id: this.unflipId,
type: SettingType.BOOLEAN,
packageValue: true,
required: false,
public: false,
i18nLabel: 'Enable_Unflip_Table_Command',
i18nDescription: 'Enable_Unflip_Table_Command_Description',
});
configuration.slashCommands.provideSlashCommand(new GimmeCommand());
configuration.slashCommands.provideSlashCommand(new LennyCommand());
configuration.slashCommands.provideSlashCommand(new ShrugCommand());
configuration.slashCommands.provideSlashCommand(new TableflipCommand());
configuration.slashCommands.provideSlashCommand(new UnflipCommand());
}
private enableOrDisableCommand(id: string, doEnable: boolean, configModify: IConfigurationModify): void {
switch (id) {
case this.gimmeId:
if (doEnable) {
configModify.slashCommands.enableSlashCommand(GimmeCommand.CommandName);
} else {
configModify.slashCommands.disableSlashCommand(GimmeCommand.CommandName);
}
return;
case this.lennyId:
if (doEnable) {
configModify.slashCommands.enableSlashCommand(LennyCommand.CommandName);
} else {
configModify.slashCommands.disableSlashCommand(LennyCommand.CommandName);
}
return;
case this.shrugId:
if (doEnable) {
configModify.slashCommands.enableSlashCommand(ShrugCommand.CommandName);
} else {
configModify.slashCommands.disableSlashCommand(ShrugCommand.CommandName);
}
return;
case this.flipId:
if (doEnable) {
configModify.slashCommands.enableSlashCommand(TableflipCommand.CommandName);
} else {
configModify.slashCommands.disableSlashCommand(TableflipCommand.CommandName);
}
return;
case this.unflipId:
if (doEnable) {
configModify.slashCommands.enableSlashCommand(UnflipCommand.CommandName);
} else {
configModify.slashCommands.disableSlashCommand(UnflipCommand.CommandName);
}
return;
}
}
}
......@@ -2,7 +2,9 @@ import { IHttp, IModify, IRead } from 'temporary-rocketlets-ts-definition/access
import { ISlashCommand, SlashCommandContext } from 'temporary-rocketlets-ts-definition/slashcommands';
export class GimmeCommand implements ISlashCommand {
public command: string = 'gimme';
public static CommandName = 'gimme';
public command: string = GimmeCommand.CommandName;
public paramsExample: string = 'your_message_optional';
public i18nDescription: string = 'Slash_Gimme_Description';
......
......@@ -2,7 +2,9 @@ import { IHttp, IModify, IRead, ISettingRead } from 'temporary-rocketlets-ts-def
import { ISlashCommand, SlashCommandContext } from 'temporary-rocketlets-ts-definition/slashcommands';
export class LennyCommand implements ISlashCommand {
public command: string = 'lennyface';
public static CommandName = 'lennyface';
public command: string = LennyCommand.CommandName;
public paramsExample: string = 'your_message_optional';
public i18nDescription: string = 'Slash_LennyFace_Description';
......
......@@ -2,7 +2,9 @@ import { IHttp, IModify, IRead, ISettingRead } from 'temporary-rocketlets-ts-def
import { ISlashCommand, SlashCommandContext } from 'temporary-rocketlets-ts-definition/slashcommands';
export class ShrugCommand implements ISlashCommand {
public command: string = 'shrug';
public static CommandName = 'shrug';
public command: string = ShrugCommand.CommandName;
public paramsExample: string = 'your_message_optional';
public i18nDescription: string = 'Slash_Shrug_Description';
......
......@@ -2,7 +2,9 @@ import { IHttp, IModify, IRead, ISettingRead } from 'temporary-rocketlets-ts-def
import { ISlashCommand, SlashCommandContext } from 'temporary-rocketlets-ts-definition/slashcommands';
export class TableflipCommand implements ISlashCommand {
public command: string = 'tableflip';
public static CommandName = 'tableflip';
public command: string = TableflipCommand.CommandName;
public paramsExample: string = 'your_message_optional';
public i18nDescription: string = 'Slash_Tableflip_Description';
......
......@@ -2,7 +2,9 @@ import { IHttp, IModify, IRead, ISettingRead } from 'temporary-rocketlets-ts-def
import { ISlashCommand, SlashCommandContext } from 'temporary-rocketlets-ts-definition/slashcommands';
export class UnflipCommand implements ISlashCommand {
public command: string = 'unflip';
public static CommandName = 'unflip';
public command: string = UnflipCommand.CommandName;
public paramsExample: string = 'your_message_optional';
public i18nDescription: string = 'Slash_TableUnflip_Description';
......
{
"Enable_Gimme_Command": "Enable the Gimme Command",
"Enable_Gimme_Command_Description": "Whether or not the `/gimme` command should be enabled.",
"Enable_Lenny_Command": "Enable the Lenny Command",
"Enable_Lenny_Command_Description": "Whether or not the `/lenny` command should be enabled.",
"Enable_Shrug_Command": "Enable the Shrug Command",
"Enable_Shrug_Command_Description": "Whether or not the `/shrug` command should be enabled.",
"Enable_Tableflip_Command": "Enable the Tableflip Command",
"Enable_Tableflip_Command_Description": "Whether or not the `/tableflip` command should be enabled.",
"Enable_Unflip_Table_Command": "Enable the Unflip Table Command",
"Enable_Unflip_Table_Description": "Whether or not the `/unflip` command should be enabled."
}
......@@ -3,12 +3,13 @@
"name": "ASCII Art Commands",
"nameSlug": "asciiart-commands",
"description": "Provides neat little asciiart commands for fun usage.",
"version": "1.0.0",
"version": "1.0.1",
"requiredApiVersion": ">=0.6.1",
"author": {
"name": "Bradley Hilton",
"homepage": "https://github.com/graywolf336/temporary-rocketlets-dev-environment",
"support": "https://github.com/graywolf336/temporary-rocketlets-dev-environment/issues"
},
"classFile": "AsciiArtCommandsRocketlet.ts"
"classFile": "AsciiArtCommandsRocketlet.ts",
"iconFile": "icon.png"
}
......@@ -66,7 +66,7 @@ export class GuggyRocketlet extends Rocketlet {
configModify.slashCommands.enableSlashCommand('guggy');
} catch (e) {
// Not valid api key
this.getLogger().log('Disabling the slash command because the api eky isnt valid.');
this.getLogger().log('Disabling the slash command because the api key isnt valid.');
configModify.slashCommands.disableSlashCommand('guggy');
}
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment