From 788e40f07680ff9c96fa3a0bebb7711fa30a9bbc Mon Sep 17 00:00:00 2001 From: chr Date: Mon, 18 Feb 2019 15:27:22 -0800 Subject: [PATCH 1/4] Add /shrug command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Certain popular web-based chat systems support a `/shrug` command which appends the ¯\\_(ツ)_/¯ text emoticon (kaomoji) to a message. I've often found myself wishing Riot had something similar, so I decided to add it myself. (If Riot ever gets a user-extensible /-command system, this will probably no longer be necessary. But since it doesn't have that, here I am). Doesn't support markdown / rich text messages because I didn't want to dig that far into Riot/the SDKs for my first PR; if someone else would like to add that, by all means. Signed-off-by: Andrew Chronister --- src/SlashCommands.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/SlashCommands.js b/src/SlashCommands.js index 115cf0e018..d675500f07 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -70,6 +70,19 @@ function success(promise) { /* eslint-disable babel/no-invalid-this */ export const CommandMap = { + shrug: new Command({ + name: 'shrug', + args: '', + description: _td('Prepends ¯\\_(ツ)_/¯ to a plain-text message'), + runFn: function(roomId, args) { + var message = '¯\\_(ツ)_/¯' + if (args) { + message = message + ' ' + args + } + return success(MatrixClientPeg.get().sendTextMessage(roomId, message)); + } + }), + ddg: new Command({ name: 'ddg', args: '', From 32f96788f138e56ff8a783971177d6f2f4e778fb Mon Sep 17 00:00:00 2001 From: Andrew Chronister Date: Mon, 18 Feb 2019 15:46:54 -0800 Subject: [PATCH 2/4] Add to en_US i18n --- src/i18n/strings/en_US.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 7139f704b3..93aa52fd05 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -261,6 +261,7 @@ "%(senderName)s placed a %(callType)s call.": "%(senderName)s placed a %(callType)s call.", "Please check your email and click on the link it contains. Once this is done, click continue.": "Please check your email and click on the link it contains. Once this is done, click continue.", "Power level must be positive integer.": "Power level must be positive integer.", + "Prepends ¯\\_(ツ)_/¯ to a plain-text message": "Prepends ¯\\_(ツ)_/¯ to a plain-text message", "Privacy warning": "Privacy warning", "Privileged Users": "Privileged Users", "Profile": "Profile", From 12c1e82f111fbe9508c5d089993608f1d36232f7 Mon Sep 17 00:00:00 2001 From: Andrew Chronister Date: Tue, 19 Feb 2019 21:45:16 -0800 Subject: [PATCH 3/4] s/var/let --- src/SlashCommands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SlashCommands.js b/src/SlashCommands.js index d675500f07..00afc1a4ee 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -75,7 +75,7 @@ export const CommandMap = { args: '', description: _td('Prepends ¯\\_(ツ)_/¯ to a plain-text message'), runFn: function(roomId, args) { - var message = '¯\\_(ツ)_/¯' + let message = '¯\\_(ツ)_/¯' if (args) { message = message + ' ' + args } From 250341ec4dd394266d0678dbc841c665dcd060ef Mon Sep 17 00:00:00 2001 From: Andrew Chronister Date: Tue, 19 Feb 2019 21:46:17 -0800 Subject: [PATCH 4/4] Miscellaneous style issues --- src/SlashCommands.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SlashCommands.js b/src/SlashCommands.js index 00afc1a4ee..7d5fc4d355 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -75,12 +75,12 @@ export const CommandMap = { args: '', description: _td('Prepends ¯\\_(ツ)_/¯ to a plain-text message'), runFn: function(roomId, args) { - let message = '¯\\_(ツ)_/¯' + let message = '¯\\_(ツ)_/¯'; if (args) { - message = message + ' ' + args + message = message + ' ' + args; } return success(MatrixClientPeg.get().sendTextMessage(roomId, message)); - } + }, }), ddg: new Command({