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
hears(['accept'], 'ambient', (bot, message) => { | |
... | |
if (user in players && !players[user].accepted) { | |
bot.reply(message, 'GREAT, LET THE BATTLE BEGIN!!!'); | |
bot.startPrivateConversation(message, callback); | |
} else { | |
... | |
}); |
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
hears([‘play’], ‘direct_message,direct_mention,mention’, (bot, message) => { | |
... | |
channels.save(gameData, (err) => { | |
if (err) throw err; | |
bot.say({ | |
text: `<@${playerTwo}> you've been challenged to a game of ROCK PAPER SCISSORS by <@${user}>, say \`accept\` unless you're too scared.`, | |
channel, | |
}); |
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
... | |
if (data && 'players' in data) { | |
const { user } = message; | |
const { players } = data; | |
if (user in players && !players[user].accepted) { | |
// player two accepted | |
bot.reply(message, 'GREAT, LET THE BATTLE BEGIN!!!'); | |
} else { | |
const player = Object.keys(players).find((p) => !players[p].accepted); |
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
// a bot can listen for text it's not mentioned in | |
// by passing 'ambient' as the second parameter | |
hears(['accept'], 'ambient', (bot, message) => { | |
const { channel } = message; | |
channels.get(channel, (err, data) => { | |
if (err) throw err; | |
if (data && 'players' in data) { | |
// game has started ! |
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
if (userData) { | |
... | |
channels.save(gameData, (err) => { | |
if (err) throw err; | |
bot.say({ | |
text: `<@${playerTwo}> you've been challenged to a game of ROCK PAPER SCISSORS by <@${user}>, say \`accept\` unless you're too scared.`, | |
channel, | |
}); |
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
... | |
if (userData) { | |
const playerTwo = userData[1]; // player two's id is at the first index of match results | |
const gameData = { | |
id: channel, | |
players: { | |
[user]: { | |
accepted: true, | |
played: '', | |
}, |
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
hears(['play'], 'direct_message,direct_mention,mention', (bot, message) => { | |
const { user, channel, text } = message; // destructure message variable | |
const userData = text.match(/<@([A-Z0–9]{9})>/); // parse the text for user's 9 character id | |
if (userData) { | |
// if there is a user challenged, start the game | |
} else { | |
bot.reply(message, 'You didn\'t challenge anyone…'); | |
} | |
}); |
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
if (!process.env.token) { | |
process.exit(1); | |
} | |
const Botkit = require('botkit'); | |
const controller = Botkit.slackbot({ | |
debug: true, | |
}); |
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
<!doctype html> | |
<html> | |
<head> | |
<script src="https://rawgit.com/aframevr/aframe/b813db0614ac2b518e547105e810b5b6eccfe1c8/dist/aframe.min.js"></script> | |
</head> | |
<body> | |
<script> | |
AFRAME.registerComponent('set-sky', { | |
schema: {default: ''}, | |
init() { |
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
// ARROW GENERATOR | |
@mixin arrow( | |
$box-edge: top, | |
$arrow-size: 10px, | |
$border-width: 4px, | |
$background-color: white, | |
$border-color: black) { | |
position: relative; | |
background: $background-color; |