Skip to content

Commit

Permalink
get repl for temp fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRuiz committed Feb 22, 2021
1 parent c26ffa3 commit 10f0f0c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/slack/smart-bot/commands/on_bot/get_repl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ def get_repl(dest, user, session_name)
!config.admins.include?(user.name)
respond "The REPL with session name: #{session_name} is private", dest
else
content = "require 'nice_http'\n"
if @repls.key?(session_name)
@repls[session_name][:accessed] = Time.now.to_s
@repls[session_name][:gets] += 1
update_repls()
end

content = "require 'nice_http'\n"
if File.exist?("#{project_folder}/.smart-bot-repl") and @repls[session_name][:type] != :private_clean and @repls[session_name][:type] != :public_clean
if !@repls.key?(session_name) or
(File.exist?("#{project_folder}/.smart-bot-repl") and @repls[session_name][:type] != :private_clean and @repls[session_name][:type] != :public_clean)
content += File.read("#{project_folder}/.smart-bot-repl")
content += "\n"
end

content += File.read("#{config.path}/repl/#{@channel_id}/#{session_name}.run").gsub(/^(quit|exit|bye)$/i,'') #todo: remove this gsub it will never contain it
File.write("#{config.path}/repl/#{@channel_id}/#{session_name}.rb", content, mode: "w+")
send_file(dest, "REPL #{session_name} on #{config.channel}", "#{config.path}/repl/#{@channel_id}/#{session_name}.rb", " REPL #{session_name} on #{config.channel}", 'text/plain', "ruby")
Expand Down

0 comments on commit 10f0f0c

Please sign in to comment.