Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ABSLord committed Oct 12, 2018
1 parent 2ff635c commit d76e41f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/cuteme.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function (robot) {
const CUTIES_LIMIT = parseInt(process.env.CUTIES_LIMIT, 10) || 5

robot.respond(/pug me/i, async (msg) => {
await nFetch(`${SERVICE_URL}/breed/pug/images/random`)
await nFetch(`${PUGME_SERVICE}/breed/pug/images/random`)
.then(res => res.json())
.then(json => msg.send(json.message))
.catch(err => robot.logger.error(`Failed to request a pug: ${err}`))
Expand All @@ -26,12 +26,13 @@ module.exports = function (robot) {
robot.respond(/pug bomb( (\d+))?/i, async (msg) => {
const count = msg.match[2] || 5

if (count > PUGS_LIMIT) {
msg.send(`The maximum number of pugs is limited to ${PUGS_LIMIT}`)
if (count > CUTIES_LIMIT) {
msg.send(`The maximum number of pugs is limited to ${CUTIES_LIMIT}`)
return

}

await nFetch(`${SERVICE_URL}/breed/pug/images/random/${count}`)
await nFetch(`${PUGME_SERVICE}/breed/pug/images/random/${count}`)
.then(res => res.json())
.then(json => Array.from(json.message).map((pug) => msg.send(pug)))
.catch(err => robot.logger.error(`Failed to request ${count} pugs: ${err}`))
Expand Down

0 comments on commit d76e41f

Please sign in to comment.