summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/rbot/plugins/seen.rb1
-rw-r--r--lib/rbot/config.rb28
-rw-r--r--lib/rbot/keywords.rb1
3 files changed, 21 insertions, 9 deletions
diff --git a/data/rbot/plugins/seen.rb b/data/rbot/plugins/seen.rb
index a8dc1af7..cc0c1792 100644
--- a/data/rbot/plugins/seen.rb
+++ b/data/rbot/plugins/seen.rb
@@ -21,6 +21,7 @@ class SeenPlugin < Plugin
end
def listen(m)
+ return if m.sourcenick.nil?
# keep database up to date with who last said what
if m.kind_of?(PrivMessage)
return if m.private?
diff --git a/lib/rbot/config.rb b/lib/rbot/config.rb
index 36160875..7475d617 100644
--- a/lib/rbot/config.rb
+++ b/lib/rbot/config.rb
@@ -311,20 +311,30 @@ module Irc
:defaults => {:topic => false}
if(File.exist?("#{@@bot.botclass}/conf.yaml"))
- newconfig = YAML::load_file("#{@@bot.botclass}/conf.yaml")
- @@config.update newconfig
- else
- # first-run wizard!
- BotConfigWizard.new(@@bot).run
- # save newly created config
- save
+ begin
+ newconfig = YAML::load_file("#{@@bot.botclass}/conf.yaml")
+ @@config.update newconfig
+ return
+ rescue
+ $stderr.puts "failed to read conf.yaml: #{$!}"
+ end
end
+ # if we got here, we need to run the first-run wizard
+ BotConfigWizard.new(@@bot).run
+ # save newly created config
+ save
end
# write current configuration to #{botclass}/conf.rbot
def save
- File.open("#{@@bot.botclass}/conf.yaml", "w") do |file|
- file.puts @@config.to_yaml
+ begin
+ File.open("#{@@bot.botclass}/conf.yaml.new", "w") do |file|
+ file.puts @@config.to_yaml
+ end
+ File.rename("#{@@bot.botclass}/conf.yaml.new",
+ "#{@@bot.botclass}/conf.yaml")
+ rescue
+ $stderr.puts "failed to write configuration file conf.yaml! #{$!}"
end
end
diff --git a/lib/rbot/keywords.rb b/lib/rbot/keywords.rb
index 8065e8b8..cc91155c 100644
--- a/lib/rbot/keywords.rb
+++ b/lib/rbot/keywords.rb
@@ -250,6 +250,7 @@ module Irc
#
# handle a message asking about a keyword
def keyword(m, key, dunno=true)
+ return if key.nil?
unless(kw = self[key])
m.reply @bot.lang.get("dunno") if (dunno)
return