This file contains hidden or 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
let store = { | |
_users: {}, | |
// creates state tree | |
_initializeUserState: function(hash) { | |
this._users[hash] = { | |
command: '', | |
spotify: { | |
genre: '', | |
numberOfRecs: 0 |
This file contains hidden or 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
class Messenger { | |
... | |
handleText(msg) { | |
const message = new Message(Message.mapMessage(msg)) | |
const text = message.text | |
if (inputParser.isAskingForGenreList(text)) | |
return handlers.music.getGenreList(message, this.bot) |
This file contains hidden or 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
let store = { | |
... | |
update: function(hash, data) { | |
if (!this._users[hash]) this._initializeUserState(hash) | |
console.log('🌑 => PREVIOUS STATE') | |
console.log(this.getState(hash)) | |
this._users[hash] = _.merge(this._users[hash], data) |
This file contains hidden or 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
let store = { | |
... | |
getState: function(hash) { | |
if (!this._users[hash]) return this._initializeUser(hash) | |
return this._users[hash] | |
}, | |
clearState: function(hash) { |
This file contains hidden or 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
var fallbackMessages = [ | |
'Sorry, not sure what you just said.', | |
'Uh oh! Try again.', | |
'Hm... Sorry I\'m not that smart yet. Try again!' | |
]; | |
var message = messages[Math.floor(Math.random() * messages.length)]; | |
bot.say(message); |
This file contains hidden or 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
var nodemailer = require('nodemailer'); | |
const subscribe = { | |
send: function(name, service) { | |
const transporter = nodemailer.createTransport({ | |
service: 'Gmail', | |
auth: { | |
user: 'your gmail username', | |
pass: 'your gmail password' | |
}, |
This file contains hidden or 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
var express = require('express'); | |
var path = require('path'); | |
var bodyParser = require('body-parser'); | |
var subscribe = require('./subscribe'); | |
var app = new express(); | |
var port = 8000; | |
// middleware |
This file contains hidden or 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
export const fontSize = { | |
// heading | |
displayLarge: '32px', | |
displayMedium: '26px', | |
displaySmall: '20px', | |
heading: '18px', | |
subheading: '16px', | |
// body | |
body: '17px', |
This file contains hidden or 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 React, { PropTypes } from 'react'; | |
import { StyleSheet, css } from 'aphrodite/no-important'; | |
import { tagMapping, fontSize, fontWeight, lineHeight } from '../styles/base/typography'; | |
function Heading(props) { | |
const { children, tag: Tag } = props; | |
return <Tag className={css(styles[tagMapping[Tag]])}>{children}</Tag>; | |
} | |
export default Heading; |
This file contains hidden or 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
... | |
export const tagMapping = { | |
h1: 'displayLarge', | |
h2: 'displayMedium', | |
h3: 'displaySmall', | |
h4: 'heading', | |
h5: 'subheading', | |
}; |