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
(function() { | |
'use strict'; | |
ThemeController.$inject = ['$scope', 'Notifications']; | |
function ThemeController($scope, Notifications) { | |
$scope.user = {}; | |
$scope.changeTheme = function(theme) { | |
$scope.user.theme = theme; |
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
(function() { | |
UserModel.$inject = '$resource'; | |
function UserModel($resource) { | |
var baseUrl = 'api/user/:dest'; | |
var User = {}; | |
var userMethods = $resource(baseUrl, {}, { | |
get: { |
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
(function() { | |
'use strict'; | |
ThemeController.$inject = ['$scope', 'User', 'Notifications']; | |
function ThemeController($scope, User, Notifications) { | |
var vm = this; | |
vm.user = {}; | |
vm.saveUser = saveUser; |
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 'babel-core/polyfill' | |
import React from 'react' | |
import { render } from 'react-dom' | |
import Root from './containers/Root' | |
import configureStore from './store/configureStore' | |
const store = configureStore() | |
render( | |
<Root store={store} />, |
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 { | |
constructor() { | |
this.bot = new TelegramBot('Your token here', { polling: true }); | |
} | |
listen() { | |
this.bot.on('text', this.handleText.bind(this)) | |
} | |
... |
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
'use strict' | |
const Messenger = require('./lib/messenger') | |
const messenger = new Messenger() | |
messenger.listen() | |
.then(() => { | |
console.log('🤖 Listening to incoming messages') | |
}) |
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 InputParser { | |
isAskingForGenreList(text) { | |
const pattern = /music|recommendation/i | |
return text.match(pattern) | |
} | |
isAskingForNumberOfRec(text, prevCommand) { | |
return prevCommand === commands.GET_GENRE_LIST | |
} |
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 Music { | |
getGenreList(message, bot) { | |
// clears store for new command tree | |
store.clearState(message.from) | |
store.update(message.from, { command: commands.GET_GENRE_LIST }) | |
bot.sendMessage(message.from, 'Choose a genre you would like a recommendation for 🎵', { | |
reply_markup: { | |
keyboard: genresJSON.genres, | |
one_time_keyboard: true |
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 Music { | |
... | |
getRecommendation(message, bot) { | |
store.update(message.from, { | |
command: commands.GET_RECOMMENDATION, | |
spotify: { | |
numberOfRecs: message.text | |
} | |
}) |
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
(function(module) { | |
function getRecommendation(selectedGenre, limit) { | |
... | |
return Promise.resolve() | |
.then(getSpotifyAccessToken) | |
.then(getRecommendation) | |
function getRecommendation() { |
OlderNewer