X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fkeywords.rb;fp=data%2Frbot%2Fplugins%2Fkeywords.rb;h=0c1b35262ca693c1e265b468294f528116bc201e;hb=73be154bcffb5039995fdf66a2ff71be6c4e25d6;hp=7aa5b9743fb1387c69d7d276d444e5fd5986feb8;hpb=336fd3bbbec11f7157fe60b2c56094f018350a1c;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/keywords.rb b/data/rbot/plugins/keywords.rb index 7aa5b974..0c1b3526 100644 --- a/data/rbot/plugins/keywords.rb +++ b/data/rbot/plugins/keywords.rb @@ -285,20 +285,27 @@ class Keywords < Plugin debug "got keyword command #{lhs}, #{mhs}, #{rhs}" return if lhs.strip.empty? + overwrite = false + overwrite = true if(lhs.gsub!(/^no,\s*/, "")) + also = false also = true if(rhs.gsub!(/^also\s+/, "")) values = rhs.split(/\s+\|\s+/) lhs = Keyword.unescape lhs - if(also && has_key?(lhs)) + if(overwrite || also || !has_key?(lhs)) + if(also && has_key?(lhs)) + kw = self[lhs] + kw << values + @keywords[lhs] = kw.dump + else + @keywords[lhs] = Keyword.new(mhs, values).dump + end + m.okay if !quiet + elsif(has_key?(lhs)) kw = self[lhs] - kw << values - @keywords[lhs] = kw.dump - else - @keywords[lhs] = Keyword.new(mhs, values).dump + m.reply "but #{lhs} #{kw.type} #{kw.desc}" if kw && !quiet end - - @bot.okay m.target if !quiet end # return help string for Keywords with option topic +topic+ @@ -335,6 +342,8 @@ class Keywords < Plugin 'forget => forget a keyword' when "tell" 'tell about => tell somebody about a keyword' + when "learn" + 'learn that is/are => define a keyword, definition can contain "|" to separate multiple randomly chosen replies' else 'keyword module (fact learning and regurgitation) topics: lookup, set, forget, tell, search, listen, address, , , , ' end @@ -471,6 +480,12 @@ class Keywords < Plugin else m.reply "wrong 'tell' syntax" end + when "learn" + if m.params =~ /^that\s+(.+?)\s+(is|are)\s+(.+)$/ + keyword_command(m, $1, $2, $3) if @bot.auth.allow?('keycmd', m.source, m.replyto) + else + m.reply "wrong 'learn' syntax" + end end end @@ -492,4 +507,5 @@ plugin = Keywords.new plugin.register 'keyword' plugin.register 'forget' plugin.register 'tell' +plugin.register 'learn'