diff --git a/corona_stats/packages/corona_stats/corona_stats.js b/corona_stats/packages/corona_stats/corona_stats.js index 390ee15c..6180b255 100644 --- a/corona_stats/packages/corona_stats/corona_stats.js +++ b/corona_stats/packages/corona_stats/corona_stats.js @@ -17,39 +17,38 @@ let inStatesData; let inDistrictData; const mui = (element, client) => { - if (client === 'slack') { - return element; - } - - const output = []; - switch (element.type) { - case 'context': { - for (const item of element.elements) { - output.push(item.text.replace(/\*/g, '**')); + if (client === 'mattermost') { + const output = []; + switch (element.type) { + case 'context': { + for (const item of element.elements) { + output.push(item.text.replace(/\*/g, '**')); + } + break; } - break; - } - case 'section': { - if (element.fields && element.fields.length > 0) { - for (const field of element.fields) { - output.push(field.text.replace(/\*/g, '**') + '\n'); + case 'section': { + if (element.fields && element.fields.length > 0) { + for (const field of element.fields) { + output.push(field.text.replace(/\*/g, '**') + '\n'); + } + } else if (element.text) { + output.push('#### ' + element.text.text.replace(/\*/g, '**')); } - } else if (element.text) { - output.push('#### ' + element.text.text.replace(/\*/g, '**')); + break; + } + case 'mrkdwn': { + output.push('#### ' + element.text.replace(/\*/g, '**')); + break; + } + case 'divider': { + output.push('***'); + break; } - break; - } - case 'mrkdwn': { - output.push('#### ' + element.text.replace(/\*/g, '**')); - break; - } - case 'divider': { - output.push('***'); - break; } - } - return output.join(' '); + return output.join(' '); + } + return element; }; const toTitleCase = (phrase) => phrase @@ -289,7 +288,7 @@ const success = (header, fields, footer, client) => { type: 'context', elements: [{ type: 'mrkdwn', - text: `add _corona_stats_ to your ${toTitleCase(client)} with <${client==='slack'?'https://nimbella.com/blog/get-live-coronavirus-stats-in-slack-with-nimbella-commander/':'https://github.com/nimbella/command-sets'}|Commander>.`, + text: `add _corona_stats_ to your ${client} with <${client === 'slack' ? 'https://nimbella.com/blog/get-live-coronavirus-stats-in-slack-with-nimbella-commander/' : 'https://github.com/nimbella/command-sets'}|Commander>.`, }], } if (footer) { @@ -369,7 +368,7 @@ const help = (client) => { type: 'context', elements: [{ type: 'mrkdwn', - text: 'add _corona_stats_ to your Slack with | data sources: , ', + text: `add _corona_stats_ to your ${client} with <${client === 'slack' ? 'https://nimbella.com/blog/get-live-coronavirus-stats-in-slack-with-nimbella-commander/' : 'https://github.com/nimbella/command-sets'}|Commander> \n data sources: , `, }], }, client)); @@ -524,10 +523,10 @@ async function _command(params) { } if (country) { if (country === 'USA') { - footer = '\nto see stats for a state, type `corona_stats us -r ` e.g. `/nc corona_stats us -r ny`'; + footer = '\n to see stats for a state, type `corona_stats us -r ` e.g. `/nc corona_stats us -r ny`'; } if (country === 'India') { - footer = '\nto see stats for a state, type `corona_stats in -r ` e.g. `/nc corona_stats in -r up`'; + footer = '\n to see stats for a state, type `corona_stats in -r ` e.g. `/nc corona_stats in -r up`'; } header = `CoronaVirus 😷 Stats in ${country} ${getFlag(country)} :`; fields = getDetails(country, countryHtml);