Skip to content

Commit d0f78a2

Browse files
committed
improve fliptext, add more unit conversions
1 parent e18ac98 commit d0f78a2

9 files changed

+15
-8
lines changed

commands/eventconvertUnits-de650149a73c.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"locked": false,
44
"starred": false,
55
"name": "event.convertUnits",
6-
"command": "const miles = /\\b(\\d+\\.?\\d*|\\.\\d+) ?mi(les)?\\b/;\nconst feet = /\\b(\\d+\\.?\\d*|\\.\\d+) ?(feet|ft)\\b/;\nconst inch = /\\b(\\d+\\.?\\d*|\\.\\d+) ?inch(es)?\\b/;\nconst yards = /\\b(\\d+\\.?\\d*|\\.\\d+) ?(yards|yd)\\b/;\n\nconst km = /\\b(\\d+\\.?\\d*|\\.\\d+) ?(kilomet(re|er)s|km)\\b/;\nconst cm = /\\b(\\d+\\.?\\d*|\\.\\d+) ?(centimet(re|er)s|cm)\\b/;\nconst { wordsToNumbers } = require('words-to-numbers');\n\nIRC.listen('message', (event) => {\n let { text } = event.message;\n text = wordsToNumbers(text);\n if (miles.test(text)) {\n const value = text.match(miles)[1];\n print(`${+(+value * 1.60934).toFixed(2)}km`);\n } else if (feet.test(text)) {\n const value = text.match(feet)[1];\n print(`${+(+value * 0.3048).toFixed(2)}m`);\n } else if (yards.test(text)) {\n const value = text.match(yards)[1];\n print(`${+(+value * 0.9144).toFixed(2)}m`);\n } else if (km.test(text)) {\n const value = text.match(km)[1];\n print(`${+(+value * 0.621371).toFixed(2)} miles`);\n } else if (cm.test(text)) {\n const value = text.match(cm)[1];\n print(`${+(+value * 0.393701).toFixed(2)} inches`);\n } else if (inch.test(text)) {\n const value = text.match(inch)[1];\n print(`${+(+value * 2.54).toFixed(2)}cm`);\n }\n});"
6+
"command": "const miles = /\\b(\\d+\\.?\\d*|\\.\\d+) ?mi(les)?\\b/;\nconst feet = /\\b(\\d+\\.?\\d*|\\.\\d+) ?(feet|ft)\\b/;\nconst inch = /\\b(\\d+\\.?\\d*|\\.\\d+) ?(inch(es)?)\\b/;\nconst yards = /\\b(\\d+\\.?\\d*|\\.\\d+) ?(yards|yd)\\b/;\n\nconst km = /\\b(\\d+\\.?\\d*|\\.\\d+) ?(kilomet(re|er)s?|km)\\b/;\nconst cm = /\\b(\\d+\\.?\\d*|\\.\\d+) ?(centimet(re|er)s?|cm)\\b/;\nconst m = /\\b(\\d+\\.?\\d*|\\.\\d+) ?(met(re|er)s?|m)\\b/;\nconst f = /((\\b|-?)\\d+\\.?\\d*|(\\b|-?)\\.\\d+) ?(degrees ?|° ?)?(fah?renheit|F|f)\\b/;\nconst c = /((\\b|-?)\\d+\\.?\\d*|(\\b|-?)\\.\\d+) ?(degrees ?|° ?)?(cel(s|c)ius|C|c)\\b/;\nconst { wordsToNumbers } = require('words-to-numbers');\n\nIRC.listen('message', (event) => {\n let { text } = event.message;\n text = wordsToNumbers(text);\n if (miles.test(text)) {\n const value = text.match(miles)[1];\n print(`${+(+value * 1.60934).toFixed(2)}km`);\n } else if (feet.test(text)) {\n const value = text.match(feet)[1];\n print(`${+(+value * 0.3048).toFixed(2)}m`);\n } else if (yards.test(text)) {\n const value = text.match(yards)[1];\n print(`${+(+value * 0.9144).toFixed(2)}m`);\n } else if (km.test(text)) {\n const value = text.match(km)[1];\n print(`${+(+value * 0.621371).toFixed(2)} miles`);\n } else if (cm.test(text)) {\n const value = text.match(cm)[1];\n print(`${+(+value * 0.393701).toFixed(2)} inches`);\n } else if (m.test(text)) {\n const value = text.match(m)[1];\n print(`${+(+value * 3.28084).toFixed(2)} feet`);\n } else if (inch.test(text)) {\n const value = text.match(inch)[1];\n print(`${+(+value * 2.54).toFixed(2)}cm`);\n } else if (f.test(text)) {\n const value = text.match(f)[1];\n print(`${+((+value-32) * 5 / 9).toFixed(2)}°C`);\n } else if (c.test(text)) {\n const value = text.match(c)[1];\n print(`${+((+value * 9 / 5) + 32).toFixed(2)}°F`);\n }\n});"
77
}

