Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flox/env/manifest.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"lockfile-version": 1,
"manifest": {
"version": 1,
"schema-version": "1.12.0",
"install": {
"ack": {
"pkg-path": "ack"
Expand Down
2 changes: 1 addition & 1 deletion .flox/env/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# or see flox-edit(1), manifest.toml(5) for more information.
#
# Flox manifest version managed by Flox CLI
version = 1
schema-version = "1.12.0"

# List packages you wish to install in your environment inside
# the `[install]` section.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Mando Fun

This is the collection tools, daemons, libraries and binaries for collaborating
with your collegues across the internet.
with your colleagues across the internet.

The primary goal is to be things that are enjoyable to use, but ultimately have
some utility in terms of helping people accomplish something -- even if that
Expand Down
2 changes: 2 additions & 0 deletions hubot-modules/hubot-message-aggregator/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions hubot-modules/hubot-message-aggregator/src/aggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ const handleReaction = (res, robot) => {
handleReactionWithChannelId(res, robot, targetChannel, aggregatorPattern, regexFlags);
};

function isSlackAdapter(robot) {
const adapterName = robot.adapterName != null
? robot.adapterName
: robot.adapter && robot.adapter.name != null
? robot.adapter.name
: '';
return /slack/i.test(adapterName);
}

function handleReactionWithChannelId(res, robot, channelId, aggregatorPattern, regexFlags) {
const message = res.message;
const reactionRegex = new RegExp(aggregatorPattern, regexFlags);
Expand Down Expand Up @@ -182,7 +191,7 @@ function findChannelIdByName(robot, channelName) {
}

module.exports = (robot) => {
if (robot.adapterName !== 'slack') {
if (!isSlackAdapter(robot)) {
return;
}

Expand All @@ -196,4 +205,4 @@ module.exports.handleReaction = handleReaction;
module.exports.handleReactionWithChannelId = handleReactionWithChannelId;
module.exports.cleanupBrain = cleanupBrain;
module.exports.fetchMessagePermalink = fetchMessagePermalink;
module.exports.findChannelIdByName = findChannelIdByName;
module.exports.findChannelIdByName = findChannelIdByName;
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
findChannelIdByName,
fetchMessagePermalink
} = aggregator;
const isSlackAdapter = aggregator.__get__('isSlackAdapter');

describe('reaction-aggregator module exports', () => {
let robot;
Expand Down Expand Up @@ -573,6 +574,27 @@ describe('reaction-aggregator module exports', () => {
});
});

describe('isSlackAdapter', () => {
it('matches adapterName values containing slack', () => {
expect(isSlackAdapter({
adapterName: '@hubot-friends/hubot-slack'
})).to.be.true;
});

it('falls back to robot.adapter.name when adapterName is unset', () => {
expect(isSlackAdapter({
adapter: { name: 'SlackBot' }
})).to.be.true;
});

it('returns false when neither adapter value is slack', () => {
expect(isSlackAdapter({
adapterName: 'shell',
adapter: { name: 'discord' }
})).to.be.false;
});
});

describe('module initialization', () => {
it('does not register listener for non-slack adapter', () => {
const initRobot = {
Expand All @@ -594,6 +616,28 @@ describe('reaction-aggregator module exports', () => {
expect(initRobot.hearReaction.calledOnce).to.be.true;
});

it('registers hearReaction for adapter names containing slack', () => {
const initRobot = {
adapterName: '@hubot-friends/hubot-slack',
hearReaction: sinon.spy(),
logger: { error: sinon.spy(), info: sinon.spy() },
brain: { data: {} }
};
aggregator(initRobot);
expect(initRobot.hearReaction.calledOnce).to.be.true;
});

it('registers hearReaction when robot.adapter.name contains slack', () => {
const initRobot = {
adapter: { name: 'Slack Adapter' },
hearReaction: sinon.spy(),
logger: { error: sinon.spy(), info: sinon.spy() },
brain: { data: {} }
};
aggregator(initRobot);
expect(initRobot.hearReaction.calledOnce).to.be.true;
});

it('runs brain cleanup on 24-hour interval', () => {
const initRobot = {
adapterName: 'slack',
Expand All @@ -619,4 +663,4 @@ describe('reaction-aggregator module exports', () => {
expect(initRobot.brain.data).to.have.property('permalink_fresh');
});
});
});
});
18 changes: 15 additions & 3 deletions hubot-modules/hubot-slacklogs/src/slacklogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ const slackClient = slackToken ? new WebClient(slackToken) : null;
// In-memory cache for room name/type
const roomCache = new Map();

function getAdapterName(robot) {
return robot.adapterName != null
? robot.adapterName
: robot.adapter && robot.adapter.name != null
? robot.adapter.name
: '';
}

function isSlackAdapter(robot) {
return /slack/i.test(getAdapterName(robot));
}

function getSlackRoomType(roomId) {
if (!roomId || typeof roomId !== 'string') return 'unknown';
if (roomId.startsWith('C')) return 'public_channel';
Expand Down Expand Up @@ -74,8 +86,9 @@ async function getRoomInfo(roomId) {
}

module.exports = (robot) => {
if (robot.adapterName !== 'slack') {
console.log(`[hubot-logger] Adapter is '${robot.adapterName}', skipping Slack-specific logging.`);
const adapterName = getAdapterName(robot);
if (!isSlackAdapter(robot)) {
console.log(`[hubot-logger] Adapter is '${adapterName}', skipping Slack-specific logging.`);
return;
}

Expand Down Expand Up @@ -113,4 +126,3 @@ module.exports = (robot) => {
}
});
};

11 changes: 10 additions & 1 deletion hubot-modules/hubot-wisdom/src/wisdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ const {
WebClient
} = require('@slack/web-api');

function isSlackAdapter(robot) {
const adapterName = robot.adapterName != null
? robot.adapterName
: robot.adapter && robot.adapter.name != null
? robot.adapter.name
: '';
return /slack/i.test(adapterName);
}

module.exports = (robot) => {

// Listening for quotes and storing them
Expand All @@ -41,7 +50,7 @@ module.exports = (robot) => {
});

// Check if the bot is running in Slack
if(robot.adapterName === 'slack') {
if(isSlackAdapter(robot)) {
const slackMessage = msg.message.rawMessage;

if(slackMessage && slackMessage.ts && slackMessage.channel) {
Expand Down