diff --git a/readme.md b/readme.md index 073ac32..9834c37 100644 --- a/readme.md +++ b/readme.md @@ -41,6 +41,8 @@ Variable | Default | Description `LAST_FM_KEY` | | Access to Last.fm data `LAST_FM_USERNAME` | | Which user to get track info for `SLACK_TOKEN` | | Personal "legacy" token for updating your Slack status +`SLACK_EMOJI` | `:headphones:` | Specify which emoji to use in the status +`SLACK_SEPARATOR` | `•` | Specify which character to use as a separator between the track name and artist `TZ` | `UTC` | Set the timezone `ACTIVE_HOURS_START` | `9` | The hour of the day to start updating your Slack status `ACTIVE_HOURS_END` | `17` | The hour of the day to stop updating your Slack status diff --git a/src/config.ts b/src/config.ts index 3c247e5..935eda6 100644 --- a/src/config.ts +++ b/src/config.ts @@ -3,6 +3,8 @@ const { LAST_FM_SECRET = '', LAST_FM_USERNAME = '', SLACK_TOKEN = '', + SLACK_EMOJI = ':headphones:', + SLACK_SEPARATOR = '•', TZ = 'Australia/Melbourne', ACTIVE_HOURS_START = '9', ACTIVE_HOURS_END = '17', @@ -19,7 +21,9 @@ export const lastFM = { export const slack = { apiUrl: 'https://slack.com/api', - token: SLACK_TOKEN + token: SLACK_TOKEN, + emoji: SLACK_EMOJI, + separator: SLACK_SEPARATOR } export const activeHours = { diff --git a/src/index.ts b/src/index.ts index 0d9acce..ccf8337 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,7 +45,7 @@ async function setSlackStatus (status: string) { const body = { profile: { status_text: status, - status_emoji: status !== '' ? ':headphones:' : '', + status_emoji: status !== '' ? config.slack.emoji : '', status_expiration: 0 } } @@ -159,7 +159,9 @@ async function main () { // Update! let status = nowPlaying.name - status += ' • ' + status += ' ' + status += config.slack.separator + status += ' ' status += nowPlaying.artist['#text'] console.log(`${LOG_SLK} Setting status to "${status}"`) diff --git a/src/utils.ts b/src/utils.ts index fc7d8be..18bfdbc 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -84,7 +84,7 @@ export function getNowPlaying (tracks: LastFM.Track[]) { /** * Returns true if the profile should be updated. * - * It assumes that if a status is using the `:headphones:` emoji and contains a + * It assumes that if a status is using the configured emoji and contains a * middle dot character (`•`) that the app has previously been used to update * the status and should continue to. * @@ -93,6 +93,6 @@ export function getNowPlaying (tracks: LastFM.Track[]) { */ export function shouldSetStatus (profile: Slack.Profile) { if (profile.status_emoji === '' && profile.status_text === '') return true - if (profile.status_emoji === ':headphones:' && profile.status_text.includes(' • ')) return true + if (profile.status_emoji === config.slack.emoji && profile.status_text.includes(' • ')) return true return false }