This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller | |
{ | |
self.shouldReloadCollectionView = NO; | |
self.blockOperation = [[NSBlockOperation alloc] init]; | |
} | |
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo | |
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type | |
{ | |
__weak UICollectionView *collectionView = self.collectionView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface MomentEncrypter : NSValueTransformer | |
@property NSData *key; | |
@property NSData *iv; | |
- (void)setKeyAndIVWith:(NSString*)password; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addGreeting((user, response) => { | |
response.sendText('📢 🤖') | |
}) | |
newScript() | |
.dialog((session, response) => { | |
if (session.message.type === 'text') { | |
switch (session.message.text) { | |
// solved better with intents, https://www.alana.tech/concepts/intents.html | |
case 'hello': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Alana = require('@alana/core').default; | |
const request = require('request-promise'); | |
const flatten = require('lodash.flatten'); | |
const Promise = require('bluebird'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const vm = require('vm'); | |
// Converts FB payloads to Alana common message format | |
const inputConverter = require('@alana/platform-facebook').mapFBToInternal; | |
// Converts alana format to FB messenger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.dialog(function(session, response, stop) { | |
// always send typing indicators | |
response.sendTyping(); | |
// make an api request | |
request({ uri: '', method: 'POST' ... }) | |
.then(function (results) { | |
response.sendText(`The weather will be ${results} today`); | |
}) | |
.timeout(5000) // timeout is in ms | |
.catch(Promise.TimeoutError, function(e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.dialog((session, response, stop) => { | |
const expiresIn24Hours = new Date().setHours(new Date().getHours() + 24); | |
response.createButtons() | |
.text('Choose an option') | |
.addButton('postback', 'Option 1', JSON.stringify({ | |
c: 'do-this', // c is for command | |
s: 'current-state', // s is for state | |
exp: expiresIn24Hours.getTime() / 1000, | |
}) | |
.addButton('postback', 'Option 2', JSON.stringify({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.dialog((session, response, stop) => { | |
response.sendText(getRandom([ | |
"I'm confused", | |
"I don't know what you mean", | |
"Can you try again", | |
"I'm just a baby bot", | |
])); | |
}) | |
function getRandom(arr) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bp.hear(), (event, next) => { | |
bp.db.kvs.get(event.user.id) | |
.then(user => { | |
if (!user || user.step === 0) { | |
bp.messenger.sendText(event.user.id, 'Hello, what would you like me to call you?'); | |
return bp.db.kvs.set(event.user.id, defaultUser); | |
} | |
if (user.step > 2) { | |
// already registered user do somethign else here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newScript().dialog((session, response) => { | |
if (!session.user.state.nickname) { | |
response.startScript('profile'); | |
} | |
}) | |
newScript('profile') | |
.dialog((session, response) => { | |
response.sendText('Hello, what would you like me to call you?'); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bot.dialog('/', [ | |
function (session) { | |
if (!session.userData.nickname) { | |
session.beginDialog('/profile', session.userData.profile); | |
} | |
}, | |
function (session, results) { | |
session.userData.profile = results.response; | |
session.send('News of the day....'); | |
} |
OlderNewer