Skip to content

Releases: bottenderjs/bottender-compose

0.11.0 / 2018-08-27

27 Aug 09:38
Compare
Choose a tag to compare
  • [new] add predicates:

isTextMatch

Creates a predicate function to return true when text matches.

const { isTextMatch } = require('bottender-compose');

isTextMatch('abc')(context); // boolean
isTextMatch(/abc/)(context); // boolean

isPayloadMatch

Creates a predicate function to return true when payload matches.

const { isPayloadMatch } = require('bottender-compose');

isPayloadMatch('abc')(context); // boolean
isPayloadMatch(/abc/)(context); // boolean

hasStateEqual

Creates a predicate function to return true when state matches.

const { hasStateEqual } = require('bottender-compose');

hasStateEqual('x', 1)(context); // boolean
hasStateEqual('x.y.z', 1)(context); // boolean
hasStateEqual('x', { y: { z: 1 } })(context); // boolean

not

Creates a predicate function with not condition.

const { not, hasStateEqual } = require('bottender-compose');

const predicate = not(hasStateEqual('x', 1));

predicate(context); // boolean

and

Creates a predicate function with and condition.

const { and, hasStateEqual } = require('bottender-compose');

const predicate = and([
  isTextMatch('abc'),
  hasStateEqual('x', 1))
]);

predicate(context) // boolean

or

Creates a predicate function with or condition.

const { or, hasStateEqual } = require('bottender-compose');

const predicate = or([
  isTextMatch('abc'),
  hasStateEqual('x', 1))
]);

predicate(context) // boolean

alwaysTrue

Creates a predicate function that always return true.

const { alwaysTrue } = require('bottender-compose');

const predicate = alwaysTrue();

predicate(context); // true

alwaysFalse

Creates a predicate function that always return false.

const { alwaysFalse } = require('bottender-compose');

const predicate = alwaysFalse();

predicate(context); // false

Messenger

  • isMessage
  • isText
  • hasAttachment
  • isImage
  • isAudio
  • isVideo
  • isLocation
  • isFile
  • isFallback
  • isSticker
  • isLikeSticker
  • isQuickReply
  • isEcho
  • isPostback
  • isGamePlay
  • isOptin
  • isPayment
  • isCheckoutUpdate
  • isPreCheckout
  • isRead
  • isDelivery
  • isPayload
  • isPolicyEnforcement
  • isAppRoles
  • isStandby
  • isPassThreadControl
  • isTakeThreadControl
  • isRequestThreadControl
  • isRequestThreadControlFromPageInbox
  • isFromCustomerChatPlugin
  • isReferral
  • isBrandedCamera

LINE

  • isMessage
  • isText
  • isImage
  • isVideo
  • isAudio
  • isLocation
  • isSticker
  • isFollow
  • isUnfollow
  • isJoin
  • isLeave
  • isPostback
  • isPayload
  • isBeacon
  • isAccountLink

Slack

  • isMessage
  • isChannelsMessage
  • isGroupsMessage
  • isImMessage
  • isMpimMessage
  • isText
  • isInteractiveMessage
  • isAppUninstalled
  • isChannelArchive
  • isChannelCreated
  • isChannelDeleted
  • isChannelHistoryChanged
  • isChannelRename
  • isChannelUnarchive
  • isDndUpdated
  • isDndUpdated_user
  • isEmailDomainChanged
  • isEmojiChanged
  • isFileChange
  • isFileCommentAdded
  • isFileCommentDeleted
  • isFileCommentEdited
  • isFileCreated
  • isFileDeleted
  • isFilePublic
  • isFileShared
  • isFileUnshared
  • isGridMigrationFinished
  • isGridMigrationStarted
  • isGroupArchive
  • isGroupClose
  • isGroupHistoryChanged
  • isGroupOpen
  • isGroupRename
  • isGroupUnarchive
  • isImClose
  • isImCreated
  • isImHistoryChanged
  • isImOpen
  • isLinkShared
  • isMemberJoinedChannel
  • isMemberLeftChannel
  • isPinAdded
  • isPinRemoved
  • isReactionAdded
  • isReactionRemoved
  • isStarAdded
  • isStarRemoved
  • isSubteamCreated
  • isSubteamMembersChanged
  • isSubteamSelfAdded
  • isSubteamSelfRemoved
  • isSubteamUpdated
  • isTeamDomainChange
  • isTeamJoin
  • isTeamRename
  • isTokensRevoked
  • isUrlVerification
  • isUserChange

