Skip to content

Releases: bottenderjs/bottender-compose

0.8.1 / 2018-04-02

02 Apr 10:51
Compare
Choose a tag to compare
  • [fix] warning condition on compileTemplate method.

0.8.0 / 2018-04-02

02 Apr 09:54
Compare
Choose a tag to compare
  • [new] Use Template in String:

You can use context, session, event, state to access values in your template string:

B.sendText('Hi, {{session.user.first_name}} {{session.user.last_name}}');
B.sendText('Received: {{event.text}}');
B.sendText('State: {{state.xxx}}');
  • [new] Support match:

Create a function that encapsulates value matching logic.

const { match, sendText } = require('bottender-compose');

bot.onEvent(
  match('a', [
    ['a', sendText('You got a A')],
    ['b', sendText('You got a B')],
    ['c', sendText('You got a C')],
  ])
);

It accepts function with context argument:

bot.onEvent(
  match(context => context.state.answer, [
    ['a', sendText('You got a A')],
    ['b', sendText('You got a B')],
    ['c', sendText('You got a C')],
  ])
);

// curry function
const matchAnswer = match(context => context.state.answer);

bot.onEvent(
  matchAnswer([
    ['a', sendText('You got a A')],
    ['b', sendText('You got a B')],
    ['c', sendText('You got a C')],
  ])
);

To assign default action, use _ as pattern:

const { _, match, sendText } = require('bottender-compose');
bot.onEvent(
  match('a', [
    ['a', sendText('You got a A')],
    ['b', sendText('You got a B')],
    ['c', sendText('You got a C')],
    [_, sendText('You got something')],
  ])
);

0.7.0 / 2018-03-31

31 Mar 08:50
Compare
Choose a tag to compare
  • [new] Curry branch, repeat and tryCatch:
// curry branch
const trueConditionBranch = branch(context => true);

bot.onEvent(
  trueConditionBranch(sendText('You are the lucky one.'), sendText('Too bad.'))
);

// curry repeat
const repeatFiveTimes = repeat(5);

bot.onEvent(repeatFiveTimes(sendText('This will be sent 5 times.')));

// curry tryCatch
const mayFailTryCatch = tryCatch(doSomethingMayFail());

bot.onEvent(mayFailTryCatch(sendText('Error Happened~~~~~~~~~~~!')));
  • [new] support otherArgs:
const action = (context, ...otherArgs) => {};

0.6.2 / 2018-03-22

22 Mar 09:37
Compare
Choose a tag to compare
  • [new] Support new methods:

telegram:

  • editMessageText

  • editMessageCaption

  • editMessageReplyMarkup

  • deleteMessage

  • editMessageLiveLocation

  • stopMessageLiveLocation

  • forwardMessageFrom

  • forwardMessageTo

  • [removed] remove useless

messenger:

  • getAssociatedLabels

line:

  • getLinkedRichMenu

0.6.1 / 2018-03-21

21 Mar 08:56
Compare
Choose a tag to compare
  • [new] Support new methods:

messenger:

  • requestThreadControl

slack:

  • postEphemeral

telegram:

  • kickChatMember
  • unbanChatMember
  • restrictChatMember
  • promoteChatMember
  • exportChatInviteLink
  • setChatPhoto
  • deleteChatPhoto
  • setChatTitle
  • setChatDescription
  • setChatStickerSet
  • deleteChatStickerSet
  • pinChatMessage
  • unpinChatMessage
  • leaveChat
  • answerShippingQuery
  • answerPreCheckoutQuery
  • answerInlineQuery

0.6.0 / 2018-03-21

21 Mar 06:17
Compare
Choose a tag to compare
  • [new] Support passing function as argument to context methods:

You can pass function as argument to handle time-specified or context-specified case, for example:

// Lazy execution
B.sendText(() => `Now: ${new Date()}`);

// Use user information on context
B.sendText(
  context =>
    `${context.session.user.first_name} ${
      context.session.user.last_name
    }, You are the lucky one.`
);

// Use event information
B.sendText(context => `Received: ${context.event.text}`);

0.5.1 / 2017-12-20

20 Dec 09:40
Compare
Choose a tag to compare
  • [new] Support methods:
    • passThreadControl
    • passThreadControlToPageInbox
    • takeThreadControl
    • sendMediaGroup
    • sendInvoice
    • sendGame
    • setGameScore

0.5.0 / 2017-12-20

20 Dec 07:04
Compare
Choose a tag to compare
  • [new] Support repeat and delay.

0.4.0 / 2017-12-14

14 Dec 03:12
Compare
Choose a tag to compare
  • [new] Support weight and doNothing.

0.3.1 / 2017-12-13

13 Dec 04:58
Compare
Choose a tag to compare
  • [fix] Fix random runtime bug