From 21d2d135f76357205b63ab0e9fac836ca5d1ba78 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 17 Aug 2006 17:17:25 +0000 Subject: [PATCH] Restore tell and forget behaviour without 'keyword' before them --- ChangeLog | 2 + data/rbot/plugins/keywords.rb | 109 ++++++++++++++++++++-------------- 2 files changed, 68 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index d82ab0a8..63e06d86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ auth, so that only owner can do stuff with it * New Auth Framework: fix horrible typo, assignment instead of equality test when checking for the username during login. + * Keywords plugin: tell and forget work again without 'keyword' before + them. 2006-08-12 Giuseppe Bilotta diff --git a/data/rbot/plugins/keywords.rb b/data/rbot/plugins/keywords.rb index d963e186..a5b773a1 100644 --- a/data/rbot/plugins/keywords.rb +++ b/data/rbot/plugins/keywords.rb @@ -9,7 +9,7 @@ class Keyword # type of keyword (e.g. "is" or "are") attr_reader :type - + # type:: type of keyword (e.g "is" or "are") # values:: array of values # @@ -299,29 +299,38 @@ class Keywords < Plugin # return help string for Keywords with option topic +topic+ def help(plugin, topic = '') - case topic - when 'lookup' - 'keyword [lookup] => look up the definition for a keyword; writing "lookup" is optional' - when 'set' - 'keyword set is/are => define a keyword, definition can contain "|" to separate multiple randomly chosen replies' - when 'forget' - 'keyword forget => forget a keyword' - when 'tell' - 'keyword tell about => tell somebody about a keyword' - when 'search' - 'keyword search [--all] [--full] => search keywords for , which can be a regular expression. If --all is set, search static keywords too, if --full is set, search definitions too.' - when 'listen' - 'when the config option "keyword.listen" is set to false, rbot will try to extract keyword definitions from regular channel messages' - when 'address' - 'when the config option "keyword.address" is set to true, rbot will try to answer channel questions of the form "?"' - when '' - ' => normal response is " is ", but if begins with , the response will be ""' - when '' - ' => makes keyword respond with "/me "' - when '' - ' => replaced with questioner in reply' - when '' - ' => respond by setting the topic to the rest of the definition' + case plugin + when /keyword/ + case topic + when 'lookup' + 'keyword [lookup] => look up the definition for a keyword; writing "lookup" is optional' + when 'set' + 'keyword set is/are => define a keyword, definition can contain "|" to separate multiple randomly chosen replies' + when 'forget' + 'keyword forget => forget a keyword' + when 'tell' + 'keyword tell about => tell somebody about a keyword' + when 'search' + 'keyword search [--all] [--full] => search keywords for , which can be a regular expression. If --all is set, search static keywords too, if --full is set, search definitions too.' + when 'listen' + 'when the config option "keyword.listen" is set to false, rbot will try to extract keyword definitions from regular channel messages' + when 'address' + 'when the config option "keyword.address" is set to true, rbot will try to answer channel questions of the form "?"' + when '' + ' => normal response is " is ", but if begins with , the response will be ""' + when '' + ' => makes keyword respond with "/me "' + when '' + ' => replaced with questioner in reply' + when '' + ' => respond by setting the topic to the rest of the definition' + else + 'keyword module (fact learning and regurgitation) topics: lookup, set, forget, tell, search, listen, address, , , , ' + end + when "forget" + 'forget => forget a keyword' + when "tell" + 'tell about => tell somebody about a keyword' else 'keyword module (fact learning and regurgitation) topics: lookup, set, forget, tell, search, listen, address, , , , ' end @@ -333,7 +342,7 @@ class Keywords < Plugin m.reply @bot.lang.get("dunno_about_X") % key return end - + response = kw.to_s response.gsub!(//, m.sourcenick) if(response =~ /^\s*(.*)/) @@ -415,24 +424,35 @@ class Keywords < Plugin # privmsg handler def privmsg(m) - case m.params - when /^set\s+(.+?)\s+(is|are)\s+(.+)$/ - keyword_command(m, $1, $2, $3) if @bot.auth.allow?('keycmd', m.source, m.replyto) - when /^forget\s+(.+)$/ - keyword_forget(m, $1) if @bot.auth.allow?('keycmd', m.source, m.replyto) - when /^lookup\s+(.+)$/ - keyword_lookup(m, $1) if @bot.auth.allow?('keyword', m.source, m.replyto) - when /^stats\s*$/ - keyword_stats(m) if @bot.auth.allow?('keyword', m.source, m.replyto) - when /^search\s+(.+)$/ - key = $1 - full = key.sub!('--full ', '') - all = key.sub!('--all ', '') - keyword_search(m, key, full, all) if @bot.auth.allow?('keyword', m.source, m.replyto) - when /^tell\s+(\S+)\s+about\s+(.+)$/ - keyword_tell(m, $1, $2) if @bot.auth.allow?('keyword', m.source, m.replyto) - else - keyword_lookup(m, m.params) if @bot.auth.allow?('keyword', m.source, m.replyto) + case m.plugin + when "keyword" + case m.params + when /^set\s+(.+?)\s+(is|are)\s+(.+)$/ + keyword_command(m, $1, $2, $3) if @bot.auth.allow?('keycmd', m.source, m.replyto) + when /^forget\s+(.+)$/ + keyword_forget(m, $1) if @bot.auth.allow?('keycmd', m.source, m.replyto) + when /^lookup\s+(.+)$/ + keyword_lookup(m, $1) if @bot.auth.allow?('keyword', m.source, m.replyto) + when /^stats\s*$/ + keyword_stats(m) if @bot.auth.allow?('keyword', m.source, m.replyto) + when /^search\s+(.+)$/ + key = $1 + full = key.sub!('--full ', '') + all = key.sub!('--all ', '') + keyword_search(m, key, full, all) if @bot.auth.allow?('keyword', m.source, m.replyto) + when /^tell\s+(\S+)\s+about\s+(.+)$/ + keyword_tell(m, $1, $2) if @bot.auth.allow?('keyword', m.source, m.replyto) + else + keyword_lookup(m, m.params) if @bot.auth.allow?('keyword', m.source, m.replyto) + end + when "forget" + keyword_forget(m, params) if @bot.auth.allow?('keycmd', m.source, m.replyto) + when "tell" + if m.params =~ /(\S+)\s+about\s+(.+)$/ + keyword_tell(m, $1, $2) if @bot.auth.allow?('keyword', m.source, m.replyto) + else + m.reply "wrong 'tell' syntax" + end end end @@ -452,3 +472,6 @@ end plugin = Keywords.new plugin.register 'keyword' +plugin.register 'forget' +plugin.register 'tell' + -- 2.39.2