Skip to content

Commit

Permalink
rename helper text -> transcript
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwofford committed Oct 16, 2019
1 parent 557fa45 commit b91e797
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions src/interactions/address.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getInfoForUser, text } from '../utils'
import { getInfoForUser, transcript } from '../utils'

const interactionAddress = (bot, message) => {
// check that they're a user
Expand All @@ -11,7 +11,7 @@ const interactionAddress = (bot, message) => {

bot.replyPrivateDelayed(
message,
text('address', { address: leaderAddress.fields })
transcript('address', { address: leaderAddress.fields })
)
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/announcement.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash'
import {
text as transcript,
transcript,
getInfoForUser,
initBot,
airPatch,
Expand Down
8 changes: 4 additions & 4 deletions src/interactions/catchall.js
Original file line number Diff line number Diff line change
@@ -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)
}
Expand Down
25 changes: 17 additions & 8 deletions src/interactions/checkinNotification.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,28 +16,35 @@ 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,
})
})
.catch(err => {
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,
})

Expand Down
4 changes: 2 additions & 2 deletions src/interactions/clubAddress.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getInfoForUser, text } from '../utils'
import { getInfoForUser, transcript } from '../utils'

const interactionClubAddress = (bot, message) => {
const { user } = message
Expand All @@ -13,7 +13,7 @@ const interactionClubAddress = (bot, message) => {

bot.replyPrivateDelayed(
message,
text('clubAddress', { address: clubAddress.fields })
transcript('clubAddress', { address: clubAddress.fields })
)
})
}
Expand Down
5 changes: 2 additions & 3 deletions src/interactions/hacktoberfest.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { getInfoForUser, text as transcript } from '../utils'
import { getInfoForUser, transcript } from '../utils'

const interactionHacktoberfest = (bot, message) => {
const { user, channel } = message
return getInfoForUser(user).then(({ userRecord }) => {
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') })
}
})
}
Expand Down
28 changes: 16 additions & 12 deletions src/interactions/hello.js
Original file line number Diff line number Diff line change
@@ -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
7 changes: 1 addition & 6 deletions src/interactions/leaderAdd.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/leaderInvite.js
Original file line number Diff line number Diff line change
@@ -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 =>
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/leaderList.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/meetingAdd.js
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/meetingTime.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
8 changes: 4 additions & 4 deletions src/interactions/meetingTutorial.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getInfoForUser, initBot, text } from '../utils'
import { getInfoForUser, initBot, transcript } from '../utils'

const interactionMeetingTutorial = (_bot, message) => {
const { user } = message
Expand All @@ -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'],
})
Expand All @@ -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
7 changes: 1 addition & 6 deletions src/interactions/promo.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/rename.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 10 additions & 10 deletions src/interactions/stats.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import _ from 'lodash'
import { getInfoForUser, text } from '../utils'
import { getInfoForUser, transcript } from '../utils'

const interactionStats = (bot, message) => {
const { user } = message

const loaderPromise = new Promise((resolve, reject) => {
bot.replyPrivateDelayed(
message,
text('stats.loadingMessage'),
transcript('stats.loadingMessage'),
(err, res) => {
if (err) {
reject(err)
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand All @@ -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
// }

Expand Down Expand Up @@ -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 }))
// }
}

Expand Down
14 changes: 7 additions & 7 deletions src/text.yml → src/transcript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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™
Expand Down Expand Up @@ -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\:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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}_

0 comments on commit b91e797

Please sign in to comment.