Simp-O-Matic

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

commit 5bc3a14acb7c99c27283f108f48f3408a9d46c30
parent fc51012ad8d5df2f2b9c723a570ab47ba219959e
Author: Demonstrandum <moi@knutsen.co>
Date:   Fri, 22 May 2020 19:45:54 +0100

!set reads after spaces.

Diffstat:
Mconsole.rb | 5++---
Mlib/commands/set.ts | 4++--
2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/console.rb b/console.rb @@ -1,5 +1,6 @@ #!/usr/bin/env ruby require 'json' +require 'readline' URL = 'simp-o-matic.herokuapp.com' $guild = 'GLOBAL' @@ -17,9 +18,7 @@ def send_message message system *command end -loop do - print "[#{$guild}]> " - input = gets.strip +while input = Readline.readline("[#{$guild}]> ", true) if input.start_with? '/' command, *args = input[1..].split ' ' diff --git a/lib/commands/set.ts b/lib/commands/set.ts @@ -11,11 +11,11 @@ export default (home_scope: HomeScope) => { const accessors = args[0].trim().split('.').squeeze(); const parent = accessors.pop(); const obj = access(CONFIG, accessors); - obj[parent] = JSON.parse(args[1]); + obj[parent] = JSON.parse(args.tail().join(' ')); const normal = JSON.stringify(obj[parent], null, 4); message.channel.send(`Assignment successful. - \`${args[0].trim()} = ${normal}\``.squeeze()); + \`${args[0].trim()} = ${normal}\``.squeeze()); } catch (e) { message.channel.send(`Invalid object access-path,` + `nothing set.\nProblem: \`\`\`\n${e}\n\`\`\``);