Simp-O-Matic

Dumb Discord bot in TS.
git clone git://git.knutsen.co/Simp-O-Matic
Log | Files | Refs | README | LICENSE

commit 7115fa0f1b7fdae4dc7b00c7c87d616fa32b7c30
parent 855e01a68be8222149bf5305d7e92cb5f82363d6
Author: Demonstrandum <moi@knutsen.co>
Date:   Sat, 28 Mar 2020 20:02:06 +0000

bouta flip.

Diffstat:
Clib/commands/flip.ts -> lib/commands/coin.ts | 0
Alib/commands/flip.js | 31+++++++++++++++++++++++++++++++
Mlib/commands/flip.ts | 12++++++++++--
Mlib/commands/trans.ts | 6+++++-
Alib/resources/flips.js | 146+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alib/resources/flips.ts | 136+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 328 insertions(+), 3 deletions(-)

diff --git a/lib/commands/flip.ts b/lib/commands/coin.ts diff --git a/lib/commands/flip.js b/lib/commands/flip.js @@ -0,0 +1,31 @@ +"use strict"; +// (╯°□°)╯︵ ┻━┻ +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +exports.__esModule = true; +var flips_1 = require("../resources/flips"); +var flip = function (c) { return flips_1["default"][c] || c; }; +// export default (home_scope: HomeScope) => { +// const { message, args } = home_scope; +// message.channel.send([...args.join(' ')].map(flip).join('')); +// }; +var args = ['Hello', 'World']; +console.log(__spread(args.join(' ')).map(flip).reverse().join('')); diff --git a/lib/commands/flip.ts b/lib/commands/flip.ts @@ -1,4 +1,12 @@ +// (╯°□°)╯︵ ┻━┻ + +import FLIPS from '../resources/flips'; + +const flip = c => FLIPS[c] || c; + export default (home_scope: HomeScope) => { - const { message } = home_scope; - message.answer(Math.random() < 0.5 ? 'Heads!' : 'Tails!'); + const { message, args } = home_scope; + message.channel.send('(╯°□°)╯︵ ' + + [...args.join(' ')].map(flip).reverse().join('')); }; + diff --git a/lib/commands/trans.ts b/lib/commands/trans.ts @@ -8,4 +8,8 @@ export default async (home_scope: HomeScope) => { fetch(`${api_uri}?key=${SECRETS.yandex.translate.key}&text=${args.join(' ')}&lang=` + from + to).catch(console.log).then((res: any) => res.json()).then(tr => message.channel.send([,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,false,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,'api key missing,blocked api key',,'limit reached',,,,,,,,,'text too long (shouldnt happen)',,,,,,,,,'untranslatable.',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,'unsupported'][tr.code] || tr.text[0])) } else message.answer('.trans [lang to [lang from]] words \n defaults: autodetect en'); -} +}; + +// P.S. If you're reading this code, and wondering why +// it looks like that; it's because Danny wrote it. +// Danny is on drugs. diff --git a/lib/resources/flips.js b/lib/resources/flips.js @@ -0,0 +1,146 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +exports.__esModule = true; +var UP_TO_DOWN = { + "a": "\u0250", + "b": "q", + "c": "\u0254", + "d": "p", + "e": "\u01DD", + "f": "\u025F", + "g": "\u0183", + "h": "\u0265", + "i": "\u1D09", + "j": "\u027E", + "k": "\u029E", + "l": "\u05DF", + "m": "\u026F", + "n": "u", + "r": "\u0279", + "t": "\u0287", + "v": "\u028C", + "w": "\u028D", + "y": "\u028E", + "A": "\u2200", + "C": "\u0186", + "E": "\u018E", + "F": "\u2132", + "G": "\u05E4", + "H": "H", + "I": "I", + "J": "\u017F", + "L": "\u02E5", + "M": "W", + "N": "N", + "P": "\u0500", + "T": "\u2534", + "U": "\u2229", + "V": "\u039B", + "Y": "\u2144", + "1": "\u0196", + "2": "\u1105", + "3": "\u0190", + "4": "\u3123", + "5": "\u03DB", + "6": "9", + "7": "\u3125", + "8": "8", + "9": "6", + "0": "0", + ".": "\u02D9", + ",": "'", + "'": ",", + '"': "„", + "`": ",", + "?": "\u00BF", + "!": "\u00A1", + "[": "]", + "]": "[", + "(": ")", + ")": "(", + "{": "}", + "}": "{", + "<": ">", + ">": "<", + "&": "\u214B", + "_": "\u203E", + "\u2234": "\u2235", + "\u2045": "\u2046" +}; +var DOWN_TO_UP = { + "\u0250": "a", + "q": "b", + "\u0254": "c", + "p": "d", + "\u01DD": "e", + "\u025F": "f", + "\u0183": "g", + "\u0265": "h", + "\u1D09": "i", + "\u027E": "j", + "\u029E": "k", + "\u05DF": "l", + "\u026F": "m", + "u": "n", + "\u0279": "r", + "\u0287": "t", + "\u028C": "v", + "\u028D": "w", + "\u028E": "y", + "\u2200": "A", + "\u0186": "C", + "\u018E": "E", + "\u2132": "F", + "\u05E4": "G", + "H": "H", + "I": "I", + "\u017F": "J", + "\u02E5": "L", + "W": "M", + "N": "N", + "\u0500": "P", + "\u2534": "T", + "\u2229": "U", + "\u039B": "V", + "\u2144": "Y", + "\u0196": "1", + "\u1105": "2", + "\u0190": "3", + "\u3123": "4", + "\u03DB": "5", + "9": "6", + "\u3125": "7", + "8": "8", + "6": "9", + "0": "0", + "\u02D9": ".", + "'": ",", + ",": "'", + "„": '"', + "\u00BF": "?", + "\u00A1": "!", + "]": "[", + "[": "]", + ")": "(", + "(": ")", + "}": "{", + "{": "}", + ">": "<", + "<": ">", + "\u214B": "&", + "\u203E": "_", + "\u2235": "\u2234", + "\u2046": "\u2045" +}; +var FLIPS = __assign(__assign({}, DOWN_TO_UP), UP_TO_DOWN); +exports["default"] = FLIPS; diff --git a/lib/resources/flips.ts b/lib/resources/flips.ts @@ -0,0 +1,136 @@ +const UP_TO_DOWN = { + "a": "\u0250", + "b": "q", + "c": "\u0254", + "d": "p", + "e": "\u01DD", + "f": "\u025F", + "g": "\u0183", + "h": "\u0265", + "i": "\u1D09", + "j": "\u027E", + "k": "\u029E", + "l": "\u05DF", + "m": "\u026F", + "n": "u", + "r": "\u0279", + "t": "\u0287", + "v": "\u028C", + "w": "\u028D", + "y": "\u028E", + "A": "\u2200", + "C": "\u0186", + "E": "\u018E", + "F": "\u2132", + "G": "\u05E4", + "H": "H", + "I": "I", + "J": "\u017F", + "L": "\u02E5", + "M": "W", + "N": "N", + "P": "\u0500", + "T": "\u2534", + "U": "\u2229", + "V": "\u039B", + "Y": "\u2144", + "1": "\u0196", + "2": "\u1105", + "3": "\u0190", + "4": "\u3123", + "5": "\u03DB", + "6": "9", + "7": "\u3125", + "8": "8", + "9": "6", + "0": "0", + ".": "\u02D9", + ",": "'", + "'": ",", + '"': "„", + "`": ",", + "?": "\u00BF", + "!": "\u00A1", + "[": "]", + "]": "[", + "(": ")", + ")": "(", + "{": "}", + "}": "{", + "<": ">", + ">": "<", + "&": "\u214B", + "_": "\u203E", + "\u2234": "\u2235", + "\u2045": "\u2046" +}; + +const DOWN_TO_UP = { + "\u0250": "a", + "q": "b", + "\u0254": "c", + "p": "d", + "\u01DD": "e", + "\u025F": "f", + "\u0183": "g", + "\u0265": "h", + "\u1D09": "i", + "\u027E": "j", + "\u029E": "k", + "\u05DF": "l", + "\u026F": "m", + "u": "n", + "\u0279": "r", + "\u0287": "t", + "\u028C": "v", + "\u028D": "w", + "\u028E": "y", + "\u2200": "A", + "\u0186": "C", + "\u018E": "E", + "\u2132": "F", + "\u05E4": "G", + "H": "H", + "I": "I", + "\u017F": "J", + "\u02E5": "L", + "W": "M", + "N": "N", + "\u0500": "P", + "\u2534": "T", + "\u2229": "U", + "\u039B": "V", + "\u2144": "Y", + "\u0196": "1", + "\u1105": "2", + "\u0190": "3", + "\u3123": "4", + "\u03DB": "5", + "9": "6", + "\u3125": "7", + "8": "8", + "6": "9", + "0": "0", + "\u02D9": ".", + "'": ",", + ",": "'", + "„": '"', + "\u00BF": "?", + "\u00A1": "!", + "]": "[", + "[": "]", + ")": "(", + "(": ")", + "}": "{", + "{": "}", + ">": "<", + "<": ">", + "\u214B": "&", + "\u203E": "_", + "\u2235": "\u2234", + "\u2046": "\u2045" +}; + +const FLIPS = { ...DOWN_TO_UP, ...UP_TO_DOWN }; + +export default FLIPS;