Comments (7)
Here's a patch @drislands and I cooked up for a quick fix. Took some inspiration from https://github.com/slackapi/node-slack-sdk/wiki/DataStore-v3.x-Migration-Guide
--- a/lib/bot.js 2021-08-27 23:34:32.622846730 -0700
+++ b/lib/bot.js 2021-08-27 23:34:28.351824023 -0700
@@ -254,27 +254,29 @@
return;
}
- const currentChannelUsernames = slackChannel.members.map(member =>
- dataStore.getUserById(member).name
- );
+ this.slack.web.conversations.members(slackChannel.id).then( resp => {
+ const currentChannelUsernames = resp.members.map(member =>
+ dataStore.getUserById(member).name
+ );
- const mappedText = currentChannelUsernames.reduce((current, username) =>
- highlightUsername(username, current)
- , text);
+ const mappedText = currentChannelUsernames.reduce((current, username) =>
+ highlightUsername(username, current)
+ , text);
- let iconUrl;
- if (author !== this.nickname && this.avatarUrl) {
- iconUrl = this.avatarUrl.replace(/\$username/g, author);
- }
+ let iconUrl;
+ if (author !== this.nickname && this.avatarUrl) {
+ iconUrl = this.avatarUrl.replace(/\$username/g, author);
+ }
- const options = {
- username: this.slackUsernameFormat.replace(/\$username/g, author),
- parse: 'full',
- icon_url: iconUrl
- };
+ const options = {
+ username: this.slackUsernameFormat.replace(/\$username/g, author),
+ parse: 'full',
+ icon_url: iconUrl
+ };
- logger.debug('Sending message to Slack', mappedText, channel, '->', slackChannelName);
- this.slack.web.chat.postMessage(slackChannel.id, mappedText, options);
+ logger.debug('Sending message to Slack', mappedText, channel, '->', slackChannelName);
+ this.slack.web.chat.postMessage(slackChannel.id, mappedText, options);
+ });
}
}
}
from slack-irc.
@bovine I've just submitted a pull request for the change
from slack-irc.
We are having the same issue. I have spent a couple of hours debugging to try and find out why this has just randomly stopped working. So far not found anything. Will keep looking.
Adam Horden
from slack-irc.
My bot has stopped working too. It manages to join IRC, then soon dies with this message:
/usr/lib/node_modules/slack-irc/node_modules/irc/lib/irc.js:849
throw err;
^
TypeError: Cannot read property 'map' of undefined
at Bot.sendToSlack (/usr/lib/node_modules/slack-irc/dist/bot.js:295:60)
at emitMany (events.js:147:13)
at Client.emit (events.js:224:7)
at Client.<anonymous> (/usr/lib/node_modules/slack-irc/node_modules/irc/lib/irc.js:557:22)
at emitOne (events.js:116:13)
at Client.emit (events.js:211:7)
at iterator (/usr/lib/node_modules/slack-irc/node_modules/irc/lib/irc.js:846:26)
at Array.forEach (<anonymous>)
at Socket.handleData (/usr/lib/node_modules/slack-irc/node_modules/irc/lib/irc.js:841:15)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:246:13)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:601:20)
from slack-irc.
Unless I'm mistaken, this is the line that is failing:
var currentChannelUsernames = slackChannel.members.map(function (member) {
Whatever part of the code that gets the members list is not working, for some reason. Perhaps an API change on Slack's end?
from slack-irc.
@gkelle Perhaps you could submit that change as a new pull request and reference this issue?
from slack-irc.
I can confirm this is working for me. Would be nice for @ekmartin to accept the PR.
from slack-irc.
Related Issues (20)
- Not able to use after updating to latest version HOT 1
- README now clear on where things need to be installed HOT 1
- How do I know what to use for Token? Mapping? HOT 2
- Bot crashes when more than 15 rooms are relayed HOT 1
- Use display name rather than username HOT 1
- Feature Request: Allow bot to simulate direct messages HOT 2
- public vs private "groups" (channels) HOT 1
- Dockerize slack-irc HOT 2
- Slack thread support
- Highlight problem
- New (updated) Docker container for slack-irc HOT 2
- Slack-IRC reconnects when adding/removing bans/quiets. HOT 1
- error: Response not OK: missing_scope info: Unable to rtm.start, attempting reconnect HOT 1
- Messages from external users in shared workspaces causes a crash
- Crash when reading text in IRC channel HOT 1
- IT DOESNT WORK HOT 1
- Suggesting some changes from my repo HOT 1
- Thread replies also sent to channel aren't bridged.
- slack user email names getting injected into text, replacing organization name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slack-irc.