Sha256: 2b1e6e9ee269de72eaaa12ea6efe479841e1cb5eb89518e85a3460bd01e6eb88

Contents?: true

Size: 855 Bytes

Versions: 20

Compression:

Stored size: 855 Bytes

Contents

class SlackSmartBot

  def get_repls(channel = @channel_id)
    require 'yaml'
    repl_file = "#{config.path}/repl/repls_#{channel}.yaml"

    if File.exist?("#{config.path}/repl/repls_#{channel}.rb") #backwards compatible
      file_conf = IO.readlines("#{config.path}/repl/repls_#{channel}.rb").join
      if file_conf.to_s() == ""
        @repls = {}
      else
        @repls = eval(file_conf)
      end
      File.open(repl_file, 'w') {|file| file.write(@repls.to_yaml) }
      File.delete("#{config.path}/repl/repls_#{channel}.rb")
    end

    if File.exist?(repl_file)      
      repls = @repls
      10.times do
        repls = YAML.load(File.read(repl_file))
        if repls.is_a?(Hash)
          break
        else
          sleep (0.1*(rand(2)+1))
        end
      end
      @repls = repls unless repls.is_a?(FalseClass)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
slack-smart-bot-1.15.25 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.15.1 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.15.0 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.14.2 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.14.1 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.14.0 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.13.2 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.13.1 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.13.0 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.12.9 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.12.8 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.12.7 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.12.6 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.12.5 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.12.4 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.12.3 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.12.2 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.12.1 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.12.0 lib/slack/smart-bot/utils/get_repls.rb
slack-smart-bot-1.11.0 lib/slack/smart-bot/utils/get_repls.rb