Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Parsers/Currency Converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ var amount = match ? match[1] : "";
var fromCurrency = match ? match[2] : "";
var toCurrency = match ? match[3] : "";

// Build the search URL using the Currency Converter API
var baseUrl = 'https://api.exchangeratesapi.io/latest';
var searchUrl = baseUrl + '?base=' + fromCurrency;
// Build the search URL using the Frankfurter API (free, no API key required)
var baseUrl = 'https://api.frankfurter.app/latest';
var searchUrl = baseUrl + '?from=' + fromCurrency + '&to=' + toCurrency;

// Make the API request
var chatReq = new sn_ws.RESTMessageV2();
Expand All @@ -29,8 +29,8 @@ var responseData = JSON.parse(chatResponseBody);
// Check if the API response contains exchange rates
if (responseData.rates && responseData.rates[toCurrency]) {
var exchangeRate = responseData.rates[toCurrency];
var convertedAmount = amount * exchangeRate;

var convertedAmount = (amount * exchangeRate).toFixed(2);
// Send a formatted message to Slack
new x_snc_slackerbot.Slacker().send_chat(current, `${amount} ${fromCurrency} is equal to ${convertedAmount.toFixed(2)} ${toCurrency}`, false);
} else {
Expand Down
20 changes: 20 additions & 0 deletions Parsers/Docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Parser Name: Docs
// Listens for: !docs <search term>
// What it does: Returns a link to ServiceNow documentation using the current URL format

var text = current.text + '';
var docsMatch = text.match(/!docs\s+(.*)/i);

if (docsMatch) {
var searchTerm = docsMatch[1].trim();
var encodedTerm = encodeURIComponent(searchTerm);
var docsUrl = 'https://www.servicenow.com/docs/csh?version=latest&topicname=' + encodedTerm;
var searchUrl = 'https://www.servicenow.com/docs/?q=' + encodedTerm;

new x_snc_slackerbot.Slacker().send_chat(current,
'*ServiceNow Docs: ' + searchTerm + '*\n' +
':book: Search results: ' + searchUrl + '\n' +
':link: Direct topic link: ' + docsUrl
);
}

Loading