Skip to content

Commit

Permalink
🛎🚕 Updated with Glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
Glitch (bee) committed Jan 10, 2018
1 parent 6dc03ec commit c7c1bd5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .config/configstore/update-notifier-npm.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"optOut": false,
"lastUpdateCheck": 1514319292993
"lastUpdateCheck": 1515560428334
}
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,22 @@ We never do that for the test version of the bot hosted on Glitch.
But it still works. Why?
Maybe that only applies to slash commands that talk to the Beeminder server.

What's the difference between redis.set and redis.hset
What's the difference between redis.set and redis.hset

Karmabot stopped working after deploying the following changes:
https://github.com/beeminder/beebot/compare/346b56e61035...efba9b029b39

Those all seem innocuous so I'm theorizing that something changed with Slack permissions and it was triggered by a redeploy.

Obvious way to test that though is to revert the code to just before 346b56e61035 and see if it works again.

### Instructions for deploying

Andy set it up to automagically deploy whenever changes are pushed to the branch `production`.
So do the following after pushing to master:

```
git checkout production
git merge master
git push
```
22 changes: 11 additions & 11 deletions lib/beebot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ console.log(`DEBUG3: karmabot = ${JSON.stringify(karmabot)}`)
var bots = []

// handle a message and pass it through to the Beeminder server
var handleMessage = (rtm, message) => {
var handleMessage = function(rtm, message) {
console.log(`DEBUG4: handleMessage ${message.text}`)
var text = message.text
var regexpString = "<@" + rtm.activeUserId + ">"
Expand Down Expand Up @@ -43,14 +43,14 @@ var handleMessage = (rtm, message) => {
}).on('error', (e) => { console.error(e) })
}

var stopBot = (teamId) => {
bots.forEach((rtm) => {
var stopBot = function(teamId) {
bots.forEach(function(rtm) {
if (rtm.teamId === teamId) { rtm.disconnect() }
})
}

var startBot = (teamId, rurl=null) => {
redis.hgetall("beebot.teamid." + teamId, (err, obj) => {
var startBot = function(teamId, rurl=null) {
redis.hgetall("beebot.teamid." + teamId, function(err, obj) {
console.log("DEBUG: obj and err are both null!")
console.log(`DEBUG: teamId/obj/err = ${teamId} / ${obj} / ${err}`)
var RtmClient = require('@slack/client').RtmClient
Expand All @@ -66,7 +66,7 @@ var startBot = (teamId, rurl=null) => {
autoReconnect: true,
})

rtm.on('message', (message) => {
rtm.on('message', function(message) {
if (!message.text) { return }
var regexpString = "<@" + rtm.activeUserId + ">"
if (message.text.match(new RegExp(regexpString))) {
Expand All @@ -80,11 +80,11 @@ var startBot = (teamId, rurl=null) => {
}
})

rtm.on('error', (bot) => { bot.disconnect() })
rtm.on('error', function(bot) { bot.disconnect() })

var CLIENT_EVENTS = require('@slack/client').CLIENT_EVENTS

rtm.on(CLIENT_EVENTS.RTM.AUTHENTICATED, (rtmStartData) => {
rtm.on(CLIENT_EVENTS.RTM.AUTHENTICATED, function(rtmStartData) {
rtm.userId = rtmStartData.self.id
})

Expand All @@ -95,13 +95,13 @@ var startBot = (teamId, rurl=null) => {
})
}

var handleCreateBot = (req, resp) => {
var handleCreateBot = function(req, resp) {
console.log(`DEBUG5: req = ${JSON.stringify(req)}`)
redis.hmset("beebot.teamid." + req.body.team_id,
{ bot_access_token: req.body.bot_access_token },
(err, obj) => {
function(err, obj) {
console.log("DEBUG2")
beebot.startBot(req.body.team_id) // beebot not defined here?
startBot(req.body.team_id)
resp.send("OK")
}
)
Expand Down

0 comments on commit c7c1bd5

Please sign in to comment.