bottender
Advanced tools
Comparing version 0.14.14 to 0.14.15
@@ -0,1 +1,17 @@ | ||
# 0.14.15 / 2018-01-12 | ||
### slack | ||
* [new] Add `context.postEphemeral`: | ||
```js | ||
context.postEphemeral({ text: 'hello' }); | ||
``` | ||
* [fix] Reply to thread instead of channel when receiving events in thread [#145](https://github.com/Yoctol/bottender/pull/145) | ||
### telegram | ||
* [fix] Use `message.chat.id` to reply [#148](https://github.com/Yoctol/bottender/pull/148) | ||
# 0.14.14 / 2018-01-08 | ||
@@ -2,0 +18,0 @@ |
@@ -53,3 +53,8 @@ 'use strict'; | ||
postMessage(text, options) { | ||
/** | ||
* Sends a message to the channel of the session. | ||
* | ||
* https://api.slack.com/methods/chat.postMessage | ||
*/ | ||
postMessage(message, options) { | ||
const channelId = this._getChannelIdFromSession(); | ||
@@ -64,9 +69,31 @@ | ||
return this._client.postMessage(channelId, text, _extends({}, options)); | ||
return this._client.postMessage(channelId, message, _extends({ | ||
thread_ts: this._event.rawEvent.thread_ts | ||
}, options)); | ||
} | ||
/** | ||
* Send text to the owner of then session. | ||
* Sends an ephemeral message to the session owner. | ||
* | ||
* https://api.slack.com/methods/chat.postMessage | ||
*/ | ||
postEphemeral(message, options = {}) { | ||
const channelId = this._getChannelIdFromSession(); | ||
if (!channelId) { | ||
(0, _warning2.default)(false, 'postMessage: should not be called in context without session'); | ||
return Promise.resolve(); | ||
} | ||
this._isHandled = true; | ||
return this._client.postEphemeral(channelId, | ||
// $FlowFixMe | ||
this._session.user.id, message, options); | ||
} | ||
/** | ||
* Send text to the owner of the session. | ||
* | ||
*/ | ||
sendText(text, options) { | ||
@@ -73,0 +100,0 @@ return this.postMessage(text, options); |
@@ -55,3 +55,3 @@ 'use strict'; | ||
*/ | ||
async sendText(text) { | ||
async sendText(text, options) { | ||
if (!this._session) { | ||
@@ -64,4 +64,19 @@ (0, _warning2.default)(false, 'sendText: should not be called in context without session'); | ||
return this._client.sendMessage(this._session.user.id, text); | ||
const chatId = this._getChatId(); | ||
return this._client.sendMessage(chatId, text, options); | ||
} | ||
_getChatId() { | ||
if (this._event.isMessage) { | ||
return this._event.message.chat.id; | ||
} | ||
if (this._event.isCallbackQuery && this._event.callbackQuery.message) { | ||
return this._event.callbackQuery.message.chat.id; | ||
} | ||
if (this._session) { | ||
return this._session.user.id; | ||
} | ||
return null; | ||
} | ||
} | ||
@@ -92,3 +107,5 @@ | ||
return this._client[method](this._session.user.id, ...args); | ||
const chatId = this._getChatId(); | ||
return this._client[method](chatId, ...args); | ||
} | ||
@@ -95,0 +112,0 @@ }); |
@@ -10,3 +10,3 @@ { | ||
}, | ||
"version": "0.14.14", | ||
"version": "0.14.15", | ||
"main": "lib/index.js", | ||
@@ -73,4 +73,4 @@ "bin": { | ||
"messaging-api-line": "^0.6.7", | ||
"messaging-api-messenger": "^0.6.6", | ||
"messaging-api-slack": "^0.6.0", | ||
"messaging-api-messenger": "^0.6.9", | ||
"messaging-api-slack": "^0.6.10", | ||
"messaging-api-telegram": "^0.6.8", | ||
@@ -77,0 +77,0 @@ "messaging-api-viber": "^0.6.0", |
@@ -107,2 +107,3 @@ # Bottender | ||
* Keyboard | ||
* Group Chat | ||
* Message Live Location | ||
@@ -109,0 +110,0 @@ * Payment |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
321370
8888
149