Telegram

  • isMessage
  • isText
  • isAudio
  • isDocument
  • isGame
  • isPhoto
  • isSticker
  • isVideo
  • isVoice
  • isVideoNote
  • isContact
  • isLocation
  • isVenue
  • isEditedMessage
  • isChannelPost
  • isEditedChannelPost
  • isInlineQuery
  • isChosenInlineResult
  • isCallbackQuery
  • isPayload
  • isShippingQuery
  • isPreCheckoutQuery

Viber

  • isMessage
  • isText
  • isPicture
  • isVideo
  • isFile
  • isSticker
  • isContact
  • isURL
  • isLocation
  • isSubscribed
  • isUnsubscribed
  • isConversationStarted
  • isDelivered
  • isSeen
  • isFailed

Facebook

  • isFeed
  • isStatus
  • isStatusAdd
  • isStatusEdited
  • isPost
  • isPostRemove
  • isComment
  • isCommentAdd
  • isCommentEdited
  • isCommentRemove
  • isLike
  • isLikeAdd
  • isLikeRemove
  • isReaction
  • isReactionAdd
  • isReactionEdit
  • isReactionRemove

0.10.3 / 2018-08-08

07 Aug 16:11
Compare
Choose a tag to compare
  • [fix] fallback to empty string when template getting falsy value

0.10.2 / 2018-07-25

25 Jul 10:35
Compare
Choose a tag to compare
  • [new] Support user accessor: {{user.xxx}} in template.

0.10.1 / 2018-05-16

16 May 04:23
Compare
Choose a tag to compare
  • [fix] run babel compilation before publish.

0.10.0 / 2018-05-16

16 May 02:31
Compare
Choose a tag to compare
  • [new] build source with babel to have real support for node >= 7.6

0.9.1 / 2018-05-07

07 May 03:23
Compare
Choose a tag to compare
  • Add new logger methods:
B.series([
  B.log('sending hello'),
  B.info('sending hello'),
  B.warn('sending hello'),
  B.error('sending hello'),

  B.sendText('hello'),
]);

It supports template too.

B.series([
  B.log('user: {{ session.user.id }} x: {{ state.x }}'),
  B.sendText('hello'),
]);

You can use your owner adapter for the logger:

const { log, info, warn, error } = B.createLogger({
  log: debug('log'),
  info: debug('info'),
  warn: debug('warn'),
  error: debug('error'),
});

B.series([log('sending hello'), B.sendText('hello')]);

0.9.0 / 2018-05-06

06 May 13:33
Compare
Choose a tag to compare
  • [new] effect:
const { effect } = require('bottender-compose');

bot.onEvent(
  effect(
    // function has side effects
    async context => {
      await doSomeSideEffects();
      return {
        derivedState: {
          x: 1,
        },
        derivedParam: {
          y: 2,
        },
      };
    },

    // action
    async (context, param) => {
      console.log(context.state.x); // 1
      console.log(param.y); // 2
    }
  )
);

0.8.4 / 2018-04-26

26 Apr 07:39
Compare
Choose a tag to compare
  • [new] also overwrite name in setDisplayName

0.8.3 / 2018-04-12

12 Apr 10:33
Compare
Choose a tag to compare
  • [fix] pass extra args to match value function (#58)
  • [fix] pass extra args to all of context fns (#59)

0.8.2 / 2018-04-09

08 Apr 16:48
Compare
Choose a tag to compare
  • [new] Add setDisplayName:

Assigns to the displayName property on the action.

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

setDisplayName('sayHello', sendText('hello'));

// curry function
setDisplayName('sayHello')(sendText('hello'));