set data prefix
This commit is contained in:
parent
bc8f144d93
commit
4ab79e2893
15
main.rb
15
main.rb
@ -14,8 +14,13 @@ require './folder.rb'
|
|||||||
|
|
||||||
logger = Logger.new(STDOUT)
|
logger = Logger.new(STDOUT)
|
||||||
logger.level = Logger::INFO
|
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")
|
logger.info("loaded config")
|
||||||
bot = Discordrb::Commands::CommandBot.new token: config_obj["bot_token"], prefix: "!folder"
|
bot = Discordrb::Commands::CommandBot.new token: config_obj["bot_token"], prefix: "!folder"
|
||||||
folder = Folder.new
|
folder = Folder.new
|
||||||
@ -72,8 +77,8 @@ bot.message(private: true) do |event|
|
|||||||
if res != nil
|
if res != nil
|
||||||
if res.image? or res.video?
|
if res.image? or res.video?
|
||||||
download = Down.download(file.url)
|
download = Down.download(file.url)
|
||||||
FileUtils.mv(download.path, "./spool/#{download.original_filename}")
|
FileUtils.mv(download.path, "#{prefix}spool/#{download.original_filename}")
|
||||||
folder.submit(Submission.new("./spool/#{download.original_filename}",true,sender))
|
folder.submit(Submission.new("#{prefix}spool/#{download.original_filename}",true,sender))
|
||||||
event.respond("Submission #{i} accepted")
|
event.respond("Submission #{i} accepted")
|
||||||
i = i + 1
|
i = i + 1
|
||||||
else
|
else
|
||||||
@ -89,8 +94,8 @@ bot.message(private: true) do |event|
|
|||||||
if mime_guess != nil
|
if mime_guess != nil
|
||||||
if mime_guess.image? or mime_guess.video?
|
if mime_guess.image? or mime_guess.video?
|
||||||
download = Down.download(file.url)
|
download = Down.download(file.url)
|
||||||
FileUtils.mv(download.path, "./spool/#{download.original_filename}")
|
FileUtils.mv(download.path, "#{prefix}spool/#{download.original_filename}")
|
||||||
folder.submit(Submission.new("./spool/#{download.original_filename}",true,sender))
|
folder.submit(Submission.new("#{prefix}spool/#{download.original_filename}",true,sender))
|
||||||
event.respond("Submission #{i} accepted")
|
event.respond("Submission #{i} accepted")
|
||||||
updated = true
|
updated = true
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user