Skip to content

Instantly share code, notes, and snippets.

View JonathanZWhite's full-sized avatar
🦁

Jonathan White JonathanZWhite

🦁
View GitHub Profile
(function() {
'use strict';
ThemeController.$inject = ['$scope', 'Notifications'];
function ThemeController($scope, Notifications) {
$scope.user = {};
$scope.changeTheme = function(theme) {
$scope.user.theme = theme;
(function() {
UserModel.$inject = '$resource';
function UserModel($resource) {
var baseUrl = 'api/user/:dest';
var User = {};
var userMethods = $resource(baseUrl, {}, {
get: {
(function() {
'use strict';
ThemeController.$inject = ['$scope', 'User', 'Notifications'];
function ThemeController($scope, User, Notifications) {
var vm = this;
vm.user = {};
vm.saveUser = saveUser;
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} />,
class Messenger {
constructor() {
this.bot = new TelegramBot('Your token here', { polling: true });
}
listen() {
this.bot.on('text', this.handleText.bind(this))
}
...
'use strict'
const Messenger = require('./lib/messenger')
const messenger = new Messenger()
messenger.listen()
.then(() => {
console.log('🤖 Listening to incoming messages')
})
class InputParser {
isAskingForGenreList(text) {
const pattern = /music|recommendation/i
return text.match(pattern)
}
isAskingForNumberOfRec(text, prevCommand) {
return prevCommand === commands.GET_GENRE_LIST
}
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
class Music {
...
getRecommendation(message, bot) {
store.update(message.from, {
command: commands.GET_RECOMMENDATION,
spotify: {
numberOfRecs: message.text
}
})
(function(module) {
function getRecommendation(selectedGenre, limit) {
...
return Promise.resolve()
.then(getSpotifyAccessToken)
.then(getRecommendation)
function getRecommendation() {