Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bottender-compose

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bottender-compose - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

CHANGELOG.md

16

package.json
{
"name": "bottender-compose",
"version": "0.0.3",
"description": "An utility library for bottender and higher-order handlers",
"version": "0.1.0",
"repository": {

@@ -11,5 +12,11 @@ "type": "git",

"engines": {
"node": ">=6"
"node": ">=7.6"
},
"keywords": [
"bot",
"bottender",
"compose"
],
"devDependencies": {
"delay": "^2.0.0",
"eslint": "^4.3.0",

@@ -42,3 +49,6 @@ "eslint-config-prettier": "^2.3.0",

],
"testEnvironment": "node"
"testEnvironment": "node",
"timers": "fake",
"resetModules": true,
"resetMocks": true
},

@@ -45,0 +55,0 @@ "dependencies": {

# bottender-compose
> An utility library for [Bottender](github.com/Yoctol/bottender) and higher-order handlers
## Installation
```sh
npm install bottender-compose
```
## API Reference
### `series`
Create a function that executes methods in series.
```js
const { series } = require('bottender-compose');
bot.onEvent(series([
sendText('a');
sendText('b');
sendText('c');
]))
```
### `parallel`
Create a function that executes methods in parallel.
```js
const { parallel } = require('bottender-compose');
bot.onEvent(parallel([
sendText('a');
sendText('b');
sendText('c');
]))
```
### `random`
Create a function that executes one of method randomly.
```js
const { parallel } = require('bottender-compose');
bot.onEvent(random([
sendText('a');
sendText('b');
sendText('c');
]))
```
### Other Methods
#### State
* `setState`
* `resetState`
#### Messenger
* `sendMessage`
* `sendText`
* `sendAttachment`
* `sendAudio`
* `sendImage`
* `sendVideo`
* `sendFile`
* `sendTemplate`
* `sendButtonTemplate`
* `sendGenericTemplate`
* `sendListTemplate`
* `sendOpenGraphTemplate`
* `sendMediaTemplate`
* `sendReceiptTemplate`
* `sendAirlineBoardingPassTemplate`
* `sendAirlineCheckinTemplate`
* `sendAirlineItineraryTemplate`
* `sendAirlineFlightUpdateTemplate`
* `sendSenderAction`
* `markSeen`
* `typingOn`
* `typingOff`
* `associateLabel`
* `dissociateLabel`
* `getAssociatedLabels`
## LINE
* `sendText`
* `sendImage`
* `sendVideo`
* `sendAudio`
* `sendLocation`
* `sendSticker`
* `sendImagemap`
* `sendButtonTemplate`
* `sendConfirmTemplate`
* `sendCarouselTemplate`
* `sendImageCarouselTemplate`
* `reply`
* `replyText`
* `replyImage`
* `replyVideo`
* `replyAudio`
* `replyLocation`
* `replySticker`
* `replyImagemap`
* `replyButtonTemplate`
* `replyConfirmTemplate`
* `replyCarouselTemplate`
* `replyImageCarouselTemplate`
* `sendImageCarouselTemplate`
* `push`
* `pushText`
* `pushImage`
* `pushVideo`
* `pushAudio`
* `pushLocation`
* `pushSticker`
* `pushImagemap`
* `pushButtonTemplate`
* `pushConfirmTemplate`
* `pushCarouselTemplate`
* `pushImageCarouselTemplate`
* `getLinkedRichMenu`
* `linkRichMenu`
* `unlinkRichMenu`
## Slack
* `sendText`
* `postMessage`
## Telegram
* `sendText`
* `sendMessage`
* `sendPhoto`
* `sendAudio`
* `sendDocument`
* `sendSticker`
* `sendVideo`
* `sendVoice`
* `sendVideoNote`
* `sendLocation`
* `sendVenue`
* `sendContact`
* `sendChatAction`
## License
MIT © [Yoctol](https://github.com/Yoctol/bottender-compose)

@@ -1,6 +0,100 @@

const { random, sendText } = require('../');
const B = require('../');
it('should export public apis', () => {
expect(random).toBeDefined();
expect(sendText).toBeDefined();
it('should export state apis', () => {
expect(B.setState).toBeDefined();
expect(B.resetState).toBeDefined();
});
it('should export Messenger apis', () => {
expect(B.sendMessage).toBeDefined();
expect(B.sendText).toBeDefined();
expect(B.sendAttachment).toBeDefined();
expect(B.sendAudio).toBeDefined();
expect(B.sendImage).toBeDefined();
expect(B.sendVideo).toBeDefined();
expect(B.sendFile).toBeDefined();
expect(B.sendTemplate).toBeDefined();
expect(B.sendButtonTemplate).toBeDefined();
expect(B.sendGenericTemplate).toBeDefined();
expect(B.sendListTemplate).toBeDefined();
expect(B.sendOpenGraphTemplate).toBeDefined();
expect(B.sendMediaTemplate).toBeDefined();
expect(B.sendReceiptTemplate).toBeDefined();
expect(B.sendAirlineBoardingPassTemplate).toBeDefined();
expect(B.sendAirlineCheckinTemplate).toBeDefined();
expect(B.sendAirlineItineraryTemplate).toBeDefined();
expect(B.sendAirlineFlightUpdateTemplate).toBeDefined();
expect(B.sendSenderAction).toBeDefined();
expect(B.markSeen).toBeDefined();
expect(B.typingOn).toBeDefined();
expect(B.typingOff).toBeDefined();
expect(B.associateLabel).toBeDefined();
expect(B.dissociateLabel).toBeDefined();
expect(B.getAssociatedLabels).toBeDefined();
});
it('should export LINE apis', () => {
expect(B.sendText).toBeDefined();
expect(B.sendImage).toBeDefined();
expect(B.sendVideo).toBeDefined();
expect(B.sendAudio).toBeDefined();
expect(B.sendLocation).toBeDefined();
expect(B.sendSticker).toBeDefined();
expect(B.sendImagemap).toBeDefined();
expect(B.sendButtonTemplate).toBeDefined();
expect(B.sendConfirmTemplate).toBeDefined();
expect(B.sendCarouselTemplate).toBeDefined();
expect(B.sendImageCarouselTemplate).toBeDefined();
expect(B.reply).toBeDefined();
expect(B.replyText).toBeDefined();
expect(B.replyImage).toBeDefined();
expect(B.replyVideo).toBeDefined();
expect(B.replyAudio).toBeDefined();
expect(B.replyLocation).toBeDefined();
expect(B.replySticker).toBeDefined();
expect(B.replyImagemap).toBeDefined();
expect(B.replyButtonTemplate).toBeDefined();
expect(B.replyConfirmTemplate).toBeDefined();
expect(B.replyCarouselTemplate).toBeDefined();
expect(B.replyImageCarouselTemplate).toBeDefined();
expect(B.push).toBeDefined();
expect(B.pushText).toBeDefined();
expect(B.pushImage).toBeDefined();
expect(B.pushVideo).toBeDefined();
expect(B.pushAudio).toBeDefined();
expect(B.pushLocation).toBeDefined();
expect(B.pushSticker).toBeDefined();
expect(B.pushImagemap).toBeDefined();
expect(B.pushButtonTemplate).toBeDefined();
expect(B.pushConfirmTemplate).toBeDefined();
expect(B.pushCarouselTemplate).toBeDefined();
expect(B.pushImageCarouselTemplate).toBeDefined();
expect(B.getLinkedRichMenu).toBeDefined();
expect(B.linkRichMenu).toBeDefined();
expect(B.unlinkRichMenu).toBeDefined();
});
it('should export Slack apis', () => {
expect(B.sendText).toBeDefined();
expect(B.postMessage).toBeDefined();
});
it('should export Telegram apis', () => {
expect(B.sendText).toBeDefined();
expect(B.sendMessage).toBeDefined();
expect(B.sendPhoto).toBeDefined();
expect(B.sendAudio).toBeDefined();
expect(B.sendDocument).toBeDefined();
expect(B.sendSticker).toBeDefined();
expect(B.sendVideo).toBeDefined();
expect(B.sendVoice).toBeDefined();
expect(B.sendVideoNote).toBeDefined();
expect(B.sendLocation).toBeDefined();
expect(B.sendVenue).toBeDefined();
expect(B.sendContact).toBeDefined();
expect(B.sendChatAction).toBeDefined();
});
it('should export other apis', () => {
expect(B.random).toBeDefined();
});

2

src/__tests__/random.spec.js

@@ -6,3 +6,3 @@ jest.mock('random-item');

const random = require('../random');
const sendText = require('../sendText');
const { sendText } = require('../');

@@ -9,0 +9,0 @@ it('should create action that will call sendText', () => {

@@ -1,2 +0,2 @@

const sendText = require('../sendText');
const { sendText } = require('../');

@@ -3,0 +3,0 @@ it('should create action that will call sendText', async () => {

@@ -0,2 +1,15 @@

const { state, messenger, line, slack, telegram } = require('./methods');
const allMethods = state
.concat(messenger)
.concat(line)
.concat(slack)
.concat(telegram);
allMethods.forEach(method => {
if (!exports[method]) {
exports[method] = (...args) => context => context[method](...args);
}
});
exports.random = require('./random');
exports.sendText = require('./sendText');

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc