Skip to content

Commit 5851883

Browse files
authored
Merge pull request #31 from github/add_mention_slug
Add support for mention_slug parameter
2 parents f0414af + bd1f2b4 commit 5851883

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ this regex. Arguments will be available in the `params` hash. `params[:user]`
9393
and `params[:room_id]` are special, and will be set by the client. `user` will
9494
always be the login of the user typing the command, and `room_id` will be where
9595
it was typed.
96+
The optional `mention_slug` parameter will provide the name to use to refer to
97+
the user when sending a message; this may or may not be the same thing as the
98+
username, depending on the chat system being used.
9699

97100
You can return `jsonrpc_success` with a string to return text to chat. If you
98101
have an input validation or other handle-able error, you can use

docs/protocol-description.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ chat message matches a command's regex matcher, the CRPC client creates a method
4343
invocation. A method invocation is a JSON object with the following fields:
4444

4545
* `user`: A slug username corresponding to to the command giver's GitHub login.
46+
* `mention_slug`: Optional. If provided, a string which should be used to mention the user when sending a message in response. For example, Slack requires that users be mentioned using user IDs instead of usernames.
4647
* `room_id`: A slug room name where the command originated.
4748
* `method`: The method name, without namespace, of the matching regex.
4849
* `params`: A mapping of parameter names to matches extracted from named capture groups in the command's regex. Parameters that are empty or null should not be passed.

lib/chatops/controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def list
2828

2929
def process(*args)
3030
scrubbed_params = jsonrpc_params.except(
31-
:user, :method, :controller, :action, :params, :room_id)
31+
:user, :mention_slug, :method, :controller, :action, :params, :room_id)
3232

3333
scrubbed_params.each { |k, v| params[k] = v }
3434

0 commit comments

Comments
 (0)