From d51861faa9607718870cea1acbbc0b2b2c2c7364 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 27 Oct 2006 11:51:23 +0000 Subject: Try to read old language-agnostic lart/praises if language-specific ones are not found --- data/rbot/plugins/lart.rb | 12 ++++++++++++ data/rbot/plugins/salut.rb | 4 ++++ 2 files changed, 16 insertions(+) (limited to 'data/rbot') diff --git a/data/rbot/plugins/lart.rb b/data/rbot/plugins/lart.rb index 435ed04d..77c09882 100644 --- a/data/rbot/plugins/lart.rb +++ b/data/rbot/plugins/lart.rb @@ -42,23 +42,35 @@ class LartPlugin < Plugin @lartfile = nil @praisefile = nil super + end def set_language(lang) save @lartfile = "#{@bot.botclass}/lart/larts-#{lang}" @praisefile = "#{@bot.botclass}/lart/praises-#{lang}" + # We may be on an old installation, so on the first run read non-language-specific larts + @bulart = "#{@bot.botclass}/lart/larts" + @bupraise = "#{@bot.botclass}/lart/praise" @larts.clear @praises.clear if File.exists? @lartfile IO.foreach(@lartfile) { |line| @larts << line.chomp } + elsif File.exists? @bulart + IO.foreach(@bulart) { |line| + @larts << line.chomp + } end if File.exists? @praisefile IO.foreach(@praisefile) { |line| @praises << line.chomp } + elsif File.exists? @bupraise + IO.foreach(@bupraise) { |line| + @praises << line.chomp + } end end diff --git a/data/rbot/plugins/salut.rb b/data/rbot/plugins/salut.rb index 1a301b43..48276019 100644 --- a/data/rbot/plugins/salut.rb +++ b/data/rbot/plugins/salut.rb @@ -137,6 +137,10 @@ class SalutPlugin < Plugin end def load_lang(lang) + dir = "#{@bot.botclass}/salut" + if not File.exist?(dir) + Dir.mkdir(dir) + end file = "#{@bot.botclass}/salut/salut-#{lang}" if File.exist?(file) begin -- cgit v1.2.3