commands/eventemoji-75d30b290a33.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"locked": false,
44
"starred": false,
55
"name": "event.emoji",
6-
"command": "const { nameToEmoji } = require('gemoji');\nconst { compareTwoStrings } = require('string-similarity');\nconst names = Object.keys(nameToEmoji);\n\nconst getEmoji = str => {\n \tif (str === 'penis') return '𓂸';\n const list = names.map(d => [compareTwoStrings(d, str), d]).sort((a, b) => b[0] - a[0]);\n return nameToEmoji[list.shift().pop()];\n};\n\nIRC.listen('message', ({ message: { from, text } }) => {\n \tif (/(?<!\\d):([\\w-]+?):/.test(text)) {\n \t//print('🤔'); \n const result = text.toLowerCase().match(/:(\\S*?):/g)\n if (result) {\n const out = result.map(d => getEmoji(d.slice(1,-1)));\n print(out.join(''));\n }\n }\n});"
6+
"command": "const { nameToEmoji } = require('gemoji');\nconst { compareTwoStrings } = require('string-similarity');\nconst names = Object.keys(nameToEmoji);\n\nconst getEmoji = str => {\n const list = names.map(d => [compareTwoStrings(d, str), d]).sort((a, b) => b[0] - a[0]);\n return nameToEmoji[list.shift().pop()];\n};\n\nIRC.listen('message', ({ message: { from, text } }) => {\n \tif (/(?<!\\d):([\\w-]+?):/.test(text)) {\n \t//print('🤔'); \n const result = text.toLowerCase().match(/:(\\S*?):/g)\n if (result) {\n const out = result.map(d => getEmoji(d.slice(1,-1)));\n print(out.join(''));\n }\n }\n});"
77
}

commands/eventmorse-4f8766b2bbef.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"locked": false,
44
"starred": false,
55
"name": "event.morse",
6-
"command": "const lookup = {\"-----\":\"0\",\".----\":\"1\",\"..---\":\"2\",\"...--\":\"3\",\"....-\":\"4\",\".....\":\"5\",\"-....\":\"6\",\"--...\":\"7\",\"---..\":\"8\",\"----.\":\"9\",\".-\":\"a\",\"-...\":\"b\",\"-.-.\":\"c\",\"-..\":\"d\",\".\":\"e\",\"..-.\":\"f\",\"--.\":\"g\",\"....\":\"h\",\"..\":\"i\",\".---\":\"j\",\"-.-\":\"k\",\".-..\":\"l\",\"--\":\"m\",\"-.\":\"n\",\"---\":\"o\",\".--.\":\"p\",\"--.-\":\"q\",\".-.\":\"r\",\"...\":\"s\",\"-\":\"t\",\"..-\":\"u\",\"...-\":\"v\",\".--\":\"w\",\"-..-\":\"x\",\"-.--\":\"y\",\"--..\":\"z\",\"morse_space\":\" \"};\n\nIRC.listen('message', (event) => {\n const morseChars = event.message.text.replace(/ /g, ' morse_space ').split(' ').filter(text => lookup[text]);\n if (morseChars.length > 2) {\n const text = morseChars.map(text => lookup[text]).join('');\n /\\S/.test(text) && print(text);\n }\n});\n"
6+
"command": "const lookup = {\"-----\":\"0\",\".----\":\"1\",\"..---\":\"2\",\"...--\":\"3\",\"....-\":\"4\",\".....\":\"5\",\"-....\":\"6\",\"--...\":\"7\",\"---..\":\"8\",\"----.\":\"9\",\".-\":\"a\",\"-...\":\"b\",\"-.-.\":\"c\",\"-..\":\"d\",\".\":\"e\",\"..-.\":\"f\",\"--.\":\"g\",\"....\":\"h\",\"..\":\"i\",\".---\":\"j\",\"-.-\":\"k\",\".-..\":\"l\",\"--\":\"m\",\"-.\":\"n\",\"---\":\"o\",\".--.\":\"p\",\"--.-\":\"q\",\".-.\":\"r\",\"...\":\"s\",\"-\":\"t\",\"..-\":\"u\",\"...-\":\"v\",\".--\":\"w\",\"-..-\":\"x\",\"-.--\":\"y\",\"--..\":\"z\",\"morse_space\":\" \"};\n\nIRC.listen('message', (event) => {\n const morseChars = event.message.text.replace(/ /g, ' morse_space ').split(' ').filter(text => lookup[text]);\n const text = morseChars.map(text => lookup[text]).join('');\n const nonSpace = text.replace(/\\s/g,'');\n if (\n nonSpace.length > 1\n && !/^[eti]+$/.test(nonSpace)\n && !/^[5ihse]+$/.test(nonSpace)\n ) {\n print(text);\n }\n});"
77
}

