rbot 0.9.14 → 0.9.15
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +6 -2
- data/REQUIREMENTS +7 -1
- data/Rakefile +10 -32
- data/bin/rbot +6 -1
- data/bin/svnwatch-postcommit-hook +68 -0
- data/data/rbot/contrib/plugins/stats.rb +3 -3
- data/data/rbot/contrib/plugins/vandale.rb +1 -1
- data/data/rbot/filters/rss.rb +72 -0
- data/data/rbot/languages/finnish.lang +50 -0
- data/data/rbot/plugins/alias.rb +6 -6
- data/data/rbot/plugins/autorejoin.rb +41 -2
- data/data/rbot/plugins/bans.rb +100 -6
- data/data/rbot/plugins/bash.rb +9 -4
- data/data/rbot/plugins/cal.rb +1 -1
- data/data/rbot/plugins/chucknorris.rb +6 -6
- data/data/rbot/plugins/debugger.rb +7 -3
- data/data/rbot/plugins/deepthoughts.rb +1 -1
- data/data/rbot/plugins/delicious.rb +6 -2
- data/data/rbot/plugins/dice.rb +7 -7
- data/data/rbot/plugins/dict.rb +4 -3
- data/data/rbot/plugins/dictclient.rb +17 -13
- data/data/rbot/plugins/digg.rb +3 -3
- data/data/rbot/plugins/eightball.rb +1 -1
- data/data/rbot/plugins/factoids.rb +13 -4
- data/data/rbot/plugins/figlet.rb +4 -4
- data/data/rbot/plugins/forecast.rb +3 -3
- data/data/rbot/plugins/fortune.rb +14 -8
- data/data/rbot/plugins/freshmeat.rb +2 -2
- data/data/rbot/plugins/games/azgame.rb +72 -19
- data/data/rbot/plugins/games/hangman.rb +499 -0
- data/data/rbot/plugins/games/quiz.rb +15 -13
- data/data/rbot/plugins/games/roshambo.rb +1 -1
- data/data/rbot/plugins/games/roulette.rb +4 -4
- data/data/rbot/plugins/games/shiritori.rb +31 -31
- data/data/rbot/plugins/games/uno.rb +28 -6
- data/data/rbot/plugins/games/wheelfortune.rb +1 -3
- data/data/rbot/plugins/geoip.rb +83 -28
- data/data/rbot/plugins/googlefight.rb +64 -0
- data/data/rbot/plugins/greet.rb +45 -0
- data/data/rbot/plugins/grouphug.rb +40 -12
- data/data/rbot/plugins/imdb.rb +4 -4
- data/data/rbot/plugins/insult.rb +2 -2
- data/data/rbot/plugins/karma.rb +6 -5
- data/data/rbot/plugins/keywords.rb +26 -22
- data/data/rbot/plugins/lart.rb +5 -6
- data/data/rbot/plugins/lastfm.rb +488 -125
- data/data/rbot/plugins/lib_spotify.rb +84 -0
- data/data/rbot/plugins/linkbot.rb +1 -1
- data/data/rbot/plugins/markov.rb +567 -78
- data/data/rbot/plugins/math.rb +3 -3
- data/data/rbot/plugins/modes.rb +1 -1
- data/data/rbot/plugins/nickrecover.rb +1 -1
- data/data/rbot/plugins/nickserv.rb +7 -7
- data/data/rbot/plugins/note.rb +55 -0
- data/data/rbot/plugins/nslookup.rb +2 -2
- data/data/rbot/plugins/quakeauth.rb +4 -4
- data/data/rbot/plugins/quotes.rb +53 -19
- data/data/rbot/plugins/reaction.rb +76 -19
- data/data/rbot/plugins/remind.rb +3 -96
- data/data/rbot/plugins/ri.rb +1 -1
- data/data/rbot/plugins/rot13.rb +1 -1
- data/data/rbot/plugins/rss.rb +296 -190
- data/data/rbot/plugins/salut.rb +8 -8
- data/data/rbot/plugins/script.rb +48 -11
- data/data/rbot/plugins/search.rb +124 -28
- data/data/rbot/plugins/seen.rb +162 -31
- data/data/rbot/plugins/shortenurls.rb +1 -1
- data/data/rbot/plugins/slashdot.rb +19 -6
- data/data/rbot/plugins/spotify.rb +78 -0
- data/data/rbot/plugins/theyfightcrime.rb +10 -10
- data/data/rbot/plugins/time.rb +2 -2
- data/data/rbot/plugins/translator.rb +161 -85
- data/data/rbot/plugins/tube.rb +2 -2
- data/data/rbot/plugins/tumblr.rb +143 -0
- data/data/rbot/plugins/twitter.rb +25 -6
- data/data/rbot/plugins/urban.rb +6 -4
- data/data/rbot/plugins/url.rb +49 -10
- data/data/rbot/plugins/weather.rb +6 -6
- data/data/rbot/plugins/wserver.rb +5 -5
- data/data/rbot/plugins/youtube.rb +12 -12
- data/data/rbot/templates/lart/larts-italian +1 -1
- data/launch_here.rb +68 -0
- data/lib/rbot/botuser.rb +1 -1
- data/lib/rbot/compat19.rb +70 -0
- data/lib/rbot/config.rb +8 -6
- data/lib/rbot/core/auth.rb +37 -21
- data/lib/rbot/core/basics.rb +33 -2
- data/lib/rbot/core/config.rb +24 -17
- data/lib/rbot/core/filters_ui.rb +2 -2
- data/lib/rbot/core/irclog.rb +20 -11
- data/lib/rbot/core/remote.rb +9 -9
- data/lib/rbot/core/unicode.rb +4 -0
- data/lib/rbot/core/userdata.rb +16 -1
- data/lib/rbot/core/utils/extends.rb +76 -0
- data/lib/rbot/core/utils/filters.rb +47 -0
- data/lib/rbot/core/utils/httputil.rb +36 -26
- data/lib/rbot/core/utils/parse_time.rb +193 -0
- data/lib/rbot/core/utils/utils.rb +81 -56
- data/lib/rbot/core/utils/wordlist.rb +66 -0
- data/lib/rbot/core/wordlist_ui.rb +27 -0
- data/lib/rbot/irc.rb +59 -19
- data/lib/rbot/ircbot.rb +190 -58
- data/lib/rbot/ircsocket.rb +14 -8
- data/lib/rbot/language.rb +4 -3
- data/lib/rbot/load-gettext.rb +22 -9
- data/lib/rbot/message.rb +89 -18
- data/lib/rbot/messagemapper.rb +71 -19
- data/lib/rbot/plugins.rb +112 -44
- data/lib/rbot/{registry.rb → registry/bdb.rb} +226 -22
- data/lib/rbot/registry/tc.rb +531 -0
- data/lib/rbot/rfc2812.rb +33 -8
- data/lib/rbot/timer.rb +12 -20
- data/po/en_US/rbot-autorejoin.po +3 -0
- data/po/en_US/rbot-azgame.po +51 -43
- data/po/en_US/rbot-bash.po +15 -0
- data/po/en_US/rbot-dictclient.po +20 -20
- data/po/en_US/rbot-factoids.po +9 -9
- data/po/en_US/rbot-geoip.po +0 -0
- data/po/en_US/rbot-googlefight.po +24 -0
- data/po/en_US/rbot-grouphug.po +4 -4
- data/po/en_US/rbot-hangman.po +114 -0
- data/po/en_US/rbot-keywords.po +3 -3
- data/po/en_US/rbot-lastfm.po +268 -70
- data/po/en_US/rbot-markov.po +73 -2
- data/po/en_US/rbot-quotes.po +21 -21
- data/po/en_US/rbot-rss.po +6 -2
- data/po/en_US/rbot-script.po +3 -0
- data/po/en_US/rbot-seen.po +72 -0
- data/po/en_US/rbot-spell.po +2 -2
- data/po/en_US/rbot-translator.po +13 -13
- data/po/en_US/rbot-twitter.po +3 -3
- data/po/en_US/rbot-uno.po +131 -114
- data/po/en_US/rbot-wall.po +12 -13
- data/po/en_US/rbot-wheelfortune.po +41 -41
- data/po/en_US/rbot.po +254 -194
- data/po/fi/rbot-alias.po +82 -0
- data/po/fi/rbot-autoop.po +0 -0
- data/po/fi/rbot-autorejoin.po +20 -0
- data/po/fi/rbot-azgame.po +194 -0
- data/po/fi/rbot-bans.po +0 -0
- data/po/fi/rbot-bash.po +32 -0
- data/po/fi/rbot-botsnack.po +0 -0
- data/po/fi/rbot-cal.po +20 -0
- data/po/fi/rbot-chanserv.po +0 -0
- data/po/fi/rbot-chucknorris.po +0 -0
- data/po/fi/rbot-debugger.po +0 -0
- data/po/fi/rbot-deepthoughts.po +0 -0
- data/po/fi/rbot-delicious.po +0 -0
- data/po/fi/rbot-dice.po +0 -0
- data/po/fi/rbot-dict.po +0 -0
- data/po/fi/rbot-dictclient.po +111 -0
- data/po/fi/rbot-digg.po +0 -0
- data/po/fi/rbot-eightball.po +0 -0
- data/po/fi/rbot-excuse.po +0 -0
- data/po/fi/rbot-factoids.po +107 -0
- data/po/fi/rbot-figlet.po +36 -0
- data/po/fi/rbot-fish.po +0 -0
- data/po/fi/rbot-forecast.po +0 -0
- data/po/fi/rbot-fortune.po +0 -0
- data/po/fi/rbot-freshmeat.po +0 -0
- data/po/fi/rbot-geoip.po +0 -0
- data/po/fi/rbot-googlefight.po +24 -0
- data/po/fi/rbot-grouphug.po +35 -0
- data/po/fi/rbot-hangman.po +121 -0
- data/po/fi/rbot-hl2.po +0 -0
- data/po/fi/rbot-host.po +20 -0
- data/po/fi/rbot-imdb.po +0 -0
- data/po/fi/rbot-insult.po +0 -0
- data/po/fi/rbot-iplookup.po +0 -0
- data/po/fi/rbot-karma.po +0 -0
- data/po/fi/rbot-keywords.po +24 -0
- data/po/fi/rbot-lart.po +0 -0
- data/po/fi/rbot-lastfm.po +377 -0
- data/po/fi/rbot-linkbot.po +0 -0
- data/po/fi/rbot-markov.po +91 -0
- data/po/fi/rbot-math.po +0 -0
- data/po/fi/rbot-modes.po +0 -0
- data/po/fi/rbot-nickrecover.po +36 -0
- data/po/fi/rbot-nickserv.po +104 -0
- data/po/fi/rbot-nslookup.po +0 -0
- data/po/fi/rbot-quakeauth.po +0 -0
- data/po/fi/rbot-quiz.po +0 -0
- data/po/fi/rbot-quotes.po +108 -0
- data/po/fi/rbot-reaction.po +0 -0
- data/po/fi/rbot-remind.po +0 -0
- data/po/fi/rbot-remotectl.po +0 -0
- data/po/fi/rbot-ri.po +0 -0
- data/po/fi/rbot-roshambo.po +0 -0
- data/po/fi/rbot-rot13.po +0 -0
- data/po/fi/rbot-roulette.po +0 -0
- data/po/fi/rbot-rss.po +24 -0
- data/po/fi/rbot-salut.po +0 -0
- data/po/fi/rbot-script.po +20 -0
- data/po/fi/rbot-search.po +0 -0
- data/po/fi/rbot-seen.po +92 -0
- data/po/fi/rbot-shiritori.po +102 -0
- data/po/fi/rbot-shortenurls.po +0 -0
- data/po/fi/rbot-slashdot.po +0 -0
- data/po/fi/rbot-spell.po +54 -0
- data/po/fi/rbot-theyfightcrime.po +0 -0
- data/po/fi/rbot-threat.po +0 -0
- data/po/fi/rbot-time.po +0 -0
- data/po/fi/rbot-topic.po +0 -0
- data/po/fi/rbot-translator.po +77 -0
- data/po/fi/rbot-tube.po +0 -0
- data/po/fi/rbot-twitter.po +24 -0
- data/po/fi/rbot-uno.po +529 -0
- data/po/fi/rbot-urban.po +0 -0
- data/po/fi/rbot-url.po +0 -0
- data/po/fi/rbot-usermodes.po +0 -0
- data/po/fi/rbot-wall.po +32 -0
- data/po/fi/rbot-weather.po +0 -0
- data/po/fi/rbot-wheelfortune.po +205 -0
- data/po/fi/rbot-wow.po +0 -0
- data/po/fi/rbot-wserver.po +0 -0
- data/po/fi/rbot-youtube.po +58 -0
- data/po/fi/rbot.po +1152 -0
- data/po/fr/rbot-autorejoin.po +3 -0
- data/po/fr/rbot-azgame.po +51 -43
- data/po/fr/rbot-bash.po +15 -0
- data/po/fr/rbot-dictclient.po +20 -20
- data/po/fr/rbot-factoids.po +9 -9
- data/po/fr/rbot-geoip.po +0 -0
- data/po/fr/rbot-googlefight.po +24 -0
- data/po/fr/rbot-grouphug.po +4 -4
- data/po/fr/rbot-hangman.po +114 -0
- data/po/fr/rbot-keywords.po +3 -3
- data/po/fr/rbot-lastfm.po +268 -70
- data/po/fr/rbot-markov.po +74 -2
- data/po/fr/rbot-quotes.po +21 -21
- data/po/fr/rbot-rss.po +6 -2
- data/po/fr/rbot-script.po +3 -0
- data/po/fr/rbot-seen.po +72 -0
- data/po/fr/rbot-spell.po +2 -2
- data/po/fr/rbot-translator.po +13 -13
- data/po/fr/rbot-twitter.po +3 -3
- data/po/fr/rbot-uno.po +132 -114
- data/po/fr/rbot-wall.po +8 -9
- data/po/fr/rbot-wheelfortune.po +41 -41
- data/po/fr/rbot.po +268 -197
- data/po/it/rbot-autorejoin.po +3 -0
- data/po/it/rbot-azgame.po +50 -42
- data/po/it/rbot-bash.po +15 -0
- data/po/it/rbot-dictclient.po +20 -20
- data/po/it/rbot-factoids.po +9 -9
- data/po/it/rbot-geoip.po +0 -0
- data/po/it/rbot-googlefight.po +24 -0
- data/po/it/rbot-grouphug.po +4 -4
- data/po/it/rbot-hangman.po +114 -0
- data/po/it/rbot-keywords.po +3 -3
- data/po/it/rbot-lastfm.po +268 -70
- data/po/it/rbot-markov.po +75 -3
- data/po/it/rbot-quotes.po +21 -21
- data/po/it/rbot-rss.po +7 -3
- data/po/it/rbot-script.po +19 -0
- data/po/it/rbot-seen.po +72 -0
- data/po/it/rbot-spell.po +2 -2
- data/po/it/rbot-translator.po +13 -13
- data/po/it/rbot-twitter.po +3 -3
- data/po/it/rbot-uno.po +137 -116
- data/po/it/rbot-wall.po +8 -9
- data/po/it/rbot-wheelfortune.po +41 -41
- data/po/it/rbot.po +265 -208
- data/po/ja/rbot-autorejoin.po +3 -0
- data/po/ja/rbot-azgame.po +51 -43
- data/po/ja/rbot-bash.po +15 -0
- data/po/ja/rbot-dictclient.po +20 -20
- data/po/ja/rbot-factoids.po +9 -9
- data/po/ja/rbot-geoip.po +0 -0
- data/po/ja/rbot-googlefight.po +24 -0
- data/po/ja/rbot-grouphug.po +4 -4
- data/po/ja/rbot-hangman.po +114 -0
- data/po/ja/rbot-keywords.po +3 -3
- data/po/ja/rbot-lastfm.po +268 -70
- data/po/ja/rbot-markov.po +73 -2
- data/po/ja/rbot-quotes.po +21 -21
- data/po/ja/rbot-rss.po +6 -2
- data/po/ja/rbot-script.po +3 -0
- data/po/ja/rbot-seen.po +72 -0
- data/po/ja/rbot-spell.po +2 -2
- data/po/ja/rbot-translator.po +13 -13
- data/po/ja/rbot-twitter.po +3 -3
- data/po/ja/rbot-uno.po +131 -114
- data/po/ja/rbot-wall.po +8 -9
- data/po/ja/rbot-wheelfortune.po +41 -41
- data/po/ja/rbot.po +248 -192
- data/po/rbot-alias.pot +2 -2
- data/po/rbot-autorejoin.pot +21 -0
- data/po/rbot-azgame.pot +51 -43
- data/po/rbot-bash.pot +33 -0
- data/po/rbot-cal.pot +2 -2
- data/po/rbot-dictclient.pot +21 -21
- data/po/rbot-factoids.pot +10 -10
- data/po/rbot-figlet.pot +2 -2
- data/po/rbot-geoip.pot +0 -0
- data/po/rbot-googlefight.pot +25 -0
- data/po/rbot-grouphug.pot +6 -6
- data/po/rbot-hangman.pot +115 -0
- data/po/rbot-host.pot +2 -2
- data/po/rbot-keywords.pot +4 -4
- data/po/rbot-lastfm.pot +270 -72
- data/po/rbot-markov.pot +74 -3
- data/po/rbot-nickrecover.pot +2 -2
- data/po/rbot-nickserv.pot +2 -2
- data/po/rbot-quotes.pot +22 -22
- data/po/rbot-rss.pot +7 -3
- data/po/rbot-script.pot +21 -0
- data/po/rbot-seen.pot +90 -0
- data/po/rbot-shiritori.pot +2 -2
- data/po/rbot-spell.pot +3 -3
- data/po/rbot-translator.pot +14 -14
- data/po/rbot-twitter.pot +4 -4
- data/po/rbot-uno.pot +132 -115
- data/po/rbot-wall.pot +2 -2
- data/po/rbot-wheelfortune.pot +42 -42
- data/po/rbot-youtube.pot +2 -2
- data/po/rbot.pot +249 -193
- data/po/zh_CN/rbot-autorejoin.po +3 -0
- data/po/zh_CN/rbot-azgame.po +50 -42
- data/po/zh_CN/rbot-bash.po +15 -0
- data/po/zh_CN/rbot-dictclient.po +20 -20
- data/po/zh_CN/rbot-factoids.po +9 -9
- data/po/zh_CN/rbot-geoip.po +0 -0
- data/po/zh_CN/rbot-googlefight.po +24 -0
- data/po/zh_CN/rbot-grouphug.po +4 -4
- data/po/zh_CN/rbot-hangman.po +114 -0
- data/po/zh_CN/rbot-keywords.po +3 -3
- data/po/zh_CN/rbot-lastfm.po +268 -70
- data/po/zh_CN/rbot-markov.po +73 -2
- data/po/zh_CN/rbot-quotes.po +21 -21
- data/po/zh_CN/rbot-rss.po +6 -2
- data/po/zh_CN/rbot-script.po +3 -0
- data/po/zh_CN/rbot-seen.po +72 -0
- data/po/zh_CN/rbot-spell.po +2 -2
- data/po/zh_CN/rbot-translator.po +13 -13
- data/po/zh_CN/rbot-twitter.po +3 -3
- data/po/zh_CN/rbot-uno.po +131 -114
- data/po/zh_CN/rbot-wall.po +7 -8
- data/po/zh_CN/rbot-wheelfortune.po +41 -41
- data/po/zh_CN/rbot.po +248 -192
- data/po/zh_TW/rbot-autorejoin.po +3 -0
- data/po/zh_TW/rbot-azgame.po +50 -42
- data/po/zh_TW/rbot-bash.po +15 -0
- data/po/zh_TW/rbot-dictclient.po +20 -20
- data/po/zh_TW/rbot-factoids.po +9 -9
- data/po/zh_TW/rbot-geoip.po +0 -0
- data/po/zh_TW/rbot-googlefight.po +24 -0
- data/po/zh_TW/rbot-grouphug.po +4 -4
- data/po/zh_TW/rbot-hangman.po +114 -0
- data/po/zh_TW/rbot-keywords.po +3 -3
- data/po/zh_TW/rbot-lastfm.po +268 -70
- data/po/zh_TW/rbot-markov.po +73 -2
- data/po/zh_TW/rbot-quotes.po +21 -21
- data/po/zh_TW/rbot-rss.po +6 -2
- data/po/zh_TW/rbot-script.po +3 -0
- data/po/zh_TW/rbot-seen.po +72 -0
- data/po/zh_TW/rbot-spell.po +2 -2
- data/po/zh_TW/rbot-translator.po +13 -13
- data/po/zh_TW/rbot-twitter.po +3 -3
- data/po/zh_TW/rbot-uno.po +131 -114
- data/po/zh_TW/rbot-wall.po +7 -8
- data/po/zh_TW/rbot-wheelfortune.po +41 -41
- data/po/zh_TW/rbot.po +253 -194
- data/setup.rb +4 -4
- metadata +127 -18
- data/README +0 -43
- data/data/rbot/plugins/fish.rb +0 -121
- data/lib/rbot/dbhash.rb +0 -199
data/data/rbot/plugins/salut.rb
CHANGED
@@ -15,12 +15,12 @@
|
|
15
15
|
|
16
16
|
class SalutPlugin < Plugin
|
17
17
|
Config.register Config::BooleanValue.new('salut.all_languages',
|
18
|
-
:default => true,
|
18
|
+
:default => true,
|
19
19
|
:desc => "Check for a salutation in all languages and not just in the one defined by core.language",
|
20
20
|
:on_change => Proc.new {|bot, v| bot.plugins['salut'].reload}
|
21
21
|
)
|
22
22
|
Config.register Config::BooleanValue.new('salut.address_only',
|
23
|
-
:default => true,
|
23
|
+
:default => true,
|
24
24
|
:desc => "When set to true, the bot will only reply to salutations directed at him",
|
25
25
|
:on_change => Proc.new {|bot, v| bot.plugins['salut'].reload}
|
26
26
|
)
|
@@ -113,7 +113,7 @@ class SalutPlugin < Plugin
|
|
113
113
|
return unless salut
|
114
114
|
# If the bot wasn't addressed, we continue only if the match was exact
|
115
115
|
# (apart from space and punctuation) or if @match[:dest] matches too
|
116
|
-
return unless to_me or m.message =~ /^#{@punct}#{salut.first}#{@punct}$/ or m.message =~ @match[salut[1]][:dest]
|
116
|
+
return unless to_me or m.message =~ /^#{@punct}#{salut.first}#{@punct}$/ or m.message =~ @match[salut[1]][:dest]
|
117
117
|
h = Time.new.hour
|
118
118
|
case h
|
119
119
|
when 4...12
|
@@ -158,7 +158,7 @@ class SalutPlugin < Plugin
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
debug "Replying #{choice}"
|
161
|
-
m.
|
161
|
+
m.reply choice, :nick => false, :to => :public
|
162
162
|
end
|
163
163
|
|
164
164
|
def reload
|
@@ -168,7 +168,7 @@ class SalutPlugin < Plugin
|
|
168
168
|
@all_langs = @bot.config['salut.all_languages']
|
169
169
|
if @all_langs
|
170
170
|
# Get all available languages
|
171
|
-
langs = Dir.new(
|
171
|
+
langs = Dir.new(datafile).collect {|f|
|
172
172
|
f =~ /salut-([^.]+)/ ? $1 : nil
|
173
173
|
}.compact
|
174
174
|
langs.each { |lang|
|
@@ -183,11 +183,11 @@ class SalutPlugin < Plugin
|
|
183
183
|
end
|
184
184
|
|
185
185
|
def load_lang(lang)
|
186
|
-
dir =
|
186
|
+
dir = datafile
|
187
187
|
if not File.exist?(dir)
|
188
188
|
Dir.mkdir(dir)
|
189
189
|
end
|
190
|
-
file = "
|
190
|
+
file = File.join dir, "salut-#{lang}"
|
191
191
|
if File.exist?(file)
|
192
192
|
begin
|
193
193
|
salutations = Hash.new
|
@@ -214,7 +214,7 @@ class SalutPlugin < Plugin
|
|
214
214
|
end
|
215
215
|
|
216
216
|
def save_lang(lang, val)
|
217
|
-
fn = "
|
217
|
+
fn = datafile "salut-#{lang}"
|
218
218
|
Utils.safe_save(fn) { |file|
|
219
219
|
file.puts val.to_yaml
|
220
220
|
}
|
data/data/rbot/plugins/script.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# Scripts are little Ruby programs that run in the context of the script
|
13
13
|
# plugin. You can create them directly in an IRC channel, and invoke them just
|
14
|
-
# like normal rbot plugins.
|
14
|
+
# like normal rbot plugins.
|
15
15
|
|
16
16
|
define_structure :Command, :code, :nick, :created, :channel
|
17
17
|
|
@@ -21,7 +21,7 @@ class ScriptPlugin < Plugin
|
|
21
21
|
super
|
22
22
|
if @registry.has_key?(:commands)
|
23
23
|
@commands = @registry[:commands]
|
24
|
-
raise unless @commands
|
24
|
+
raise LoadError, "corrupted script database" unless @commands
|
25
25
|
else
|
26
26
|
@commands = Hash.new
|
27
27
|
end
|
@@ -34,10 +34,15 @@ class ScriptPlugin < Plugin
|
|
34
34
|
|
35
35
|
|
36
36
|
def help( plugin, topic="" )
|
37
|
-
|
37
|
+
case topic
|
38
|
+
when "add"
|
38
39
|
"Scripts are little Ruby programs that run in the context of the script plugin. You can access @bot (class Irc::Bot), m (class Irc::PrivMessage), user (class String, either the first argument, or if missing the sourcenick), and args (class Array, an array of arguments). Example: 'script add greet m.reply( 'Hello ' + user )'. Invoke the script just like a plugin: '<botnick>: greet'."
|
39
|
-
|
40
|
-
"
|
40
|
+
when "allow"
|
41
|
+
"script allow <script> for <user> [where] => allow <user> to run script <script> [where]"
|
42
|
+
when "allow"
|
43
|
+
"script deny <script> for <user> [where] => prevent <user> from running script <script> [where]"
|
44
|
+
else
|
45
|
+
"Create mini plugins on IRC. 'script add <name> <code>' => Create script named <name> with the Ruby program <code>. 'script list' => Show a list of all known scripts. 'script show <name>' => Show the source code for <name>. 'script del <name>' => Delete the script <name>. 'script eval <expr>' => evaluate expression <expr>. 'script echo <expr>' => evaluate and display expression <expr>. See also: add, allow, deny."
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
@@ -48,16 +53,19 @@ class ScriptPlugin < Plugin
|
|
48
53
|
end
|
49
54
|
|
50
55
|
|
51
|
-
def
|
56
|
+
def message( m )
|
52
57
|
name = m.message.split.first
|
53
58
|
|
54
59
|
if m.address? and @commands.has_key?( name )
|
60
|
+
auth_path = "script::run::#{name}".intern
|
61
|
+
return unless @bot.auth.allow?(auth_path, m.source, m.replyto)
|
62
|
+
|
55
63
|
code = @commands[name].code.dup.untaint
|
56
64
|
|
57
65
|
# Convenience variables, can be accessed by scripts:
|
58
66
|
args = m.message.split
|
59
|
-
args.delete_at( 0 )
|
60
|
-
user = args.empty? ? m.sourcenick : args.first
|
67
|
+
args.delete_at( 0 )
|
68
|
+
user = args.empty? ? m.sourcenick : args.first
|
61
69
|
|
62
70
|
Thread.start {
|
63
71
|
# TODO allow different safe levels for different botusers
|
@@ -73,6 +81,26 @@ class ScriptPlugin < Plugin
|
|
73
81
|
end
|
74
82
|
end
|
75
83
|
|
84
|
+
def handle_allow_deny(m, p)
|
85
|
+
name = p[:stuff]
|
86
|
+
if @commands.has_key?( name )
|
87
|
+
@bot.plugins['auth'].auth_allow_deny(m, p.merge(
|
88
|
+
:auth_path => "script::run::#{name}".intern
|
89
|
+
))
|
90
|
+
else
|
91
|
+
m.reply(_("%{stuff} is not a script I know of") % p)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def handle_allow(m, p)
|
96
|
+
handle_allow_deny(m, p.merge(:allow => true))
|
97
|
+
end
|
98
|
+
|
99
|
+
def handle_deny(m, p)
|
100
|
+
handle_allow_deny(m, p.merge(:allow => false))
|
101
|
+
end
|
102
|
+
|
103
|
+
|
76
104
|
|
77
105
|
def handle_eval( m, params )
|
78
106
|
code = params[:code].to_s.dup.untaint
|
@@ -124,7 +152,7 @@ class ScriptPlugin < Plugin
|
|
124
152
|
def handle_add_force( m, params )
|
125
153
|
handle_add( m, params, true )
|
126
154
|
end
|
127
|
-
|
155
|
+
|
128
156
|
|
129
157
|
def handle_del( m, params )
|
130
158
|
name = params[:name]
|
@@ -148,9 +176,9 @@ class ScriptPlugin < Plugin
|
|
148
176
|
page = params[:page].to_i
|
149
177
|
page = [page, 1].max
|
150
178
|
page = [page, num_pages].min
|
151
|
-
str = cmds[(page-1)*cmds_per_page, cmds_per_page].join(', ')
|
179
|
+
str = cmds[(page-1)*cmds_per_page, cmds_per_page].join(', ')
|
152
180
|
|
153
|
-
m.reply "Available scripts (page #{page}/#{num_pages}): #{str}"
|
181
|
+
m.reply "Available scripts (page #{page}/#{num_pages}): #{str}"
|
154
182
|
end
|
155
183
|
|
156
184
|
|
@@ -172,6 +200,7 @@ plugin = ScriptPlugin.new
|
|
172
200
|
plugin.default_auth( 'edit', false )
|
173
201
|
plugin.default_auth( 'eval', false )
|
174
202
|
plugin.default_auth( 'echo', false )
|
203
|
+
plugin.default_auth( 'run', true )
|
175
204
|
|
176
205
|
plugin.map 'script add -f :name *code', :action => 'handle_add_force', :auth_path => 'edit'
|
177
206
|
plugin.map 'script add :name *code', :action => 'handle_add', :auth_path => 'edit'
|
@@ -181,4 +210,12 @@ plugin.map 'script echo *code', :action => 'handle_echo'
|
|
181
210
|
plugin.map 'script list :page', :action => 'handle_list', :defaults => { :page => '1' }
|
182
211
|
plugin.map 'script show :name', :action => 'handle_show'
|
183
212
|
|
213
|
+
plugin.map 'script allow :stuff for :user [*where]',
|
214
|
+
:action => 'handle_allow',
|
215
|
+
:requirements => {:where => /^(?:anywhere|everywhere|[io]n \S+)$/},
|
216
|
+
:auth_path => 'edit'
|
217
|
+
plugin.map 'script deny :stuff for :user [*where]',
|
218
|
+
:action => 'handle_deny',
|
219
|
+
:requirements => {:where => /^(?:anywhere|everywhere|[io]n \S+)$/},
|
220
|
+
:auth_path => 'edit'
|
184
221
|
|
data/data/rbot/plugins/search.rb
CHANGED
@@ -16,11 +16,13 @@
|
|
16
16
|
# for most languages
|
17
17
|
|
18
18
|
GOOGLE_SEARCH = "http://www.google.com/search?oe=UTF-8&q="
|
19
|
-
GOOGLE_WAP_SEARCH = "http://www.google.com/
|
20
|
-
GOOGLE_WAP_LINK = /<a accesskey="(\d)" href=".*?u=(.*?)">(.*?)<\/a>/im
|
21
|
-
|
19
|
+
GOOGLE_WAP_SEARCH = "http://www.google.com/m/search?hl=en&q="
|
20
|
+
# GOOGLE_WAP_LINK = /<a accesskey="(\d)" href=".*?u=(.*?)">(.*?)<\/a>/im
|
21
|
+
GOOGLE_WAP_LINK = /<a href="(?:.*?u=(.*?)|(http:\/\/.*?))">(.*?)<\/a>/im
|
22
|
+
GOOGLE_CALC_RESULT = %r{<img src=/images/calc_img\.gif(?: width=40 height=30 alt="")?>.*?<h2 class=r[^>]*><b>(.+?)</b>}
|
22
23
|
GOOGLE_COUNT_RESULT = %r{<font size=-1>Results <b>1<\/b> - <b>10<\/b> of about <b>(.*)<\/b> for}
|
23
|
-
GOOGLE_DEF_RESULT = %r{<
|
24
|
+
GOOGLE_DEF_RESULT = %r{<a href="([^"]*)"[^>]*>(Web definitions for .*?)<br/>(.*?)<br/>(.*?)\s-\s+<a href}
|
25
|
+
GOOGLE_TIME_RESULT = %r{alt="Clock"></td><td valign=[^>]+>(.+?)<(br|/td)>}
|
24
26
|
|
25
27
|
class SearchPlugin < Plugin
|
26
28
|
Config.register Config::IntegerValue.new('google.hits',
|
@@ -44,6 +46,8 @@ class SearchPlugin < Plugin
|
|
44
46
|
"gcalc <equation> => use the google calculator to find the answer to <equation>"
|
45
47
|
when "gdef"
|
46
48
|
"gdef <term(s)> => use the google define mechanism to find a definition of <term(s)>"
|
49
|
+
when "gtime"
|
50
|
+
"gtime <location> => use the google clock to find the current time at <location>"
|
47
51
|
when "wp"
|
48
52
|
"wp [<code>] <string> => search for <string> on Wikipedia. You can select a national <code> to only search the national Wikipedia"
|
49
53
|
when "unpedia"
|
@@ -55,6 +59,10 @@ class SearchPlugin < Plugin
|
|
55
59
|
|
56
60
|
def google(m, params)
|
57
61
|
what = params[:words].to_s
|
62
|
+
if what.match(/^define:/)
|
63
|
+
return google_define(m, what, params)
|
64
|
+
end
|
65
|
+
|
58
66
|
searchfor = CGI.escape what
|
59
67
|
# This method is also called by other methods to restrict searching to some sites
|
60
68
|
if params[:site]
|
@@ -69,10 +77,11 @@ class SearchPlugin < Plugin
|
|
69
77
|
url = GOOGLE_WAP_SEARCH + site + searchfor
|
70
78
|
|
71
79
|
hits = params[:hits] || @bot.config['google.hits']
|
80
|
+
hits = 1 if params[:lucky]
|
72
81
|
|
73
82
|
first_pars = params[:firstpar] || @bot.config['google.first_par']
|
74
83
|
|
75
|
-
single = (hits == 1 and first_pars == 1)
|
84
|
+
single = params[:lucky] || (hits == 1 and first_pars == 1)
|
76
85
|
|
77
86
|
begin
|
78
87
|
wml = @bot.httputil.get(url)
|
@@ -82,27 +91,42 @@ class SearchPlugin < Plugin
|
|
82
91
|
return
|
83
92
|
end
|
84
93
|
results = wml.scan(GOOGLE_WAP_LINK)
|
94
|
+
|
85
95
|
if results.length == 0
|
86
96
|
m.reply "no results found for #{what}"
|
87
97
|
return
|
88
98
|
end
|
99
|
+
|
89
100
|
single ||= (results.length==1)
|
101
|
+
|
90
102
|
urls = Array.new
|
103
|
+
n = 0
|
91
104
|
results = results[0...hits].map { |res|
|
92
|
-
n
|
93
|
-
t =
|
94
|
-
u = URI.unescape res[1]
|
105
|
+
n += 1
|
106
|
+
t = res[2].ircify_html(:img => "[%{src} %{alt} %{dimensions}]").strip
|
107
|
+
u = URI.unescape(res[0] || res[1])
|
95
108
|
urls.push(u)
|
96
|
-
|
97
|
-
|
109
|
+
"%{n}%{b}%{t}%{b}%{sep}%{u}" % {
|
110
|
+
:n => (single ? "" : "#{n}. "),
|
111
|
+
:sep => (single ? " -- " : ": "),
|
112
|
+
:b => Bold, :t => t, :u => u
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
if params[:lucky]
|
117
|
+
m.reply results.first
|
118
|
+
return
|
119
|
+
end
|
120
|
+
|
121
|
+
result_string = results.join(" | ")
|
98
122
|
|
99
123
|
# If we return a single, full result, change the output to a more compact representation
|
100
124
|
if single
|
101
|
-
m.reply "Result for %s: %s -- %s" % [what,
|
125
|
+
m.reply "Result for %s: %s -- %s" % [what, result_string, Utils.get_first_pars(urls, first_pars)], :overlong => :truncate
|
102
126
|
return
|
103
127
|
end
|
104
128
|
|
105
|
-
m.reply "Results for #{what}: #{
|
129
|
+
m.reply "Results for #{what}: #{result_string}", :split_at => /\s+\|\s+/
|
106
130
|
|
107
131
|
return unless first_pars > 0
|
108
132
|
|
@@ -110,10 +134,43 @@ class SearchPlugin < Plugin
|
|
110
134
|
|
111
135
|
end
|
112
136
|
|
137
|
+
def google_define(m, what, params)
|
138
|
+
begin
|
139
|
+
wml = @bot.httputil.get(GOOGLE_SEARCH + CGI.escape(what))
|
140
|
+
raise unless wml
|
141
|
+
rescue => e
|
142
|
+
m.reply "error googling for #{what}"
|
143
|
+
return
|
144
|
+
end
|
145
|
+
|
146
|
+
begin
|
147
|
+
related_index = wml.index(/Related phrases:/, 0)
|
148
|
+
raise unless related_index
|
149
|
+
defs_index = wml.index(/Definitions of <b>/, related_index)
|
150
|
+
raise unless defs_index
|
151
|
+
defs_end = wml.index(/<input/, defs_index)
|
152
|
+
raise unless defs_end
|
153
|
+
rescue => e
|
154
|
+
m.reply "no results found for #{what}"
|
155
|
+
return
|
156
|
+
end
|
157
|
+
|
158
|
+
related = wml[related_index...defs_index]
|
159
|
+
defs = wml[defs_index...defs_end]
|
160
|
+
|
161
|
+
m.reply defs.ircify_html(:a_href => Underline), :split_at => (Underline + ' ')
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
def lucky(m, params)
|
166
|
+
params.merge!(:lucky => true)
|
167
|
+
google(m, params)
|
168
|
+
end
|
169
|
+
|
113
170
|
def gcalc(m, params)
|
114
171
|
what = params[:words].to_s
|
115
172
|
searchfor = CGI.escape(what)
|
116
|
-
|
173
|
+
|
117
174
|
debug "Getting gcalc thing: #{searchfor.inspect}"
|
118
175
|
url = GOOGLE_SEARCH + searchfor
|
119
176
|
|
@@ -125,24 +182,24 @@ class SearchPlugin < Plugin
|
|
125
182
|
end
|
126
183
|
|
127
184
|
debug "#{html.size} bytes of html recieved"
|
128
|
-
|
185
|
+
|
129
186
|
results = html.scan(GOOGLE_CALC_RESULT)
|
130
187
|
debug "results: #{results.inspect}"
|
131
|
-
|
188
|
+
|
132
189
|
if results.length != 1
|
133
190
|
m.reply "couldn't calculate #{what}"
|
134
191
|
return
|
135
192
|
end
|
136
|
-
|
193
|
+
|
137
194
|
result = results[0][0].ircify_html
|
138
195
|
debug "replying with: #{result.inspect}"
|
139
196
|
m.reply "#{result}"
|
140
197
|
end
|
141
|
-
|
198
|
+
|
142
199
|
def gcount(m, params)
|
143
200
|
what = params[:words].to_s
|
144
201
|
searchfor = CGI.escape(what)
|
145
|
-
|
202
|
+
|
146
203
|
debug "Getting gcount thing: #{searchfor.inspect}"
|
147
204
|
url = GOOGLE_SEARCH + searchfor
|
148
205
|
|
@@ -154,15 +211,15 @@ class SearchPlugin < Plugin
|
|
154
211
|
end
|
155
212
|
|
156
213
|
debug "#{html.size} bytes of html recieved"
|
157
|
-
|
214
|
+
|
158
215
|
results = html.scan(GOOGLE_COUNT_RESULT)
|
159
216
|
debug "results: #{results.inspect}"
|
160
|
-
|
217
|
+
|
161
218
|
if results.length != 1
|
162
219
|
m.reply "couldn't count #{what}"
|
163
220
|
return
|
164
221
|
end
|
165
|
-
|
222
|
+
|
166
223
|
result = results[0][0].ircify_html
|
167
224
|
debug "replying with: #{result.inspect}"
|
168
225
|
m.reply "total results: #{result}"
|
@@ -172,7 +229,7 @@ class SearchPlugin < Plugin
|
|
172
229
|
def gdef(m, params)
|
173
230
|
what = params[:words].to_s
|
174
231
|
searchfor = CGI.escape("define " + what)
|
175
|
-
|
232
|
+
|
176
233
|
debug "Getting gdef thing: #{searchfor.inspect}"
|
177
234
|
url = GOOGLE_WAP_SEARCH + searchfor
|
178
235
|
|
@@ -186,16 +243,27 @@ class SearchPlugin < Plugin
|
|
186
243
|
debug html
|
187
244
|
results = html.scan(GOOGLE_DEF_RESULT)
|
188
245
|
debug "results: #{results.inspect}"
|
189
|
-
|
246
|
+
|
190
247
|
if results.length != 1
|
191
248
|
m.reply "couldn't find a definition for #{what} on Google"
|
192
249
|
return
|
193
250
|
end
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
251
|
+
|
252
|
+
gdef_link = "http://www.google.com" + CGI.unescapeHTML(results[0][0]) # could be used to extract all defs
|
253
|
+
head = results[0][1].ircify_html
|
254
|
+
text = results[0][2].ircify_html
|
255
|
+
link = results[0][3]
|
198
256
|
m.reply "#{head} -- #{link}\n#{text}"
|
257
|
+
|
258
|
+
### gdef_link could be used for something like
|
259
|
+
# html_defs = @bot.httputil.get(gdef_link)
|
260
|
+
# related_index = html_defs.index(/Related phrases:/, 0)
|
261
|
+
# defs_index = html_defs.index(/Definitions of <b>/, related_index)
|
262
|
+
|
263
|
+
# related = html_defs[related_index..defs_index]
|
264
|
+
# defs = html_defs[defs_index..-1]
|
265
|
+
|
266
|
+
# m.reply defs.gsub(' <br/>','<li>').ircify_html
|
199
267
|
end
|
200
268
|
|
201
269
|
def wikipedia(m, params)
|
@@ -218,15 +286,43 @@ class SearchPlugin < Plugin
|
|
218
286
|
params[:firstpar] = @bot.config['wikipedia.first_par']
|
219
287
|
return google(m, params)
|
220
288
|
end
|
289
|
+
|
290
|
+
def gtime(m, params)
|
291
|
+
where = params[:words].to_s
|
292
|
+
where.sub!(/^\s*in\s*/, '')
|
293
|
+
searchfor = CGI.escape("time in " + where)
|
294
|
+
url = GOOGLE_SEARCH + searchfor
|
295
|
+
|
296
|
+
begin
|
297
|
+
html = @bot.httputil.get(url)
|
298
|
+
rescue => e
|
299
|
+
m.reply "Error googletiming #{where}"
|
300
|
+
return
|
301
|
+
end
|
302
|
+
|
303
|
+
debug html
|
304
|
+
results = html.scan(GOOGLE_TIME_RESULT)
|
305
|
+
debug "results: #{results.inspect}"
|
306
|
+
|
307
|
+
if results.length != 1
|
308
|
+
m.reply "Couldn't find the time for #{where} on Google"
|
309
|
+
return
|
310
|
+
end
|
311
|
+
|
312
|
+
time = results[0][0].ircify_html
|
313
|
+
m.reply "#{time}"
|
314
|
+
end
|
221
315
|
end
|
222
316
|
|
223
317
|
plugin = SearchPlugin.new
|
224
318
|
|
225
319
|
plugin.map "search *words", :action => 'google', :threaded => true
|
226
320
|
plugin.map "google *words", :action => 'google', :threaded => true
|
227
|
-
plugin.map "
|
321
|
+
plugin.map "lucky *words", :action => 'lucky', :threaded => true
|
322
|
+
plugin.map "gcount *words", :action => 'gcount', :threaded => true
|
228
323
|
plugin.map "gcalc *words", :action => 'gcalc', :threaded => true
|
229
324
|
plugin.map "gdef *words", :action => 'gdef', :threaded => true
|
325
|
+
plugin.map "gtime *words", :action => 'gtime', :threaded => true
|
230
326
|
plugin.map "wp :lang *words", :action => 'wikipedia', :requirements => { :lang => /^\w\w\w?$/ }, :threaded => true
|
231
327
|
plugin.map "wp *words", :action => 'wikipedia', :threaded => true
|
232
328
|
plugin.map "unpedia *words", :action => 'unpedia', :threaded => true
|