X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fdict.rb;h=c9bfabafadef5fb75491d6590f492d7ec8caa48a;hb=052217de30c59206d7025b582d4604557a747470;hp=db779889592bd6bf98478c1210933c23252f85ad;hpb=6f9bfa43ac907700fcba394e0f6b9d987b1192fb;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/dict.rb b/data/rbot/plugins/dict.rb index db779889..c9bfabaf 100644 --- a/data/rbot/plugins/dict.rb +++ b/data/rbot/plugins/dict.rb @@ -12,9 +12,11 @@ # * the Oxford dictionary for (British) English # * the De Mauro/Paravia dictionary for Italian # * the Chambers dictionary for English (accepts both US and UK) +# * the Littré dictionary for French # # Other plugins can use this one to check if a given word is valid in italian -# or english by using the is_italian?/is_british?/is_english? methods +# or english or french by using the is_italian?, is_british?, is_english?, +# is_french? methods # # TODO: cache results and reuse them if get_cached returns a cache copy @@ -29,13 +31,37 @@ class DictPlugin < Plugin :default => 0, :desc => "When set to n > 0, the bot will return the first paragraph from the first n dictionary hits") + def demauro_filter(s) + # check if it's a page we can handle + loc = Utils.check_location(s, @dmurlrx) + # the location might be not good, but we might still be able to handle the + # page + if !loc and s[:text] !~ //m) + hits = @bot.config['dict.hits'] + n = 0 + entries[0...hits].map { |ar| + n += 1 + m.reply(("#{Bold}#{n}#{Bold} %s" % ar).ircify_html, :overlong => :truncate) + } + end + + def is_french?(word) + return littre(nil, :word => word, :justcheck => true) + end + end plugin = DictPlugin.new -plugin.map 'demauro :word', :action => 'demauro' -plugin.map 'oxford *word', :action => 'oxford' -plugin.map 'chambers *word', :action => 'chambers' +plugin.map 'demauro :word', :action => 'demauro', :thread => true +plugin.map 'oxford *word', :action => 'oxford', :thread => true +plugin.map 'chambers *word', :action => 'chambers', :thread => true +plugin.map 'littre *word', :action => 'littre', :thread => true