diff options
author | Jay Thomas <degradinglight@gmail.com> | 2013-04-24 23:24:29 -0400 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2013-04-26 08:24:51 +0200 |
commit | a71bf77b72e7a0a7dd7d23953f4dde31eb47ac46 (patch) | |
tree | 14fa3370301aedcf05a00b2eb0ab47a0452a3ad7 /data/rbot | |
parent | d9ca58e7f41e4a27e087cae4cf6fe8e69aa02c73 (diff) |
note: store nicks case-insensitive to avoid lost messages
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/note.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/data/rbot/plugins/note.rb b/data/rbot/plugins/note.rb index 66e0c1ec..0c1683a6 100644 --- a/data/rbot/plugins/note.rb +++ b/data/rbot/plugins/note.rb @@ -17,10 +17,13 @@ class NotePlugin < Plugin def message(m) begin - return unless @registry.has_key? m.sourcenick + nick = m.sourcenick.downcase + # Keys are case insensitive to avoid storing a message + # for <person> instead of <Person> or visa-versa. + return unless @registry.has_key? nick pub = [] priv = [] - @registry[m.sourcenick].each do |n| + @registry[nick].each do |n| s = "[#{n.time.strftime('%H:%M')}] <#{n.from}> #{n.text}" (n.private ? priv : pub).push s end @@ -32,7 +35,7 @@ class NotePlugin < Plugin if !priv.empty? @bot.say m.sourcenick, "you have notes! " + priv.join(' ') end - @registry.delete m.sourcenick + @registry.delete nick rescue Exception => e m.reply e.message end @@ -40,11 +43,12 @@ class NotePlugin < Plugin def note(m, params) begin - q = @registry[params[:nick]] || Array.new + nick = params[:nick].downcase + q = @registry[nick] || Array.new s = params[:string].to_s.strip raise 'cowardly discarding the empty note' if s.empty? q.push Note.new(Time.now, m.sourcenick, m.private?, s) - @registry[params[:nick]] = q + @registry[nick] = q m.okay rescue Exception => e m.reply "error: #{e.message}" |