commit 2453a56ba639118fdf8eeb601d55cf1162e3fb1c
parent 7115fa0f1b7fdae4dc7b00c7c87d616fa32b7c30
Author: Demonstrandum <moi@knutsen.co>
Date: Sat, 28 Mar 2020 20:09:06 +0000
Conflicts and additions to HELP.
Diffstat:
6 files changed, 17 insertions(+), 197 deletions(-)
diff --git a/HELP.md b/HELP.md
@@ -62,12 +62,12 @@
- `!reject <ls>` — numerically lists all rejection rules.
- `!reject rm #[rule-index]` — removes the rejection-rule specified by a numerical index.
- `!replace` **〈not impl.〉** — Bots currently do not have the ability to edit other users messages. We can only wait.
-- `!cron` **〈not impl.〉** — Run commands repeatedly based on some timer (look-up cron syntax for more info):
+- `!cron` — Run commands repeatedly based on some timer (look-up cron syntax for more info):
- `!cron [minute] [hour] [day-of-month] [month] [day-of-week] ![command] <...>` — runs a command (with or without arguments) repeatedly as specified by the schedule signature.
- `!cron <ls>` — lists all active cron-jobs numerically.
- `!cron <clear>` — clears all executed cron-jobs.
- `!cron rm #[job-index]` — removes a cron-job by index.
-- `!choose [comma-separated-values]` **〈not impl.〉** — Choose randomly from a list of items, separated by commas.
+- `!choose [comma-separated-values]` — Choose randomly from a list of items, separated by commas.
- `!define [word]` — Looks a word up in the Oxford English Dictionary.
- `!urban [slang]` — Looks up a piece of slang in the _Urban Dictionary_.
- `!search [web-search-terms]` — Performs a web-search and returns the most appropriate URL found.
@@ -76,8 +76,8 @@
- `!cat` **〈not impl.〉** — Pussycat pictures...
- `!news [news-search-term]` **〈not impl.〉** — Sends you the most relevant news on the specified topic area.
- `!youtube [youtube-search-terms]` — Searches for and returns a relevant _YouTube_ video.
-- `!wikipedia` **〈not impl.〉** — Search through Wikipedia, returning the most relevant wiki-link.
-- `!translate <language> [phrase]` **〈not impl.〉** — Translate a phrase from a language (if none specified, it will auto-detect).
+- `!wikipedia` — Search through Wikipedia, returning the most relevant wiki-link.
+- `!translate <from-to> [phrase]` — Translate a phrase from one language to another (if none specified, it will translate from `en` (english) to the auto-detected language).
- `!wolfram` **〈not impl.〉** — Query Wolfram|Alpha.
- `!weather` — Check the weather:
- `!weather set [location]` — sets your weather location.
@@ -89,6 +89,8 @@
- `!figlet <options> [phrase]` — Print text in ASCII format, using Unix-like command-line arguments.
- `!roll <upper-bound>` — Roll a dice, default upper bound is 6.
- `!8ball` — Ask a question, receive a response.
+- `!coin` — Flip a coin.
+- `!flip` — GET ANGRY! FLIP SOMETHING OVER!
- `!summon [@user-name]` — Summon someone to the server by making the bot poke them in their DMs about it.
- `!mock [phrase]` — Say something, _bUt iN a MocKiNg WaY_...
- `!boomer [phrase]` — Say something, but in the way your demented boomer uncle would write it on Facebook.
diff --git a/lib/commands/flip.js b/lib/commands/flip.js
@@ -1,31 +0,0 @@
-"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/trans.ts b/lib/commands/trans.ts
@@ -1,15 +0,0 @@
-import fetch from 'node-fetch';
-const api_uri = 'https://translate.yandex.net/api/v1.5/tr.json/translate'
-const langs = ['ab', 'aa', 'af', 'ak', 'sq', 'am', 'ar', 'an', 'hy', 'as', 'av', 'ae', 'ay', 'az', 'bm', 'ba', 'eu', 'be', 'bn', 'bh', 'bi', 'bs', 'br', 'bg', 'my', 'ca', 'ch', 'ce', 'ny', 'zh', 'cv', 'kw', 'co', 'cr', 'hr', 'cs', 'da', 'dv', 'nl', 'dz', 'en', 'eo', 'et', 'ee', 'fo', 'fj', 'fi', 'fr', 'ff', 'gl', 'ka', 'de', 'el', 'gn', 'gu', 'ht', 'ha', 'he', 'hz', 'hi', 'ho', 'hu', 'ia', 'id', 'ie', 'ga', 'ig', 'ik', 'io', 'is', 'it', 'iu', 'ja', 'jv', 'kl', 'kn', 'kr', 'ks', 'kk', 'km', 'ki', 'rw', 'ky', 'kv', 'kg', 'ko', 'ku', 'kj', 'la', 'lb', 'lg', 'li', 'ln', 'lo', 'lt', 'lu', 'lv', 'gv', 'mk', 'mg', 'ms', 'ml', 'mt', 'mi', 'mr', 'mh', 'mn', 'na', 'nv', 'nb', 'nd', 'ne', 'ng', 'nn', 'no', 'ii', 'nr', 'oc', 'oj', 'cu', 'om', 'or', 'os', 'pa', 'pi', 'fa', 'pl', 'ps', 'pt', 'qu', 'rm', 'rn', 'ro', 'ru', 'sa', 'sc', 'sd', 'se', 'sm', 'sg', 'sr', 'gd', 'sn', 'si', 'sk', 'sl', 'so', 'st', 'az', 'es', 'su', 'sw', 'ss', 'sv', 'ta', 'te', 'tg', 'th', 'ti', 'bo', 'tk', 'tl', 'tn', 'to', 'tr', 'ts', 'tt', 'tw', 'ty', 'ug', 'uk', 'ur', 'uz', 've', 'vi', 'vo', 'wa', 'cy', 'wo', 'fy', 'xh', 'yi', 'yo', 'za', 'zu'];
-export default async (home_scope: HomeScope) => {
- const { message, args, SECRETS, CONFIG } = home_scope;
- if(args[0]){
- const to = langs.includes(args[0]) ? args.shift() : 'en', from = langs.includes(args[0]) ? '-' + args.shift() : '';
- 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/commands/translate.ts b/lib/commands/translate.ts
@@ -0,0 +1,9 @@
+import fetch from 'node-fetch';
+export default async (home_scope: HomeScope) => {
+ const { message, args, SECRETS, CONFIG } = home_scope, lang = String(args[0])[2] == '-' ? args.shift() : 'en'; // handle undefined
+ args[0] ? fetch(`https://translate.yandex.net/api/v1.5/tr.json/translate?key=${SECRETS.yandex.translate.key}&text=${encodeURIComponent(args.join(' '))}&lang=${lang}`).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])) : message.answer('.translate [from-to] words \n default: auto-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/default.ts b/lib/default.ts
@@ -50,7 +50,8 @@ const DEFAULT_GUILD_CONFIG : Types.Config = {
'git': 'github',
'bug': 'issue',
'source': 'github',
- 'save': 'export'
+ 'save': 'export',
+ 'trans': 'translate',
},
},
diff --git a/lib/resources/flips.js b/lib/resources/flips.js
@@ -1,146 +0,0 @@
-"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;