commit 8e16e8d45ec0c2f8c32726217b287591accbf767
parent 70a1f0ea2c85d220c13d123d9bd0b2d37b1b37e8
Author: Demonstrandum <moi@knutsen.co>
Date: Fri, 18 Sep 2020 16:49:53 +0100
Upgrade to node 14.x and escape location name for geocoder request.
Diffstat:
4 files changed, 9 insertions(+), 28 deletions(-)
diff --git a/README.md b/README.md
@@ -12,7 +12,7 @@ requests our way.
Yours, [Sammy](https://github.com/Demonstrandum), [Danny](https://github.com/danyisill), [Accelarion](https://github.com/Accelarion), [Bruno](https://github.com/0-l) and [jack-javana (Pinocchio Tortoise)](https://github.com/jack-javana).
-## Why is it objectively superior
+## Why it is objectively superior
Let's compare it to a similar discord bot, [moiph/ub3r-b0t](https://github.com/moiph/ub3r-b0t)
diff --git a/lib/commands/code.purs b/lib/commands/code.purs
@@ -1,19 +0,0 @@
-module Code where
-
-import Prelude
-import Effect.Console (log)
-
-import Node.Encoding (Encoding(UTF8))
-import Node.FS.Sync (readTextFile)
-
-import Data.Function.Uncurried (Fn2)
-import Foreign.Object
-
-
-module ../utils where
- foreign import glue_strings :: Fn2 [String] Number [String]
-
-module ../extensions where
- foreign import FORMATS :: Object
-
-
diff --git a/lib/commands/code.ts b/lib/commands/code.ts
@@ -15,14 +15,14 @@ const file_authors = async (filename: string): Promise<Authors> => {
const repo = await git.Repository.open(GIT_DIR);
const blame = await git.Blame.file(repo, filename, ['p']);
-
+
for (let i = 0; i < blame.getHunkCount(); i++) {
// Hunk has bad type signatures, someone should tell `nodegit'.
const hunk: any = blame.getHunkByIndex(i);
const oid = hunk.finalCommitId();
const commit = await repo.getCommit(oid);
const name = commit.author().name();
-
+
if (authors.hasOwnProperty(name)) authors[name] += 1;
else authors[name] = 1;
}
@@ -34,10 +34,10 @@ const file_authors = async (filename: string): Promise<Authors> => {
export default async (homescope : HomeScope) => {
const { message, args, CONFIG } = homescope;
const p = CONFIG.commands.prefix;
-
+
if (args.length < 1)
return message.answer('Please provide a command to introspect.');
-
+
const command = args[0].startsWith(p) ? args[0].tail() : args[0];
if (command.match(/\//g))
@@ -45,10 +45,10 @@ export default async (homescope : HomeScope) => {
const expansion = CONFIG.commands.aliases[command];
if (expansion) return message.channel.send(`\`${p}${command}\``
- + `is an alias that expands to \`${p}${expansion}\`.`);
+ + ` is an alias that expands to \`${p}${expansion}\`.`);
const filename = `lib/commands/${command}.ts`;
-
+
try {
const source = read_file(`${process.cwd()}/${filename}`)
.toString();
@@ -58,7 +58,7 @@ export default async (homescope : HomeScope) => {
.join(', ');
const msg = `Source code for \`${p}${command}\`:\n`;
-
+
const msg_len = [msg, source, author_str]
.reduce((acc, s) => acc + s.length, 0);
diff --git a/lib/commands/weather.ts b/lib/commands/weather.ts
@@ -49,7 +49,7 @@ export default async (home_scope: HomeScope) => {
let geocoder_json, weather_info, geo_object, country_code;
try {
const geocoder = await fetch(`${GEOCODE_URL}&apikey=${geokey}`
- +`&geocode=${location}&lang=en-US`);
+ +`&geocode=${encodeURI(location)}&lang=en-US`);
geocoder_json = await geocoder.json();
geo_object = geocoder_json.response