Skip to content
This repository has been archived by the owner on Nov 4, 2019. It is now read-only.

Commit

Permalink
Fixed inconsistent API with docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatih Kalifa committed Aug 6, 2015
1 parent af07a89 commit db284dc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ Example:

`.replyTextDM(message : string) : Promise`

- Send message to specific channel:
- Send message to specific channel/group/user:

`.sendTo(channelName : string, response : SlackResponseObject) : Promise`
`.sendTo(target : string, response : SlackResponseObject) : Promise`

- Syntactic sugar to send only text to specific channel:
- Syntactic sugar to send only text to specific channel/group/user:

`.sendTextTo(channelName : string, message : string) : Promise`
`.sendTextTo(target : string, message : string) : Promise`

- Format the username so that slack will recognize as mention. **Leading @ character is optional.**:

Expand Down
6 changes: 3 additions & 3 deletions lib/BaseAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class BaseAction {
return this.replyDM({text: message});
}

replyTo(name, response) {
sendTo(name, response) {
response.as_user = true;

return new Promise((resolve, reject) => {
Expand All @@ -43,8 +43,8 @@ export default class BaseAction {
});
}

replyTextTo(name, message) {
return this.replyTo(name, {text: message});
sendTextTo(name, message) {
return this.sendTo(name, {text: message});
}

sendDM_(user, response) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "slack-robot",
"version": "1.0.2",
"version": "1.0.3",
"description": "Simple robot for your slack integration",
"main": "src/Robot.js",
"scripts": {
"test": "mocha --compilers js:babel/register tests/**/**/*.js",
"coverage": "istanbul cover _mocha tests/**/*.js -- --compilers js:babel/register",
"coveralls": "istanbul cover _mocha tests/**/*.js --report lcovonly -- --compilers js:babel/register && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"prepublish": "babel -d src/ lib/ && mkdir -p action && cp src/BaseAction.js action/ && sed -i 's/\\.\\/BaseAction/\\.\\.\\/action\\/BaseAction/g' src/NeuronListener.js"
"prepublish": "babel -d src/ lib/ && mkdir -p action && mv src/BaseAction.js action/ && sed -i 's/\\.\\/BaseAction/\\.\\.\\/action\\/BaseAction/g' src/NeuronListener.js"
},
"repository": {
"type": "git",
Expand Down
14 changes: 7 additions & 7 deletions tests/test_BaseAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('action/BaseAction', () => {
});
});

it('should be able to reply to specific channel/group/dm', done => {
it('should be able to send response to specific channel/group/dm instead of reply', done => {
var action = new BaseAction(robot);
var response = {specific: 'channel/group/dm'};

Expand All @@ -102,21 +102,21 @@ describe('action/BaseAction', () => {
var chatStub = {postMessage: sinon.stub()};
robot.slack_.getChannelGroupOrDMByName.returns(chatStub);

action.payload(payload).replyTo('#general', response).then(() => {
action.payload(payload).sendTo('#general', response).then(() => {
robot.slack_.getChannelGroupOrDMByName.should.be.calledWith('#general');
chatStub.postMessage.should.be.calledWith({as_user: true, specific: 'channel/group/dm'});
done();
});
});

it('should be able to reply text to specific channel/group/DM', done => {
it('should be able to send text to specific channel/group/DM', done => {
var action = new BaseAction(robot);
var message = 'message for specific channel/group/dm';
var replyToStub = sinon.stub(BaseAction.prototype, 'replyTo').returns(Promise.resolve());
var sendToStub = sinon.stub(BaseAction.prototype, 'sendTo').returns(Promise.resolve());

action.payload(payload).replyTextTo('#general', message).then(() => {
replyToStub.should.be.calledWith('#general', {text: message})
replyToStub.restore();
action.payload(payload).sendTextTo('#general', message).then(() => {
sendToStub.should.be.calledWith('#general', {text: message})
sendToStub.restore();
done();
});
});
Expand Down

0 comments on commit db284dc

Please sign in to comment.