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