Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require commands be uppercase when using !cmd #1823

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1823.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In `!cmd`, don't require commands be all uppercase.
6 changes: 2 additions & 4 deletions spec/integ/admin-rooms.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,14 +885,12 @@ describe("Admin rooms", function() {
cmdIx++;
});

// 5 commands should be executed
// rubbishserver should not be accepted
// 4 commands should be executed
const commands = [
`!cmd ${roomMapping.server} JOIN ${newChannel}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to test lower case though?

`!cmd ${roomMapping.server} TOPIC ${newChannel} :some new fancy topic`,
`!cmd ${roomMapping.server} PART ${newChannel}`,
`!cmd ${roomMapping.server} STUPID COMMANDS`,
`!cmd rubbishserver SOME COMMAND`];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we've lost the test for an invalid server here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change "rubbishserver" is now interpreted as a command rather than as a server.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right...we still need to interpret servers here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are interpreted correctly when valid, but rubbishserver matches the new regex.

Perhaps that could be replaced by rubbish^server! or something?

`!cmd ${roomMapping.server} STUPID COMMANDS`];

for (let i = 0; i < commands.length; i++) {
// send commands
Expand Down
6 changes: 3 additions & 3 deletions src/bridge/AdminRoomHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ const COMMANDS: {[command: string]: Command|Heading} = {
'Actions': { heading: true },
"cmd": {
example: `!cmd [irc.example.net] COMMAND [arg0 [arg1 [...]]]`,
summary: "Issue a raw IRC command. These will not produce a reply." +
summary: "Issue a raw IRC command. These will not produce a reply. " +
"(Note that the command must be all uppercase.)",
},
"feature": {
example: `!feature feature-name [true/false/default]`,
summary: `Enable, disable or default a feature's status for your account.` +
summary: `Enable, disable or default a feature's status for your account. ` +
`Will display the current feature status if true/false/default not given.`,
},
"join": {
Expand Down Expand Up @@ -428,7 +428,7 @@ export class AdminRoomHandler {
const keyword = args[0];

// keyword could be a failed server or a malformed command
if (!keyword.match(/^[A-Z]+$/)) {
if (!keyword.match(/^[A-Za-z]+$/)) {
// if not a domain OR is only word (which implies command)
if (!keyword.match(/^[a-z0-9:\.-]+$/) || args.length === 1) {
throw new Error(`Malformed command: ${keyword}`);
Expand Down
Loading