# handle it, checks for a keyword command or lookup, otherwise the message
# is delegated to plugins
class Keywords < Plugin
- BotConfig.register BotConfigBooleanValue.new('keyword.listen',
+ Config.register Config::BooleanValue.new('keyword.listen',
:default => false,
:desc => "Should the bot listen to all chat and attempt to automatically detect keywords? (e.g. by spotting someone say 'foo is bar')")
- BotConfig.register BotConfigBooleanValue.new('keyword.address',
+ Config.register Config::BooleanValue.new('keyword.address',
:default => true,
:desc => "Should the bot require that keyword lookups are addressed to it? If not, the bot will attempt to lookup foo if someone says 'foo?' in channel")
- BotConfig.register BotConfigIntegerValue.new('keyword.search_results',
+ Config.register Config::IntegerValue.new('keyword.search_results',
:default => 3,
:desc => "How many search results to display at a time")
end
end
- # drop static keywords and reload them from files, picking up any new
- # keyword files that have been added
- def rescan
- @statickeywords = Hash.new
- scan
- end
-
# load static keywords from files, picking up any new keyword files that
# have been added
def scan
end
def unreplied(m)
- # return if m.address?
- # in channel message, not to me
# TODO option to do if(m.message =~ /^(.*)$/, ie try any line as a
# keyword lookup.
- if !@bot.config["keyword.address"] && m.message =~ /^(.*\S)\s*\?\s*$/
+ if m.message =~ /^(.*\S)\s*\?\s*$/ and (m.address? or not @bot.config["keyword.address"])
keyword_lookup m, $1, true if @bot.auth.allow?("keyword", m.source)
elsif @bot.config["keyword.listen"] && (m.message =~ /^(.*?)\s+(is|are)\s+(.*)$/)
# TODO MUCH more selective on what's allowed here