diff --git a/src/index.js b/src/index.js index a8a5e01a..c9790900 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ import _ from 'lodash' import bugsnag from '@bugsnag/js' import controller from './controller' -import { text as transcript } from './utils' +import { transcript } from './utils' import interactionCheckin from './interactions/checkin' import interactionDate from './interactions/date' diff --git a/src/interactions/address.js b/src/interactions/address.js index 03761eac..3fb50452 100644 --- a/src/interactions/address.js +++ b/src/interactions/address.js @@ -1,4 +1,4 @@ -import { getInfoForUser, text } from '../utils' +import { getInfoForUser, transcript } from '../utils' const interactionAddress = (bot, message) => { // check that they're a user @@ -11,7 +11,7 @@ const interactionAddress = (bot, message) => { bot.replyPrivateDelayed( message, - text('address', { address: leaderAddress.fields }) + transcript('address', { address: leaderAddress.fields }) ) }) } diff --git a/src/interactions/announcement.js b/src/interactions/announcement.js index 9068cd14..6b00ea3f 100644 --- a/src/interactions/announcement.js +++ b/src/interactions/announcement.js @@ -1,6 +1,6 @@ import _ from 'lodash' import { - text as transcript, + transcript, getInfoForUser, initBot, airPatch, diff --git a/src/interactions/catchall.js b/src/interactions/catchall.js index 29f65bfe..0e690a18 100644 --- a/src/interactions/catchall.js +++ b/src/interactions/catchall.js @@ -1,17 +1,17 @@ -import { text, getInfoForUser } from '../utils' +import { transcript, getInfoForUser } from '../utils' const interactionCatchall = (bot, message) => { const { ts: timestamp, channel, user } = message getInfoForUser(user).then(({ slackUser }) => { if (slackUser.is_bot) { - bot.replyInThread(message, text('catchall.botReply')) + bot.replyInThread(message, transcript('catchall.botReply')) } else { if (Math.random() > 0.5) { - bot.replyInThread(message, text('catchall.reply')) + bot.replyInThread(message, transcript('catchall.reply')) } else { bot.api.reactions.add( - { timestamp, channel, name: text('catchall.emoji') }, + { timestamp, channel, name: transcript('catchall.emoji') }, err => { if (err) console.error(err) } diff --git a/src/interactions/checkinNotification.js b/src/interactions/checkinNotification.js index c21895ed..330d0761 100644 --- a/src/interactions/checkinNotification.js +++ b/src/interactions/checkinNotification.js @@ -1,11 +1,13 @@ -import { initBot, airFind, userRecord, text } from '../utils' +import { initBot, airFind, userRecord, transcript } from '../utils' const interactionCheckinNotification = (bot = initBot(), message) => { const { channel } = message let { user } = message if (!user) { - console.log(text('checkinNotification.log.lookingForPOC', { channel })) + console.log( + transcript('checkinNotification.log.lookingForPOC', { channel }) + ) airFind('Clubs', 'Slack Channel ID', channel) .then(club => { const pocAirtableID = club.fields.POC @@ -14,10 +16,13 @@ const interactionCheckinNotification = (bot = initBot(), message) => { .then(leader => { user = leader.fields['Slack ID'] console.log( - text('checkinNotification.log.foundPoc', { channel, user }) + transcript('checkinNotification.log.foundPoc', { + channel, + user, + }) ) bot.say({ - text: text('checkinNotification.named', { user }), + text: transcript('checkinNotification.named', { user }), channel, }) }) @@ -25,17 +30,21 @@ const interactionCheckinNotification = (bot = initBot(), message) => { throw err }) } else { - console.log(text('checkinNotification.log.noPOCFound', { channel })) - bot.say({ text: text('checkinNotification.unnamed'), channel }) + console.log( + transcript('checkinNotification.log.noPOCFound', { channel }) + ) + bot.say({ text: transcript('checkinNotification.unnamed'), channel }) } }) .catch(err => { throw err }) } else { - console.log(text('checkinNotification.log.posting', { user, channel })) + console.log( + transcript('checkinNotification.log.posting', { user, channel }) + ) bot.say({ - text: text('checkinNotification.named', { user }), + text: transcript('checkinNotification.named', { user }), channel, }) diff --git a/src/interactions/clubAddress.js b/src/interactions/clubAddress.js index 169f4c27..f9471f87 100644 --- a/src/interactions/clubAddress.js +++ b/src/interactions/clubAddress.js @@ -1,4 +1,4 @@ -import { getInfoForUser, text } from '../utils' +import { getInfoForUser, transcript } from '../utils' const interactionClubAddress = (bot, message) => { const { user } = message @@ -13,7 +13,7 @@ const interactionClubAddress = (bot, message) => { bot.replyPrivateDelayed( message, - text('clubAddress', { address: clubAddress.fields }) + transcript('clubAddress', { address: clubAddress.fields }) ) }) } diff --git a/src/interactions/hacktoberfest.js b/src/interactions/hacktoberfest.js index 257c7c86..e2dcd67f 100644 --- a/src/interactions/hacktoberfest.js +++ b/src/interactions/hacktoberfest.js @@ -1,4 +1,4 @@ -import { getInfoForUser, text as transcript } from '../utils' +import { getInfoForUser, transcript } from '../utils' const interactionHacktoberfest = (bot, message) => { const { user, channel } = message @@ -6,8 +6,7 @@ const interactionHacktoberfest = (bot, message) => { if (!userRecord.fields['Flag: Hacktoberfest 2019']) { userRecord.patch({ 'Flag: Hacktoberfest 2019': true }) - const text = transcript('hacktoberfest') - bot.sendEphemeral({ channel, user, text }) + bot.sendEphemeral({ channel, user, text: transcript('hacktoberfest') }) } }) } diff --git a/src/interactions/hello.js b/src/interactions/hello.js index 0471bc63..37043392 100644 --- a/src/interactions/hello.js +++ b/src/interactions/hello.js @@ -1,19 +1,23 @@ -import { text } from '../utils' +import { transcript } from '../utils' const interactionHello = (bot, message) => { // send a message back with a typo - bot.replyAndUpdate(message, text('hello'), (err, src, updateResponse) => { - if (err) { - console.error(err) - return + bot.replyAndUpdate( + message, + transcript('hello'), + (err, src, updateResponse) => { + if (err) { + console.error(err) + return + } + // oh no, "hellp" is a typo - let's update the message to "hello" + setTimeout(() => { + updateResponse('hello', err => { + if (err) console.error(err) + }) + }, Math.random() * 5000 + 2000) } - // oh no, "hellp" is a typo - let's update the message to "hello" - setTimeout(() => { - updateResponse('hello', err => { - if (err) console.error(err) - }) - }, Math.random() * 5000 + 2000) - }) + ) } export default interactionHello diff --git a/src/interactions/leaderAdd.js b/src/interactions/leaderAdd.js index 45ac5907..ad1bf07c 100644 --- a/src/interactions/leaderAdd.js +++ b/src/interactions/leaderAdd.js @@ -1,9 +1,4 @@ -import { - getInfoForUser, - airCreate, - airPatch, - text as transcript, -} from '../utils' +import { getInfoForUser, airCreate, airPatch, transcript } from '../utils' const interactionLeaderAdd = (bot, message) => { const { user, text, channel } = message diff --git a/src/interactions/leaderInvite.js b/src/interactions/leaderInvite.js index e7d48016..5f788f73 100644 --- a/src/interactions/leaderInvite.js +++ b/src/interactions/leaderInvite.js @@ -1,4 +1,4 @@ -import { getInfoForUser, airFind, initBot, text as transcript } from '../utils' +import { getInfoForUser, airFind, initBot, transcript } from '../utils' const LEADERS_CHANNEL = 'GAE0FFNFN' const invitePromise = leaderRecordID => diff --git a/src/interactions/leaderList.js b/src/interactions/leaderList.js index 2fe4c854..f706b9a4 100644 --- a/src/interactions/leaderList.js +++ b/src/interactions/leaderList.js @@ -1,4 +1,4 @@ -import { getInfoForUser, airGet, text as transcript } from '../utils' +import { getInfoForUser, airGet, transcript } from '../utils' const interactionLeaderList = (bot, message) => { const { channel, user } = message diff --git a/src/interactions/meetingAdd.js b/src/interactions/meetingAdd.js index 487080b7..6c050c27 100644 --- a/src/interactions/meetingAdd.js +++ b/src/interactions/meetingAdd.js @@ -1,6 +1,6 @@ import { parseDate } from 'chrono-node' -import { recordMeeting, getInfoForUser, text as transcript } from '../utils' +import { recordMeeting, getInfoForUser, transcript } from '../utils' const interactionMeetingAdd = (bot, message) => { getInfoForUser(message.user).then(({ club, history, slackUser }) => { diff --git a/src/interactions/meetingTime.js b/src/interactions/meetingTime.js index 86316def..597f4123 100644 --- a/src/interactions/meetingTime.js +++ b/src/interactions/meetingTime.js @@ -1,4 +1,4 @@ -import { getInfoForUser, airPatch, text as transcript } from '../utils' +import { getInfoForUser, airPatch, transcript } from '../utils' import { parseDate } from 'chrono-node' import interactionCheckinNotification from './checkinNotification' diff --git a/src/interactions/meetingTutorial.js b/src/interactions/meetingTutorial.js index b3f8d422..567a27fa 100644 --- a/src/interactions/meetingTutorial.js +++ b/src/interactions/meetingTutorial.js @@ -1,4 +1,4 @@ -import { getInfoForUser, initBot, text } from '../utils' +import { getInfoForUser, initBot, transcript } from '../utils' const interactionMeetingTutorial = (_bot, message) => { const { user } = message @@ -7,11 +7,11 @@ const interactionMeetingTutorial = (_bot, message) => { getInfoForUser(user) .then(({ userRecord, club }) => { if (userRecord.fields['Flag: Initiated tutorial']) { - bot.replyPrivateDelayed(message, text('tutorial.alreadyStarted')) + bot.replyPrivateDelayed(message, transcript('tutorial.alreadyStarted')) } else { bot.replyPrivateDelayed( message, - text('tutorial.start', { + transcript('tutorial.start', { user, channel: club.fields['Slack Channel ID'], }) @@ -22,7 +22,7 @@ const interactionMeetingTutorial = (_bot, message) => { }) }) .catch(err => { - bot.replyPrivateDelayed(message, text('errors.memory', { err })) + bot.replyPrivateDelayed(message, transcript('errors.memory', { err })) }) } export default interactionMeetingTutorial diff --git a/src/interactions/promo.js b/src/interactions/promo.js index 6259dd8f..aaaec03c 100644 --- a/src/interactions/promo.js +++ b/src/interactions/promo.js @@ -1,9 +1,4 @@ -import { - getInfoForUser, - text as transcript, - airFind, - airCreate, -} from '../utils' +import { getInfoForUser, transcript, airFind, airCreate } from '../utils' const sdpLink = club => new Promise((resolve, reject) => { diff --git a/src/interactions/rename.js b/src/interactions/rename.js index 4f6e8785..67823977 100644 --- a/src/interactions/rename.js +++ b/src/interactions/rename.js @@ -1,4 +1,4 @@ -import { initBot, text as transcript, getInfoForUser } from '../utils' +import { initBot, transcript, getInfoForUser } from '../utils' const interactionRename = (bot, message) => { const { user, channel } = message diff --git a/src/interactions/stats.js b/src/interactions/stats.js index 69840078..ca7c09d3 100644 --- a/src/interactions/stats.js +++ b/src/interactions/stats.js @@ -1,5 +1,5 @@ import _ from 'lodash' -import { getInfoForUser, text } from '../utils' +import { getInfoForUser, transcript } from '../utils' const interactionStats = (bot, message) => { const { user } = message @@ -7,7 +7,7 @@ const interactionStats = (bot, message) => { const loaderPromise = new Promise((resolve, reject) => { bot.replyPrivateDelayed( message, - text('stats.loadingMessage'), + transcript('stats.loadingMessage'), (err, res) => { if (err) { reject(err) @@ -37,11 +37,11 @@ const interactionStats = (bot, message) => { // }) if (!leader || !club) { - bot.replyPrivateDelayed(message, text('stats.notFound')) + bot.replyPrivateDelayed(message, transcript('stats.notFound')) return } if (!history || !history.meetings) { - bot.replyPrivateDelayed(message, text('stats.noMeeting')) + bot.replyPrivateDelayed(message, transcript('stats.noMeeting')) return } @@ -83,13 +83,13 @@ const interactionStats = (bot, message) => { }) .catch(err => { console.error(err) - bot.replyPrivateDelayed(message, text('errors.general', { err })) + bot.replyPrivateDelayed(message, transcript('errors.general', { err })) }) // try { // bot.replyAndUpdate( // message, - // text('stats.loadingMessage'), + // transcript('stats.loadingMessage'), // (err, src, updateResponse) => { // if (err) { // throw err @@ -98,11 +98,11 @@ const interactionStats = (bot, message) => { // .then(({ leader, club, history }) => { // setTimeout(() => { // if (!leader || !club) { - // updateResponse(text('stats.notFound')) + // updateResponse(transcript('stats.notFound')) // return // } // if (!history || !history.meetings) { - // updateResponse(text('stats.noMeeting')) + // updateResponse(transcript('stats.noMeeting')) // return // } @@ -145,14 +145,14 @@ const interactionStats = (bot, message) => { // }, 2000) // }) // .catch(err => { - // updateResponse(text('stats.error', { err })) + // updateResponse(transcript('stats.error', { err })) // throw { err } // }) // } // ) // } catch (err) { // console.error(err) - // bot.whisper(message, text('errors.general', { err })) + // bot.whisper(message, transcript('errors.general', { err })) // } } diff --git a/src/text.yml b/src/transcript.yml similarity index 96% rename from src/text.yml rename to src/transcript.yml index ba35f13a..2539913a 100644 --- a/src/text.yml +++ b/src/transcript.yml @@ -91,7 +91,7 @@ announcement: To prevent a race condition where 2 admins try sending announcements at the same time, the address verb is disabled. To queue up clubs for an announcement, check the "Announcement Queued" checkbox for your target clubs in Airtable unrecognizedCommand: | I couldn't figure out what action you're trying to take. Here's the help text. - ${this.text('announcement.help')} + ${this.t('announcement.help')} notExactSlackMatch: | I couldn't pull up that Slack message. This is probably a limitation of Slack's permissions for bots– we can't query ephemeral messages, private channels, etc. whatAreYouDoing: @@ -124,7 +124,7 @@ checkinNotification: noPOCFound: "*I didn't find a POC for the club in channel '${this.channel}', so I'll just post the notification without tagging anyone*" posting: "*Posting a checkin notification in channel '${this.channel}' & tagging user '${this.user}'!*" stats: - loadingMessage: ":beachball: ${this.text('stats.loadingFlavor')}" + loadingMessage: ":beachball: ${this.t('stats.loadingFlavor')}" loadingFlavor: - chugging the data juice - chugging *Stat-Cola©*, for those who want to know things™ @@ -171,7 +171,7 @@ tutorial: errors: general: | Something went wrong\: \`${this.err}\` - ${this.err.stack ? this.text('errors.stack', {err:this.err}):''} + ${this.err.stack ? this.t('errors.stack', {err:this.err}):''} stack: | \`\`\` // Here's my stacktrace from my code at https://github.com/maxwofford/orpheus-bot-hackclub\: @@ -236,8 +236,8 @@ leaderList: - rulers - commanding officers list: > - \*The ${this.text('leaderList.leaderFlavor')} of <#${this.channel}>:* - ${this.leaders.map(leader => this.text('leaderList.leader', { leader } ))} + \*The ${this.t('leaderList.leaderFlavor')} of <#${this.channel}>:* + ${this.leaders.map(leader => this.t('leaderList.leader', { leader } ))} leader: "\n- <@${this.leader.fields['Slack ID']}>" promos: githubSDP: @@ -269,11 +269,11 @@ promos: Here are the details for your records\: \> Grant request ID\: *${this.record}* \> Grant type\: *$100 provided by GitHub* - \> Has a bank account\: *${this.text('promos.githubGrant.success.hcbEmoji.' + this.hcb)}* + \> Has a bank account\: *${this.t('promos.githubGrant.success.hcbEmoji.' + this.hcb)}* \> Submitted by\: *<@${this.user}> (@${this.user})* Just one quick note though\: Next time you record a club meeting with \`/meeting-add\`, you'll see a link to dropbox.hackclub.com. We'd really appreciate it if you put some photos of your club meeting in there that we can show GitHub. This is the first semester we're partnering with GitHub and if they're happy with the results this could happen in the future. promo: help: 'Request a promotion / partnership through Hack Club. Try \`/promo Free Notion\`' - list: Here are the active promotions you can use ${this.promos.map(p => this.text('promo.bullet', { p }))} + list: Here are the active promotions you can use ${this.promos.map(p => this.t('promo.bullet', { p }))} bullet: \n- \`/promo ${this.p.name}\` _${this.p.details}_ \ No newline at end of file