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
| channels.get(channel, (err, data) => { | |
| ... | |
| if (onlyOnePlayed) { | |
| channels.save(updateData, (err) => { | |
| if (err) throw err; | |
| bot.reply(message, `<@${user}> has played!`); | |
| }); |
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
| } else { | |
| const gameResults = playerIDs.map((id) => `<@${id}> played ${players[id].played}`); | |
| bot.reply(message, gameResults.join(' & ')); | |
| // reset the game data | |
| channels.save({ id: updateData.id }, (err) => { | |
| if (err) throw err; | |
| }); | |
| } |
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
| if (!process.env.token) { | |
| process.exit(1); | |
| } | |
| const Botkit = require('botkit'); | |
| const controller = Botkit.slackbot({ | |
| debug: 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
| const jwt = require('jsonwebtoken'); | |
| const models = require('../models'); | |
| const Strategy = require('passport-local'); | |
| function generateToken(req, res, next) { | |
| res.cookie('token', | |
| jwt.sign({ id: req.user.id }, process.env.SECRET), | |
| { | |
| maxAge: 86400000, | |
| httpOnly: 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
| const jwt = require('jsonwebtoken'); | |
| const models = require('../models'); | |
| const Strategy = require('passport-local'); | |
| function generateToken(req, res, next) { | |
| res.cookie('token', | |
| jwt.sign({ id: req.user.id }, process.env.SECRET), | |
| { | |
| maxAge: 86400000, | |
| httpOnly: 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
| [ | |
| { | |
| "Introduction": "# intro/n/n ## hello there...." | |
| }, | |
| { | |
| "Getting Started": | |
| [ | |
| { | |
| "Step One": "# stepone/n/n ## hello there..." | |
| }, |
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
| { | |
| 0: { | |
| "Introduction": "# intro/n/n ## hello there...." | |
| }, | |
| 1: { | |
| "Getting Started": | |
| { | |
| 0: { | |
| "Step One": "# stepone/n/n ## hello there..." | |
| }, |
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 re = /(#+)(.*)/; | |
| var str = '## About Bottler\n\nThis is something about the project\n\n# something else\n'; | |
| function findAll(regex, sourceString, aggregator = []) { | |
| const arr = re.exec(sourceString); | |
| if (arr === null) return aggregator; | |
| const newString = sourceString.slice(arr.index + arr[0].length); | |
| return findAll(regex, newString, aggregator.concat([arr])); |
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() { | |
| var searchQuery = window.location.search; | |
| var ref; | |
| var $form; | |
| var userEmail; | |
| if (searchQuery !== '' && searchQuery.indexOf('ref=') > -1) { | |
| ref = searchQuery.split('=')[1]; | |
| console.log('ref',ref); | |
| $form = $('form.newsletter-form'); | |
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
| router.put('/user/:refCode', function(req, res, next) { | |
| if (!req.params.refCode) res.json({ result: 'error', msg: 'must send an referral code'}); | |
| var newEmail = req.body.email ? req.body.email : ''; | |
| mailchimp.get({ | |
| path: 'lists/' + listID + '/members?unique_email_id=' + req.params.refCode, | |
| }) | |
| .then(function(search) { | |
| const user = search.members[0]; |