Skip to content

Commit

Permalink
debug attempt 1: send channel messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bsoule committed Dec 1, 2023
1 parent 86955ef commit f5bb922
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions lib/beebot.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,28 @@ var handleZeno = (req, res) => {

if (req.body.channel) {
webClient.conversations.list({}, (error, response) => {
const target = req.body.channel
if (!response.ok) {
console.error("error in conversations.list: " + response)
console.error("DEBUG1: error: ", error)
return
} //TODO: alert
for (var i = 0; i < response.channels.length; i++) {
const toChl = response.channels[i]
if (channel.name !== channel.replace('#', '')) { continue }
webClient.chat.postMessage(channel.id, req.body.message)
try {
const target = req.body.channel.replace('#', '')
if (!response.ok) {
console.error("error in conversations.list: " + response)
console.error("DEBUG1: error: ", error)
return
} //TODO: alert
for (var i = 0; i < response.channels.length; i++) {
const toChl = response.channels[i]
if (toChl.name === target) {
webClient.chat.postMessage(toChl.id, req.body.message)
} else {
// no match, no message
}
}
} catch (error) {
// this maybe doesn't actually catch errors because of promises or something?
console.log('caught an error', error)
}
console.log(`could not find a channel with the name ${req.body.channel}`)
})
res.send("ok");
return
res.send("ok");
return
});
} else {

// open the dm channel if we didn't find a user
Expand Down

0 comments on commit f5bb922

Please sign in to comment.