summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-15 19:36:36 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-15 19:36:36 +0000
commita708da678ebafbfac08e1c867610fc809680ae68 (patch)
treea889237cc334822160f43a94b2acc7e756cea995
parent21af4682361be8d6218d1ea9575da9e311b675a7 (diff)
Make the lart plugin use language-specific lart/praises
-rw-r--r--data/rbot/plugins/lart.rb42
-rw-r--r--data/rbot/templates/lart/larts-english (renamed from data/rbot/templates/lart/larts)0
-rw-r--r--data/rbot/templates/lart/praises-english (renamed from data/rbot/templates/lart/praises)0
3 files changed, 28 insertions, 14 deletions
diff --git a/data/rbot/plugins/lart.rb b/data/rbot/plugins/lart.rb
index d4abee3b..40a0432a 100644
--- a/data/rbot/plugins/lart.rb
+++ b/data/rbot/plugins/lart.rb
@@ -1,9 +1,13 @@
-# Author: Michael Brailsford <brailsmt@yahoo.com>
-# aka brailsmt
-# Purpose: Provide for humorous larts and praises
-# Copyright: 2002 Michael Brailsford. All rights reserved.
-# License: This plugin is licensed under the BSD license. The terms of
-# which follow.
+# Original Author:
+# Michael Brailsford <brailsmt@yahoo.com>
+# aka brailsmt
+# Author: Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>
+# Purpose: Provide for humorous larts and praises
+# Original Copyright:
+# 2002 Michael Brailsford. All rights reserved.
+# Copyright: 2006 Giuseppe Bilotta. All rights reserved.
+# License: This plugin is licensed under the BSD license. The terms of
+# which follow.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -33,17 +37,26 @@ class LartPlugin < Plugin
end
def initialize
- super
@larts = Array.new
@praises = Array.new
- #read in the lart and praise files
- if File.exists? "#{@bot.botclass}/lart/larts"
- IO.foreach("#{@bot.botclass}/lart/larts") { |line|
+ @lartfile = nil
+ @praisefile = nil
+ super
+ end
+
+ def set_language(lang)
+ save
+ @lartfile = "#{@bot.botclass}/lart/larts-#{lang}"
+ @praisefile = "#{@bot.botclass}/lart/praises-#{lang}"
+ @larts.clear
+ @praises.clear
+ if File.exists? @lartfile
+ IO.foreach(@lartfile) { |line|
@larts << line.chomp
}
end
- if File.exists? "#{@bot.botclass}/lart/praises"
- IO.foreach("#{@bot.botclass}/lart/praises") { |line|
+ if File.exists? @praisefile
+ IO.foreach(@praisefile) { |line|
@praises << line.chomp
}
end
@@ -53,12 +66,13 @@ class LartPlugin < Plugin
end
def save
+ return if @lartfile.nil? and @praisefile.nil?
Dir.mkdir("#{@bot.botclass}/lart") if not FileTest.directory? "#{@bot.botclass}/lart"
# TODO implement safe saving here too
- File.open("#{@bot.botclass}/lart/larts", "w") { |file|
+ File.open(@lartfile, "w") { |file|
file.puts @larts
}
- File.open("#{@bot.botclass}/lart/praises", "w") { |file|
+ File.open(@praisefile, "w") { |file|
file.puts @praises
}
end
diff --git a/data/rbot/templates/lart/larts b/data/rbot/templates/lart/larts-english
index c3a25880..c3a25880 100644
--- a/data/rbot/templates/lart/larts
+++ b/data/rbot/templates/lart/larts-english
diff --git a/data/rbot/templates/lart/praises b/data/rbot/templates/lart/praises-english
index 3d89df74..3d89df74 100644
--- a/data/rbot/templates/lart/praises
+++ b/data/rbot/templates/lart/praises-english