Simp-O-Matic

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

commit 6306c7e926325df6f0b3087294d898bb5e7dfb4b
parent 1ac1fd7d69c863d5dfad890c3a27b667c275bbfb
Author: Demonstrandum <moi@knutsen.co>
Date:   Fri, 22 May 2020 15:19:15 +0100

Do not fall through to global with bad guild.

Diffstat:
Aconsole.rb | 34++++++++++++++++++++++++++++++++++
Mlib/main.ts | 2++
Atest.sh | 4++++
3 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/console.rb b/console.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby +require 'json' + +URL = 'simp-o-matic.herokuapp.com' +$guild = 'GLOBAL' + +def send_message message + body = { + :console => true, + :message => message, + } + body[:guild] = $guild unless $guild == 'GLOBAL' + payload = JSON.dump body + puts "Sending payload: #{payload}" + + command = ['curl', '-d', payload, URL] + system *command +end + +loop do + print "#{$guild}> " + input = gets.strip + if input.start_with? '/' + command, *args = input[1..].split ' ' + + case command + when 'guild' + $guild = args[0] + end + else + send_message input + end +end + diff --git a/lib/main.ts b/lib/main.ts @@ -213,6 +213,8 @@ export class SimpOMatic { client.channels .fetch(GLOBAL_CONFIG.guilds[guild].system_channel) .then((c: TextChannel) => c.send(msg)); + } else if (guild) { + console.log(`Guild: '${guild}', does not exist.`); } else { system_message(client, msg); } diff --git a/test.sh b/test.sh @@ -0,0 +1,4 @@ + #/bin/bash + for i; do + echo "Arg: '$i'" + done