Skip to content

Commit

Permalink
ft: adds regional chapters button (#117)
Browse files Browse the repository at this point in the history
refactor: moves channel ids and constants into config

Signed-off-by: Precious Abubakar <[email protected]>
  • Loading branch information
misspee007 authored Oct 22, 2024
1 parent 383898b commit 5772e03
Show file tree
Hide file tree
Showing 11 changed files with 239 additions and 153 deletions.
82 changes: 43 additions & 39 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
const { App } = require('@slack/bolt');
const newbie = require('./components/newbie');
const theActions = require('./components/actions/actionResponses');
const mentorshipAction = require('./components/actions/mentorshipAction');
const mentorshipResponses = require('./components/actions/mentorshipResponses');
const outreachyPrompt = require('./components/outreachyPrompt');

const joinChaossAfrica = require('./components/chaossAfrica/joinChaossAfrica');
const chaossAfrica = require('./components/chaossAfrica/africa');

const joinTeam = require('./components/joinTeam');
const memberJoinChannel = require('./components/joinChannel');

const dotenv = require('dotenv');
const { App } = require("@slack/bolt");
const newbie = require("./components/newbie");
const theActions = require("./components/actions/actionResponses");
const mentorshipAction = require("./components/actions/mentorshipAction");
const mentorshipResponses = require("./components/actions/mentorshipResponses");
const outreachyPrompt = require("./components/outreachyPrompt");
const {
chaossAfricaInfo,
joinChaossAfrica,
} = require("./components/chaossAfrica");

const joinTeam = require("./components/joinTeam");
const memberJoinChannel = require("./components/joinChannel");

const dotenv = require("dotenv");

dotenv.config();

Expand All @@ -32,85 +33,90 @@ app.message(/newbie/i, async ({ message, client, logger }) => {

//This responds to a member when they type africa in any channel where the bot is present
app.message(/africa-info/i, async ({ message, client, logger }) => {
chaossAfrica.chaossAfrica(message, client, logger);
chaossAfricaInfo(message, client, logger);
});

// handle the button click and show the responses
app.action('develop', async ({ ack, say }) => {
app.action("develop", async ({ ack, say }) => {
await ack();
theActions.develop(say);
});

app.action('joinMeet', async ({ ack, say }) => {
app.action("joinMeet", async ({ ack, say }) => {
// Acknowledge the action
await ack();
theActions.joinMeet(say);
});

app.action('contribute', async ({ ack, say }) => {
app.action("contribute", async ({ ack, say }) => {
// Acknowledge the action
await ack();
theActions.contribute(say);
});

app.action('helpWithWebsite', async ({ ack, say }) => {
app.action("helpWithWebsite", async ({ ack, say }) => {
await ack();
theActions.helpWithWebsite(say);
});

app.action('docs', async ({ ack, say }) => {
app.action("docs", async ({ ack, say }) => {
await ack();
theActions.docs(say);
});

app.action('mentorship', async ({ ack, say }) => {
app.action("mentorship", async ({ ack, say }) => {
await ack();
mentorshipAction.mentorship(say);
});

// this handler is for the nested radio buttons above
app.action('mentorship_selection', async ({ action, ack, say }) => {
app.action("mentorship_selection", async ({ action, ack, say }) => {
await ack();
console.log(action.selected_option.value);
if (action.selected_option.value === 'outreachy') {
if (action.selected_option.value === "outreachy") {
mentorshipResponses.outreachy(say);
}
if (action.selected_option.value === 'gsoc') {
mentorshipResponses.gsoc(say);
if (action.selected_option.value === "gsoc") {
mentorshipResponses.googleSummerOfCode(say);
}
if (action.selected_option.value === 'gsod') {
mentorshipResponses.gsod(say);
if (action.selected_option.value === "gsod") {
mentorshipResponses.googleSeasonOfDocs(say);
}
});

app.action('implement_metrics', async ({ ack, say }) => {
app.action("implement_metrics", async ({ ack, say }) => {
await ack();
theActions.implement_metrics(say);
});

app.action('learn_something_else', async ({ ack, say }) => {
app.action("regional_chapters", async ({ ack, say }) => {
await ack();
theActions.regional_chapters(say);
});

app.action("learn_something_else", async ({ ack, say }) => {
await ack();
theActions.learn_something_else(say);
});

app.action('faqs', async ({ ack, say }) => {
app.action("faqs", async ({ ack, say }) => {
await ack();
theActions.faqs(say);
});
//****************************************** */

// When a user joins the team, the bot sends a DM to the newcommer asking them how they would like to contribute
app.event('team_join', async ({ event, client, logger }) => {
app.event("team_join", async ({ event, client, logger }) => {
joinTeam.joinTeamSlack(event, client, logger); // this is the function that sends the DM
memberJoinChannel.memberJoin(event, client, logger); // this is for the #projectbot channel
});

//*********************************************************** */

// *******When a user join chaossafrica channel, the bot sends a welcome message and the goal of the community******//
app.event('member_joined_channel', async({ event, client, logger }) => {
joinChaossAfrica.joinChaossAfrica(event, client, logger)
})
app.event("member_joined_channel", async ({ event, client, logger }) => {
joinChaossAfrica.joinChaossAfrica(event, client, logger);
});

// ************************************************************************************************//

Expand All @@ -119,7 +125,7 @@ app.message(/outreachy/i, async ({ message, say, logger }) => {
outreachyPrompt.outreachyMessage(message, say, logger);
});

// *******************************DIRECT MESSAGE - ONE TIME ANNOUNCEMENT TO INTRODUCE THE BOT************/
// *******************************DIRECT MESSAGE - ONE TIME ANNOUNCEMENT************/
/*
let usersStore = {};
Expand Down Expand Up @@ -154,10 +160,8 @@ function saveUsers(usersArray) {
});
}
*/
//************ */

(async () => {
// Start your app
await app.start(process.env.PORT || 3000);

console.log('⚡️ Bolt app is running!');
console.log("⚡️ Bolt app is running!");
})();
39 changes: 34 additions & 5 deletions components/actions/actionResponses.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const config = require("../../config");

async function develop(say) {
return await say(
`You clicked *Develop Metrics* \n
Expand Down Expand Up @@ -44,19 +46,45 @@ async function implement_metrics(say) {
);
}

async function regional_chapters(say) {
const baseUrl = `${config.workspaceUrl}/archives`;
const { africa, asia, balkans, lac } = config.channels;
return await say({
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: `You clicked *Join a Regional Chapter*
\nOur local chapters are ways to collaborate with others in your region. You can learn more about them here: https://chaoss.community/kb/local-chapters. You can also check out our different regional chapter channels and join one of them depending on your region:
- <#${africa}> for CHAOSS Africa
- <#${asia}> for CHAOSS Asia
- <#${balkans}> for CHAOSS Balkans
- <#${lac}> for CHAOSS Latin America & Caribbean`,
},
},
],
text: `You clicked *Join a Regional Chapter*.
Our local chapters are ways to collaborate with others in your region. You can join the channels:
CHAOSS Africa: ${baseUrl}/${africa}
CHAOSS Asia: ${baseUrl}/${asia}
CHAOSS Balkans: ${baseUrl}/${balkans}
CHAOSS Latin America and Caribbean: ${baseUrl}/${lac}`,
});
}

async function learn_something_else(say) {
return await say(
`You clicked *Learn About Something Else*\n
We encourage you to read through our Community Documentation: https://chaoss.community/kb-chaoss-community/, and if you still can't find what you're looking for, feel free to ask your question in our <#C0207C3RETX> slack channel.`

We encourage you to read through our Community Documentation: https://chaoss.community/kb-chaoss-community/, and if you still can't find what you're looking for, feel free to ask your question in our <#${config.channels.newcomers}> slack channel.`
);
}

async function faqs(say) {
return await say(
`You clicked *FAQs*\n
We encourage you to read through our Frequently Asked Questions: https://handbook.chaoss.community/community-handbook/about/general-faq, and if you still can't find what you're looking for, feel free to ask your question in our <#C0207C3RETX> slack channel.`

We encourage you to read through our Frequently Asked Questions: https://handbook.chaoss.community/community-handbook/about/general-faq, and if you still can't find what you're looking for, feel free to ask your question in our <#${config.channels.newcomers}> slack channel.`
);
}

Expand All @@ -67,6 +95,7 @@ module.exports = {
contribute,
helpWithWebsite,
implement_metrics,
regional_chapters,
learn_something_else,
faqs
faqs,
};
17 changes: 0 additions & 17 deletions components/actions/constants/constants.json

This file was deleted.

31 changes: 14 additions & 17 deletions components/actions/mentorshipResponses.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
const constantData = require('./constants/constants.json');
const config = require("../../config");

async function outreachy(say) {
let responseString = constantData.Outreachy.status ? constantData.Outreachy.activeStatement : constantData.Outreachy.notActiveStatement;
return await say(
responseString
);
const { status, activeStatement, notActiveStatement } = config.outreachy;
const response = status ? activeStatement : notActiveStatement;
return await say(response);
}

async function gsoc(say) {
let responseString = constantData.GSoC.status ? constantData.GSoC.activeStatement : constantData.GSoC.notActiveStatement;
return await say(
responseString
);
async function googleSummerOfCode(say) {
const { status, activeStatement, notActiveStatement } = config.googleSummerOfCode;
let response = status ? activeStatement : notActiveStatement;
return await say(response);
}

async function gsod(say) {
let responseString = constantData.GSoD.status ? constantData.GSoD.activeStatement : constantData.GSoD.notActiveStatement;
return await say(
responseString
);
async function googleSeasonOfDocs(say) {
const { status, activeStatement, notActiveStatement } = config.googleSeasonOfDocs;
let response = status ? activeStatement : notActiveStatement;
return await say(response);
}

module.exports = {
outreachy,
gsoc,
gsod,
googleSummerOfCode,
googleSeasonOfDocs,
};
34 changes: 0 additions & 34 deletions components/chaossAfrica/africa.js

This file was deleted.

Loading

0 comments on commit 5772e03

Please sign in to comment.