Releases: bottenderjs/bottender-compose
Releases · bottenderjs/bottender-compose
0.8.1 / 2018-04-02
- [fix] warning condition on compileTemplate method.
0.8.0 / 2018-04-02
- [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
- [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
- [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
- [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
- [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
- [new] Support methods:
passThreadControl
passThreadControlToPageInbox
takeThreadControl
sendMediaGroup
sendInvoice
sendGame
setGameScore
0.5.0 / 2017-12-20
- [new] Support
repeat
anddelay
.
0.4.0 / 2017-12-14
- [new] Support
weight
anddoNothing
.
0.3.1 / 2017-12-13
- [fix] Fix
random
runtime bug