Skip to content

Commit 54b75a4

Browse files
committed
fix sed, update xs
1 parent f4a381a commit 54b75a4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

commands/eventsed-316c1254d18a.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"locked": false,
44
"starred": false,
55
"name": "event.sed",
6-
"command": "IRC.listen('message', (event) => {\n if (event.message.text.startsWith('s/')) {\n const rx = event.message.text.slice(2);\n\n // or use this regex\n // s\\/(.*?)(?<!\\\\)\\/(.*?)(?<!\\\\)(\\/.+)?$\n const chunks = rx.split('/').reduce((acc, chunk, i) => {\n if (([]+acc.slice(-1)).slice(-1) === '\\\\') {\n acc[acc.length-1] += '\\/' + chunk\n } else {\n acc.push(chunk);\n }\n return acc;\n }, []);\n\n const [search, replace, flags] = chunks;\n const [item] = IRC.log.regex('^(?!s\\\\/).+?' + search, 1, 0);\n if (item) {\n const { user, message } = item;\n const replacement = `${IRC.colors.nick(IRC.breakHighlight(user), true)} ${message.replace(new RegExp(search), replace)}`;\n print(replacement);\n }\n }\n});"
6+
"command": "IRC.listen('message', (event) => {\n if (event.message.text.startsWith('s/')) {\n const rx = event.message.text.slice(2);\n\n // or use this regex\n // s\\/(.*?)(?<!\\\\)\\/(.*?)(?<!\\\\)(\\/.+)?$\n const chunks = rx.split('/').reduce((acc, chunk) => {\n if (([]+acc.slice(-1)).slice(-1) === '\\\\') {\n acc[acc.length-1] += '\\/' + chunk\n } else {\n acc.push(chunk);\n }\n return acc;\n }, []);\n\n const [search, replace, flags] = chunks;\n const [item] = IRC.log.regex('^(?!s\\\\/).*?' + search, 1, 0);\n if (item) {\n const { user, message } = item;\n const replacement = `${IRC.colors.nick(IRC.breakHighlight(user), true)} ${message.replace(new RegExp(search), replace)}`;\n print(replacement);\n }\n }\n});"
77
}

commands/xe-8185e1aa7a5c.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xe",
3-
"command": "const sp = input.split` `;\nif (sp.length < 3) {\n print(`usage: {r}${IRC.trigger}xe AMOUNT FROM TO (eg 1 GBP EUR)`);\n}\nelse {\n const sp_sorted = ((x) => !isNaN(x[0]) ? x : [x[1], x[0], x[2]]) (sp)\n const amount = sp_sorted[0].trim();\n const from = sp_sorted[1].toUpperCase().trim();\n const to = sp_sorted[2].toUpperCase().trim();\n \n getJSON('http://data.fixer.io/api/latest?access_key=920bb4012de7e6878170750c6098e484')\n .then(obj => {\n const value = (obj.rates[to]/obj.rates[from])*amount;\n if (value !== value) {\n print(`usage: {r}${IRC.trigger}xe AMOUNT FROM TO (eg 1 GBP EUR)`);\n } else {\n print(`${value.toFixed(2)}`)\n }\n })\n .catch(print.error)\n \n // legacy\n // const url = `http://www.xe.com/currencyconverter/convert/?Amount=${sp[0]}&From=${sp[1]}&To=${sp[2]}`;\n // getDOM(url)\n // .then(dom => {\n // print('xe.com changed their website so it\\'s down until I figure out how to pirate currency exchange again')\n // print(dom.qs('.converterresult-toAmount').textContent)\n // })\n // .catch(print.error)\n}",
3+
"command": "const sp = input.split` `;\nif (sp.length < 3) {\n \tthrow `usage: {r}${IRC.colors.cmd('xe', ['from', 'to', 'amount'])} (in any order)`;\n}\nelse {\n const sp_sorted = ((x) => !isNaN(x[0]) ? x : !isNaN(x[1]) ? [x[1], x[0], x[2]] : [x[2], x[0], x[1]]) (sp)\n const amount = sp_sorted[0].trim();\n const from = sp_sorted[1].toUpperCase().trim();\n const to = sp_sorted[2].toUpperCase().trim();\n \n getJSON('http://data.fixer.io/api/latest?access_key=920bb4012de7e6878170750c6098e484')\n .then(obj => {\n const value = (obj.rates[to]/obj.rates[from])*amount;\n if (value !== value) {\n print(`usage: {r}${IRC.trigger}xe AMOUNT FROM TO (eg 1 GBP EUR)`);\n } else {\n print(`${value.toFixed(2)}`)\n }\n })\n .catch(print.error)\n \n // legacy\n // const url = `http://www.xe.com/currencyconverter/convert/?Amount=${sp[0]}&From=${sp[1]}&To=${sp[2]}`;\n // getDOM(url)\n // .then(dom => {\n // print('xe.com changed their website so it\\'s down until I figure out how to pirate currency exchange again')\n // print(dom.qs('.converterresult-toAmount').textContent)\n // })\n // .catch(print.error)\n}",
44
"locked": false,
55
"starred": false
66
}

0 commit comments

Comments
 (0)