From 4ab79e28936ed1c0d8707e9bb0575ca144a8f332 Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 11 Aug 2022 14:07:12 -0400 Subject: [PATCH] set data prefix --- main.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main.rb b/main.rb index 4e2c477..6ccad14 100755 --- a/main.rb +++ b/main.rb @@ -14,8 +14,13 @@ require './folder.rb' logger = Logger.new(STDOUT) logger.level = Logger::INFO +prefix = ENV["STEVEFOLDER_PREFIX"] +if prefix == "" + prefix = "./" +end +logger.info("starting with prefix #{prefix}") -config_obj = YAML::load_file( './config.yaml' ) +config_obj = YAML::load_file( '#{prefix}config.yaml' ) logger.info("loaded config") bot = Discordrb::Commands::CommandBot.new token: config_obj["bot_token"], prefix: "!folder" folder = Folder.new @@ -72,8 +77,8 @@ bot.message(private: true) do |event| if res != nil if res.image? or res.video? download = Down.download(file.url) - FileUtils.mv(download.path, "./spool/#{download.original_filename}") - folder.submit(Submission.new("./spool/#{download.original_filename}",true,sender)) + FileUtils.mv(download.path, "#{prefix}spool/#{download.original_filename}") + folder.submit(Submission.new("#{prefix}spool/#{download.original_filename}",true,sender)) event.respond("Submission #{i} accepted") i = i + 1 else @@ -89,8 +94,8 @@ bot.message(private: true) do |event| if mime_guess != nil if mime_guess.image? or mime_guess.video? download = Down.download(file.url) - FileUtils.mv(download.path, "./spool/#{download.original_filename}") - folder.submit(Submission.new("./spool/#{download.original_filename}",true,sender)) + FileUtils.mv(download.path, "#{prefix}spool/#{download.original_filename}") + folder.submit(Submission.new("#{prefix}spool/#{download.original_filename}",true,sender)) event.respond("Submission #{i} accepted") updated = true else