commands/fliptext-8be791336736.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fliptext",
3-
"command": "const lookup = {\n '^': 'ᵥ',\n '∀': 'A',\n B: 'ꓭ',\n Ɔ: 'C',\n D: 'ꓷ',\n Ǝ: 'E',\n Ⅎ: 'F',\n פ: 'G',\n H: 'H',\n I: 'I',\n ſ: 'J',\n ʞ: 'K',\n '˥': 'L',\n W: 'M',\n N: 'N',\n O: 'O',\n Ԁ: 'P',\n Q: 'Ὸ',\n R: 'ꓤ',\n S: 'S',\n '┴': 'T',\n '∩': 'U',\n Λ: 'V',\n M: 'W',\n X: 'X',\n '⅄': 'Y',\n Z: 'Z',\n a: '\\u0250',\n b: 'q',\n c: '\\u0254',\n d: 'p',\n e: '\\u01dd',\n f: '\\u025f',\n g: 'ƃ',\n h: '\\u0265',\n i: '\\u0131',\n j: 'ɾ',\n k: 'ʞ',\n l: 'ן',\n m: '\\u026f',\n n: 'u',\n o: 'o',\n p: 'd',\n q: 'b',\n r: '\\u0279',\n s: 's',\n t: '\\u0287',\n u: 'n',\n v: 'ʌ',\n w: '\\u028d',\n x: 'x',\n y: '\\u028e',\n z: 'z',\n '0': '0',\n Ɩ: '1',\n ᄅ: '2',\n Ɛ: '3',\n ㄣ: '4',\n ϛ: '5',\n '9': '6',\n ㄥ: '7',\n '8': '8',\n '6': '9',\n '¿': '?',\n '¡': '!',\n '[': ']',\n '(': ')',\n '{': '}',\n \"'\": ',',\n '.': '˙',\n '<': '>',\n '♥': '♠',\n '#': '♯',\n};\n\nObject.entries(lookup).forEach(([k, v]) => { lookup[v] = k; });\n\nmodule.exports = text => [...text].reverse().map(d => lookup[d] || d).join('');\n\nif (!module.required) print(module.exports(input));",
3+
"command": "const lookup = \"Ɩ1ᄅ2Ɛ3ㄣ4ϛ5ㄥ769∀ABꓭƆCDꓷƎEℲFפGſJʞK˥LWMԀPQῸRꓤ⊥T∩UΛV⅄Yaɐbqcɔdpeǝfɟgƃhɥiᴉjɾkʞlןmɯnupdqbrɹtʇunvʌwʍyʎ¿?¡![](){}<>',.˙^ᵥ&⅋_‾♥♠#♯А∀БܦВꓭГ⅃ДჩЕƎЗƐЙИ̯КꓘЛѴМꟽПⵡРԀСϽТꓕУʎЦʼnЧႹШᗰЬᑫЭЄЮꙔЯᖉ\";\nconst flip =s=>lookup[lookup.indexOf(s)^1]||s;\n\nmodule.exports = text => [...text].reverse().map(flip).join('');\n\nif (!module.required) print(module.exports(input));",
44
"locked": true,
55
"starred": false
66
}

