Skip to content

Commit

Permalink
Merge pull request #17 from beeminder/glitch
Browse files Browse the repository at this point in the history
👨‍❤️‍💋‍👨🏕 Updated with Glitch
  • Loading branch information
dreeves authored Sep 28, 2017
2 parents 1879644 + e337ac5 commit 5708d29
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
4 changes: 3 additions & 1 deletion lib/botils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ var shoutDelayed = (rurl, txt) => {
request.post(rurl, { json: {
"response_type": "in_channel", // in_channel vs ephemeral
"text": txt}
}, (error, response, body) => { }) // error handling? pshaw.
}, (error, response, body) => {
console.log("error handling? pshaw.")
})
}

// Bernoulli trial with probability p
Expand Down
22 changes: 14 additions & 8 deletions lib/roll.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
var botils = require('./botils.js');
// --------------------------------- 80chars ---------------------------------->
const botils = require('./botils.js')
const shout = botils.shout
const whisp = botils.whisp
const randint = botils.randint
const bern = botils.bern

var handleSlash = function(req, res) {
var text = req.body.text
var n = parseInt(text)
if(isNaN(n)) {
botils.whisp(res, "Pssst, this is not an integer: " + text)
} else if(n <= 0) {
botils.shout(res, "Rolling " + n + "-sided die... "
+ (botils.bern(0.1) ? ":poop:" : ":boom:")
if (isNaN(n)) {
whisp(res, "Pssst, this is not an integer: " + text)
} else if (n <= 0) {
shout(res, "Rolling " + n + "-sided die... "
+ (bern(0.1) ? ":poop:" : ":boom:")
+ " (try again with a positive number of sides?)")
} else {
botils.shout(res, "Rolling " + n + "-sided die... it came up " + botils.randint(n))
shout(res, "Rolling " + n + "-sided die... it came up " + randint(n))
}
// TODO: whisper help in response to /roll or /roll help
}

module.exports = {
handleSlash: handleSlash
handleSlash
}
// --------------------------------- 80chars ---------------------------------->
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "beebot",
"version": "1.0.1",
"description": "A helpful bot for interacting with Beeminder",
"main": "index.js",
"main": "server.js",
"engines": {
"node": "6.x"
},
Expand All @@ -19,7 +19,7 @@
"devDependencies": {},
"babel": {},
"scripts": {
"start": "node index.js"
"start": "node server.js"
},
"author": "Beeminder",
"license": "MIT",
Expand Down
File renamed without changes.

0 comments on commit 5708d29

Please sign in to comment.