if ruleset.has_key?(:wordlist_file)
begin
ruleset[:words] =
- File.new(datafile ruleset[:wordlist_file]).grep(
+ File.new(datafile(ruleset[:wordlist_file])).grep(
ruleset[:listen]) {|l| ruleset[:normalize].call l.chomp}
rescue
raise "unable to load word list"
# have been added
def scan
# first scan for old DBHash files, and convert them
- Dir[datafile '*'].each {|f|
+ Dir[datafile('*')].each {|f|
next unless f =~ /\.db$/
log "upgrading keyword db #{f} (rbot 0.9.5 or prior) database format"
newname = f.gsub(/\.db$/, ".kdb")
}
# then scan for current DBTree files, and load them
- Dir[@bot.path 'keywords', '*'].each {|f|
+ Dir[@bot.path('keywords', '*')].each {|f|
next unless f =~ /\.kdb$/
hsh = DBTree.new @bot, f, true
key = File.basename(f).gsub(/\.kdb$/, "")
}
# then scan for non DB files, and convert/import them and delete
- Dir[@bot.path 'keywords', '*'].each {|f|
+ Dir[@bot.path('keywords', '*')].each {|f|
next if f =~ /\.kdb$/
next if f =~ /CVS$/
log "auto converting keywords from #{f}"
File.rename(olds, olds + ".old")
end
- olds.replace(@bot.path 'keyword.db')
+ olds.replace(@bot.path('keyword.db'))
if File.exist? olds
log "upgrading old keywords (rbot 0.9.9 or prior) database format"
old = BDB::CIBtree.open olds, nil, "r+", 0600
end
def oldsave
- File.open(@bot.path "keywords.rbot", "w") do |file|
+ File.open(@bot.path("keywords.rbot"), "w") do |file|
@keywords.each do |key, value|
file.puts "#{key}<=#{value.type}=>#{value.dump}"
end
@oldpraise = datafile 'praise'
end
- @lartfile.replace(datafile "larts-#{lang}")
- @praisefile.replace(datafile "praises-#{lang}")
+ @lartfile.replace(datafile("larts-#{lang}"))
+ @praisefile.replace(datafile("praises-#{lang}"))
@larts.clear
@praises.clear
if File.exists? @lartfile
super
@lists = Hash.new
@changed = Hash.new
- Dir[datafile '*'].each {|f|
+ Dir[datafile('*')].each {|f|
next if File.directory?(f)
channel = File.basename(f)
@lists[channel] = Array.new if(!@lists.has_key?(channel))
begin
if @changed[channel]
debug "Writing new quotefile for channel #{channel} ..."
- Utils.safe_save(datafile channel) {|file|
+ Utils.safe_save(datafile(channel)) {|file|
quotes.compact.each {|q|
file.puts "#{q.num} | #{q.date} | #{q.source} | #{q.quote}"
}
u = URBAN + URI.escape(word)
u += '&page=' + p.to_s if p > 1
s = @bot.httputil.get(u)
- return m.reply "Couldn't get the urban dictionary definition for #{word}" if s.nil?
+ return m.reply("Couldn't get the urban dictionary definition for #{word}") if s.nil?
notfound = s.match %r{<div style="color: #669FCE"><i>.*?</i> isn't defined}
resp = @bot.httputil.head('http://www.urbandictionary.com/random.php',
:max_redir => -1,
:cache => false)
- return m.reply "Couldn't get a random urban dictionary word" if resp.nil?
+ return m.reply("Couldn't get a random urban dictionary word") if resp.nil?
if resp.code == "302" && (loc = resp['location'])
words = URI.unescape(loc.match(/define.php\?term=(.*)$/)[1]) rescue nil
end
end
def timestamp(time)
- return time.strftime @bot.config['irclog.timestamp_format']
+ return time.strftime(@bot.config['irclog.timestamp_format'])
end
def event_irclog_list_changed(nolist, dolist)
# If it's a file, we rename to filename.old.filedate
up = dir.dup
until File.exist? up
- up.replace File.dirname up
+ up.replace(File.dirname(up))
end
unless File.directory? up
backup = up.dup
missing = Dir.chdir(template_dir) { Dir.glob('*/**') } - Dir.chdir(@botclass) { Dir.glob('*/**') }
missing.map do |f|
dest = File.join(@botclass, f)
- FileUtils.mkdir_p(File.dirname dest)
+ FileUtils.mkdir_p(File.dirname(dest))
FileUtils.cp File.join(template_dir, f), dest
end
else