commands/log-7b1ebf618a31.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "log",
3-
"command": "function renderLogs(list) {\n return list.map(\n ({ time, user, command, target, message }) =>\n IRC.colors(\n `({dc}{u}${time}{/}) {bo}<{/}${IRC.colors.hash(\n user,\n )}${IRC.breakHighlight(user)}${\n command == 'PRIVMSG' ? '' : ':' + command.toLowerCase()\n }{/}{bo}>{/}`,\n ) +\n '\\u2800' +\n `${message.replace(/\\n/g, ' ')}`,\n );\n}\n\nfunction printLogs(list) {\n renderLogs(list).forEach((d) => print.raw(d, { log: false }));\n}\n\nlog(module.required);\nlog(module.exports);\n\nif (module.required) {\n module.exports = {\n renderLogs,\n printLogs,\n };\nlog(module.exports);\n return;\n}\n\nprintLogs(\n IRC.log.get(input, IRC.command.params[0] || 3, IRC.command.params[1] || 0),\n);",
3+
"command": "function renderLogs(list) {\n return list.map(\n ({ time, user, command, target, message }) =>\n IRC.colors(\n `({dc}{u}${time}{/}) {bo}<{/}${IRC.colors.hash(\n user,\n )}${IRC.breakHighlight(user)}${\n command == 'PRIVMSG' ? '' : ':' + command.toLowerCase()\n }{/}{bo}>{/}`,\n ) +\n '\\u2800' +\n `${message.replace(/\\n/g, ' ')}`,\n );\n}\n\nfunction printLogs(list) {\n renderLogs(list).forEach((d) => print.raw(d, { log: false }));\n}\n\nif (module.required) {\n module.exports = {\n renderLogs,\n printLogs,\n };\n return;\n}\n\nprintLogs(\n IRC.log.get(input, IRC.command.params[0] || 3, IRC.command.params[1] || 0),\n);",
44
"locked": true,
55
"starred": true
66
}

commands/logpaste-02823e614dd0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"locked": false,
44
"starred": false,
55
"name": "log.paste",
6-
"command": "const paste = IRC.require('module.paste');\nconst { renderLogs } = IRC.require('log');\n\nconst data = IRC.log.get(input, IRC.command.params[0] || 3, IRC.command.params[1] || 0);\n\npaste(renderLogs(data));"
6+
"command": "const paste = IRC.require('module.paste');\nconst { renderLogs } = IRC.require('log');\nconst { link, strip } = IRC.colors;\n\nconst data = IRC.log.get(input, IRC.command.params[0] || 3, IRC.command.params[1] || 0);\n\nprint(link(paste(strip(renderLogs(data).join`\\n`))));"
77
}

commands/mention-c802e85da26c.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"event": false,
3+
"locked": false,
4+
"starred": false,
5+
"name": "mention",
6+
"command": "print(`${IRC.message.from}: ping`)"
7+
}

commands/pi-b1a37c025018.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"locked": false,
44
"starred": false,
55
"name": "pi",
6-
"command": "let ndigits = 100;\nlet start = 0;\n\nconst params = input.match(/\\b(\\d+)\\b/g);\nif (params != null) {\n ndigits = Math.min(params[0], 400);\n start = Math.min(params[1] === undefined ? 0 : params[1], 100000000000000);\n}\nconst out = fetchSync.json('https://api.pi.delivery/v1/pi?numberOfDigits=' + ndigits + '&start=' + start);\n\nif (out.content)\n print(out.content);\nelse\n throw 'google pulled the plug probably?';\n"
6+
"command": "let offset = 0;\nlet length = 100;\n\nconst params = input.match(/\\b(\\d+)\\b/g);\nif (params != null) {\n offset = Math.min(params[0], 100000000000000)\n if (params[1] !== undefined)\n length = Math.min(params[1] === undefined ? 0 : params[1], 400)\n}\nif (length < 1)\n throw 'nonsense length'\n\nconst out = fetchSync.json('https://api.pi.delivery/v1/pi?numberOfDigits=' + length + '&start=' + offset);\n\nif (out.content)\n print(out.content);\nelse\n throw 'google pulled the plug probably?';\n"
77
}

commands/stupido-7bd5226f14f0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stupido",
3-
"command": "print.raw(\"http://i.imgur.com/xvBF3aK.jpg\");",
3+
"command": "print.raw(\"https://i.imgur.com/xvBF3aK.jpg\");",
44
"locked": false,
55
"starred": false
66
}

0 commit comments

Comments
 (0)