Skip to content

Commit

Permalink
Merge pull request #90 from MichaelJolley/features/repo-command
Browse files Browse the repository at this point in the history
Sending !theme repo now sends info about the GH repo to chat.  Closes…
  • Loading branch information
michaeljolley authored Jun 25, 2019
2 parents bb334e5 + e433505 commit bc69db9
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- New `!theme repo` will now send a message to chat with information about the extensions GitHub repo.
- Added the `!theme help` command to explain to chat how to use the extensions commands

---
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ This will send the currently active theme to Twitch chat.
!theme current
```

#### Send info about this GitHub repo to chat

This will send a message to Twitch chat letting everyone know where to access the source for this extension.

```
!theme repo
```

#### Explain how to use the extensions commands

This will send a message to Twitch chat explaining the available commands.
Expand Down
17 changes: 15 additions & 2 deletions src/commands/Themer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export class Themer {
}
}


public async handleChatConnectionChanged(signedIn: boolean) {
if (signedIn) {
if (keytar) {
Expand Down Expand Up @@ -171,6 +170,9 @@ export class Themer {
case 'refresh':
await this.refreshThemes(twitchUser);
break;
case 'repo':
await this.repo();
break;
case 'ban':
if (username !== undefined) {
await this.ban(twitchUser, username);
Expand Down Expand Up @@ -430,7 +432,8 @@ export class Themer {
}
} else {
this.sendMessageEventEmitter.fire(
`${twitchDisplayName}, ${themeName} is not a valid theme name or isn't installed. You can use !theme to get a list of available themes.`
`${twitchDisplayName}, ${themeName} is not a valid theme name or \
isn't installed. You can use !theme to get a list of available themes.`
);
}
}
Expand All @@ -445,6 +448,16 @@ export class Themer {
this.sendMessageEventEmitter.fire(`The current theme is ${currentTheme}`);
}

/**
* Announces to chat info about the extensions GitHub repository
*/
private async repo() {
const repoMessage = 'You can find the source code for this VS \
Code extension at https://github.com/MichaelJolley/vscode-twitch-themer. \
Feel free to Fork & contribute.';
this.sendMessageEventEmitter.fire(repoMessage);
}

/**
* Announces to chat a message with a brief explanation of how to use the commands
*/
Expand Down
25 changes: 25 additions & 0 deletions src/test/themer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@ suite('Themer Tests', function() {
});
});

test(`Themer should return info about the GitHub repo`, function(done) {
let sentMessage: string = '';
const sendMessageStub = sinon
.stub(fakeChatClient, 'sendMessage')
.callsFake((message: string) => {
sentMessage = message;
});
fakeThemer.onSendMesssage(sendMessageStub);

const message = 'repo';
const chatMessage: IChatMessage = { message, userState: user };

fakeThemer.handleCommands(chatMessage).then(() => {
try {
sendMessageStub.calledOnce.should.be.true;
sentMessage.should.equal('You can find the source code for this VS \
Code extension at https://github.com/MichaelJolley/vscode-twitch-themer. \
Feel free to Fork & contribute.');
done();
} catch (error) {
done(error);
}
});
});

test('Themer should reset theme to original theme when requested', function(done) {
fakeWorkspaceConfiguration.update('workbench.colorTheme', testTheme);

Expand Down

0 comments on commit bc69db9

Please sign in to comment.