Permalink
Browse files

Fixed spell bug on case of no results.

Fixed WikiPedia search.
Made kicker regexps case insensitive.
Added bots to kicker exemption list.


git-svn-id: http://localhost/svn/reby@1013 3bcaa56b-69e1-0310-823e-bac524374bd6
  • Loading branch information...
1 parent e969e4c commit 2f958ff3481f9b5d6320c87f1a89b8e8892f8c4c Pistos committed May 19, 2006
Showing with 69 additions and 41 deletions.
  1. +37 −32 kicker.rb
  2. +6 −2 spell.rb
  3. +26 −7 websearch.rb
View
@@ -23,43 +23,40 @@ class Kicker
'If you wanted to leave, you could have just said so...',
"Good thing these aren't real bullets...",
],
- :exempted => [
- 'Specimen',
- ],
},
],
/.+/ => [
{
:regexps => [
- /\banus\b/,
- /\bcock\b/,
- /\bfag\b/,
- /\bgive me head\b/,
- /\bnigga\b/,
- /\bnigger\b/,
- /\btits\b/,
- /\btitties\b/,
- /\bturds?\b/,
- /\bmy wang\b/,
- /anal sex/,
- /asshole/,
- /my balls/,
- /bitch/,
- /blow ?job/,
- /cunt/,
- /dick/,
- /dumbass/,
- /fag/,
- /fuck/,
- /masturbat/,
- /oral sex/,
- /orgasm/,
- /penis/,
- /pussy/,
- /pussies/,
- /shit/,
- /suck my/,
- /vagina/,
+ /\banus\b/i,
+ /\bcock\b/i,
+ /\bfag\b/i,
+ /\bgive me head\b/i,
+ /\bnigga\b/i,
+ /\bnigger\b/i,
+ /\btits\b/i,
+ /\btitties\b/i,
+ /\bturds?\b/i,
+ /\bmy wang\b/i,
+ /anal sex/i,
+ /asshole/i,
+ /my balls/i,
+ /bitch/i,
+ /blow ?job/i,
+ /cunt/i,
+ /dick/i,
+ /dumbass/i,
+ /fag/i,
+ /fuck/i,
+ /masturbat/i,
+ /oral sex/i,
+ /orgasm/i,
+ /penis/i,
+ /pussy/i,
+ /pussies/i,
+ /shit/i,
+ /suck my/i,
+ /vagina/i,
],
:reasons => [
'Watch your language.',
@@ -70,6 +67,14 @@ class Kicker
'No foul language.',
'No vulgarity.',
],
+ :exempted => [
+ 'Pistos',
+ 'Grace',
+ 'scry',
+ 'Gherkins',
+ 'MathetesUnloved',
+ 'SpyBot',
+ ]
}
],
}
View
@@ -64,8 +64,12 @@ def check( nick, userhost, handle, channel, args_ )
if result =~ /\*$/
retval = "#{word} is spelled correctly."
else
- words = list[ 1 ].strip.split( "," )
- retval = "'#{word}' is probably one of: #{words[ 0, NUM_SUGGESTIONS ].join( ', ' )}"
+ if list[ 1 ]
+ words = list[ 1 ].strip.split( "," )
+ retval = "'#{word}' is probably one of: #{words[ 0, NUM_SUGGESTIONS ].join( ', ' )}"
+ else
+ retval = "No suggestions for unknown word."
+ end
end
end
View
@@ -21,8 +21,10 @@
require_gem 'rubyful_soup'
end
-
class WebSearch
+ VERSION = '1.0.1'
+ LAST_MODIFIED = '2006-05-19'
+
MAX_RESULTS = 5
ENGINE_GOOGLE = 0
ENGINE_TEOMA = 1
@@ -50,6 +52,7 @@ def initialize
$reby.bind( "pub", "-", "!syn", "synonym", "$websearch" )
$reby.bind( "pub", "-", "!pun", "badPuns", "$websearch" )
$reby.bind( 'pub', '-', '!gloss', 'gloss', '$websearch' )
+ $reby.bind( 'pub', '-', '!define', 'gloss', '$websearch' )
$reby.bind( 'pub', '-', '!dict', 'wordsmyth', '$websearch' )
$reby.bind( "pub", "-", "!docs", "searchGeoShellDocs", "$websearch" )
@@ -241,12 +244,28 @@ def search( nick, channel, args, engine = ENGINE_GOOGLE )
#end
when ENGINE_WIKIPEDIA
open( "http://en.wikipedia.org/w/wiki.phtml?search=#{ arg }" ) do |html|
- text = html.read
- title = text[ /href.+?title=(.+?)&/, 1 ]
- if title == "Main_Page"
- $reby.putserv "PRIVMSG #{channel} :No wikipedia entries found for '#{arg}'."
- else
- $reby.putserv "PRIVMSG #{channel} :[#{arg}] http://en.wikipedia.org/wiki/#{title}"
+ soup = BeautifulSoup.new( html.read )
+
+ heading_tag = soup.find( 'h1', :attrs => { 'class' => 'firstHeading' } )
+ if heading_tag
+ title = heading_tag.string
+ case title
+ when 'Main_Page'
+ $reby.putserv "PRIVMSG #{channel} :No wikipedia entries found for '#{arg}'."
+ when 'Search'
+ count = -2
+ soup.find_all( 'a', :attrs => { 'href' => %r{^/wiki/} } ).each do |a|
+ if count >= 0
+ $reby.putserv "PRIVMSG #{channel} :[#{arg}] http://en.wikipedia.org/#{a['href']}"
+ end
+ count += 1
+ if count >= num_results
+ break
+ end
+ end
+ else
+ $reby.putserv "PRIVMSG #{channel} :[#{arg}] http://en.wikipedia.org/wiki/#{title}"
+ end
end
end
when ENGINE_GEOSHELL_WIKI

0 comments on commit 2f958ff

Please sign in to comment.