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/README
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
= rbot - The Ruby IRC bot
|
2
|
-
|
3
|
-
rbot is a ruby IRC bot. Think of him as a ruby bot framework with a highly
|
4
|
-
modular design based around plugins.
|
5
|
-
|
6
|
-
== rbot features
|
7
|
-
|
8
|
-
* Runtime configuration via irc chat
|
9
|
-
* User authentication and access levels for using different bot features
|
10
|
-
* Built in infobot-style keywords.
|
11
|
-
* Support for underlying fact database (infobot fact files), which can
|
12
|
-
be overridden or supplemented by runtime keyword controls
|
13
|
-
* Multi-language support - comes with english, dutch, german, french, italian
|
14
|
-
japanese, chinese and russian definitions so far - more translations welcome
|
15
|
-
* Powerful plugin architecture, comes with plugins for:
|
16
|
-
- DNS queries
|
17
|
-
- Babelfish translation
|
18
|
-
- Google searching
|
19
|
-
- Excuse generation
|
20
|
-
- Insult generation
|
21
|
-
- Karma
|
22
|
-
- Checking the weather
|
23
|
-
- Querying slashdot
|
24
|
-
- Doing Math
|
25
|
-
- Per-channel quote storage, searching and retrieval
|
26
|
-
- Reminders
|
27
|
-
- rot13 translation
|
28
|
-
- Check the spelling of a word
|
29
|
-
- Webserver Server: header examination
|
30
|
-
- RPG dice rolling
|
31
|
-
- larting people
|
32
|
-
- conversation stats
|
33
|
-
- more...
|
34
|
-
|
35
|
-
Thanks are owed to the infobot developers - several of rbot's features are
|
36
|
-
inspired by infobot and so are some of the default plugins. Thanks are also
|
37
|
-
owed to RADKade1, as rbot's quote plugin is a direct reimplementation of his
|
38
|
-
"quotesaq" - simply because it's a great quote interface.
|
39
|
-
|
40
|
-
Mainly, rbot's fun to play with, although the plugin architecture can be used
|
41
|
-
to write very useful modules
|
42
|
-
|
43
|
-
|
data/data/rbot/plugins/fish.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
class BabelPlugin < Plugin
|
2
|
-
LANGS = %w{en fr de it pt es nl ru zh zt el ja ko}
|
3
|
-
BASEURL = 'http://babelfish.yahoo.com'
|
4
|
-
|
5
|
-
Config.register Config::EnumValue.new('translate.default_from',
|
6
|
-
:values => LANGS, :default => 'en',
|
7
|
-
:desc => "Default language to translate from")
|
8
|
-
Config.register Config::EnumValue.new('translate.default_to',
|
9
|
-
:values => LANGS, :default => 'en',
|
10
|
-
:desc => "Default language to translate to")
|
11
|
-
|
12
|
-
def help(plugin, topic="")
|
13
|
-
case topic
|
14
|
-
when 'cache'
|
15
|
-
"translate cache [view|clear] => view or clear the translate cache contents"
|
16
|
-
else
|
17
|
-
from = @bot.config['translate.default_from']
|
18
|
-
to = @bot.config['translate.default_to']
|
19
|
-
"translate to <lang> <string> => translate from #{from} to <lang>, translate from <lang> <string> => translate to #{to} from <lang>, translate <fromlang> <tolang> <string> => translate from <fromlang> to <tolang>. If <string> is an http url, translates the referenced webpage and returns the 1st content paragraph. Languages: #{LANGS.join(', ')}. Other topics: cache"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def translate(m, params)
|
24
|
-
langs = LANGS
|
25
|
-
trans_from = params[:fromlang] ? params[:fromlang] : @bot.config['translate.default_from']
|
26
|
-
trans_to = params[:tolang] ? params[:tolang] : @bot.config['translate.default_to']
|
27
|
-
trans_text = params[:phrase].to_s
|
28
|
-
|
29
|
-
lang_match = langs.join("|")
|
30
|
-
unless(trans_from =~ /^(#{lang_match})$/ && trans_to =~ /^(#{lang_match})$/)
|
31
|
-
m.reply "invalid language: valid languagess are: #{langs.join(' ')}"
|
32
|
-
return
|
33
|
-
end
|
34
|
-
|
35
|
-
data_text = CGI.escape trans_text
|
36
|
-
trans_pair = "#{trans_from}_#{trans_to}"
|
37
|
-
|
38
|
-
if (trans_text =~ /^http:\/\//) && (URI.parse(trans_text) rescue nil)
|
39
|
-
m.reply 'webpage translation is not currently supported'
|
40
|
-
return
|
41
|
-
# TODO FIXME
|
42
|
-
# url = BASEURL+'/translate_url' +
|
43
|
-
# "?lp=#{trans_pair}&trurl=#{data_text}"
|
44
|
-
#
|
45
|
-
# return Utils.get_first_pars([url], 1, :message => m)
|
46
|
-
end
|
47
|
-
|
48
|
-
data = "lp=#{trans_pair}&doit=done&intl=1&tt=urltext&urltext=#{data_text}"
|
49
|
-
|
50
|
-
# check cache for previous lookups
|
51
|
-
if @registry.has_key?("#{trans_pair}/#{data_text}")
|
52
|
-
m.reply @registry["#{trans_pair}/#{data_text}"]
|
53
|
-
return
|
54
|
-
end
|
55
|
-
|
56
|
-
headers = {
|
57
|
-
"content-type" => "application/x-www-form-urlencoded; charset=utf-8"
|
58
|
-
}
|
59
|
-
|
60
|
-
query = "/translate_txt"
|
61
|
-
|
62
|
-
begin
|
63
|
-
body = @bot.httputil.get(BASEURL+query,
|
64
|
-
:method => :post,
|
65
|
-
:body => data,
|
66
|
-
:headers => headers)
|
67
|
-
rescue Exception => e
|
68
|
-
m.reply "http error: #{e.message}"
|
69
|
-
return
|
70
|
-
end
|
71
|
-
|
72
|
-
case body
|
73
|
-
when nil
|
74
|
-
m.reply "couldn't talk to babelfish :("
|
75
|
-
when /^\s*<div id="result"><div style="[^"]*">(.*?)<\/div><\/div>\s*$/
|
76
|
-
answer = $1
|
77
|
-
# cache the answer
|
78
|
-
if(answer.length > 0)
|
79
|
-
@registry["#{trans_pair}/#{data_text}"] = answer
|
80
|
-
end
|
81
|
-
m.reply answer
|
82
|
-
return
|
83
|
-
when /^\s+<option value="#{trans_pair}"\s+SELECTED>/
|
84
|
-
m.reply "couldn't parse babelfish response html :("
|
85
|
-
else
|
86
|
-
m.reply "babelfish doesn't support translation from #{trans_from} to #{trans_to}"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def cache_mgmt(m, params)
|
91
|
-
cmd = params[:cmd].intern
|
92
|
-
case cmd
|
93
|
-
when :view
|
94
|
-
cache = []
|
95
|
-
@registry.each { |key, val|
|
96
|
-
cache << "%s => %s" % [key, val]
|
97
|
-
}
|
98
|
-
m.reply "translate cache: #{cache.inspect}"
|
99
|
-
when :clear
|
100
|
-
keys = []
|
101
|
-
@registry.each { |key, val|
|
102
|
-
keys << key
|
103
|
-
}
|
104
|
-
keys.each { |key|
|
105
|
-
@registry.delete(key)
|
106
|
-
}
|
107
|
-
cache_mgmt(m, :cmd => 'view')
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
plugin = BabelPlugin.new
|
114
|
-
|
115
|
-
plugin.default_auth('cache', false)
|
116
|
-
|
117
|
-
plugin.map 'translate to :tolang *phrase', :thread => true
|
118
|
-
plugin.map 'translate from :fromlang *phrase', :thread => true
|
119
|
-
plugin.map 'translate cache :cmd', :action => :cache_mgmt, :auth_path => 'cache!', :requirements => { :cmd => /view|clear/ }
|
120
|
-
plugin.map 'translate :fromlang :tolang *phrase', :thread => true
|
121
|
-
|
data/lib/rbot/dbhash.rb
DELETED
@@ -1,199 +0,0 @@
|
|
1
|
-
#-- vim:sw=2:et
|
2
|
-
#++
|
3
|
-
#
|
4
|
-
# :title: Berkeley DB interface
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'bdb'
|
8
|
-
rescue LoadError
|
9
|
-
fatal "rbot couldn't load the bdb module, perhaps you need to install it? try: http://www.ruby-lang.org/en/raa-list.rhtml?name=bdb"
|
10
|
-
rescue Exception => e
|
11
|
-
fatal "rbot couldn't load the bdb module: #{e.pretty_inspect}"
|
12
|
-
end
|
13
|
-
|
14
|
-
if not defined? BDB
|
15
|
-
exit 2
|
16
|
-
end
|
17
|
-
|
18
|
-
if BDB::VERSION_MAJOR < 4
|
19
|
-
fatal "Your bdb (Berkeley DB) version #{BDB::VERSION} is too old!"
|
20
|
-
fatal "rbot will only run with bdb version 4 or higher, please upgrade."
|
21
|
-
fatal "For maximum reliability, upgrade to version 4.2 or higher."
|
22
|
-
raise BDB::Fatal, BDB::VERSION + " is too old"
|
23
|
-
end
|
24
|
-
|
25
|
-
if BDB::VERSION_MAJOR == 4 and BDB::VERSION_MINOR < 2
|
26
|
-
warning "Your bdb (Berkeley DB) version #{BDB::VERSION} may not be reliable."
|
27
|
-
warning "If possible, try upgrade version 4.2 or later."
|
28
|
-
end
|
29
|
-
|
30
|
-
# make BTree lookups case insensitive
|
31
|
-
module BDB
|
32
|
-
class CIBtree < Btree
|
33
|
-
def bdb_bt_compare(a, b)
|
34
|
-
if a == nil || b == nil
|
35
|
-
warning "CIBTree: comparing #{a.inspect} (#{self[a].inspect}) with #{b.inspect} (#{self[b].inspect})"
|
36
|
-
end
|
37
|
-
(a||'').downcase <=> (b||'').downcase
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
module Irc
|
43
|
-
|
44
|
-
# DBHash is for tying a hash to disk (using bdb).
|
45
|
-
# Call it with an identifier, for example "mydata". It'll look for
|
46
|
-
# mydata.db, if it exists, it will load and reference that db.
|
47
|
-
# Otherwise it'll create and empty db called mydata.db
|
48
|
-
class DBHash
|
49
|
-
|
50
|
-
# absfilename:: use +key+ as an actual filename, don't prepend the bot's
|
51
|
-
# config path and don't append ".db"
|
52
|
-
def initialize(bot, key, absfilename=false)
|
53
|
-
@bot = bot
|
54
|
-
@key = key
|
55
|
-
if absfilename && File.exist?(key)
|
56
|
-
# db already exists, use it
|
57
|
-
@db = DBHash.open_db(key)
|
58
|
-
elsif File.exist?(@bot.botclass + "/#{key}.db")
|
59
|
-
# db already exists, use it
|
60
|
-
@db = DBHash.open_db(@bot.botclass + "/#{key}.db")
|
61
|
-
elsif absfilename
|
62
|
-
# create empty db
|
63
|
-
@db = DBHash.create_db(key)
|
64
|
-
else
|
65
|
-
# create empty db
|
66
|
-
@db = DBHash.create_db(@bot.botclass + "/#{key}.db")
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def method_missing(method, *args, &block)
|
71
|
-
return @db.send(method, *args, &block)
|
72
|
-
end
|
73
|
-
|
74
|
-
def DBHash.create_db(name)
|
75
|
-
debug "DBHash: creating empty db #{name}"
|
76
|
-
return BDB::Hash.open(name, nil,
|
77
|
-
BDB::CREATE | BDB::EXCL, 0600)
|
78
|
-
end
|
79
|
-
|
80
|
-
def DBHash.open_db(name)
|
81
|
-
debug "DBHash: opening existing db #{name}"
|
82
|
-
return BDB::Hash.open(name, nil, "r+", 0600)
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
# DBTree is a BTree equivalent of DBHash, with case insensitive lookups.
|
89
|
-
class DBTree
|
90
|
-
@@env=nil
|
91
|
-
# TODO: make this customizable
|
92
|
-
# Note that it must be at least four times lg_bsize
|
93
|
-
@@lg_max = 8*1024*1024
|
94
|
-
# absfilename:: use +key+ as an actual filename, don't prepend the bot's
|
95
|
-
# config path and don't append ".db"
|
96
|
-
def initialize(bot, key, absfilename=false)
|
97
|
-
@bot = bot
|
98
|
-
@key = key
|
99
|
-
if @@env.nil?
|
100
|
-
begin
|
101
|
-
@@env = BDB::Env.open("#{@bot.botclass}", BDB::INIT_TRANSACTION | BDB::CREATE | BDB::RECOVER, "set_lg_max" => @@lg_max)
|
102
|
-
debug "DBTree: environment opened with max log size #{@@env.conf['lg_max']}"
|
103
|
-
rescue => e
|
104
|
-
debug "DBTree: failed to open environment: #{e.pretty_inspect}. Retrying ..."
|
105
|
-
@@env = BDB::Env.open("#{@bot.botclass}", BDB::INIT_TRANSACTION | BDB::CREATE | BDB::RECOVER)
|
106
|
-
end
|
107
|
-
#@@env = BDB::Env.open("#{@bot.botclass}", BDB::CREATE | BDB::INIT_MPOOL | BDB::RECOVER)
|
108
|
-
end
|
109
|
-
|
110
|
-
if absfilename && File.exist?(key)
|
111
|
-
# db already exists, use it
|
112
|
-
@db = DBTree.open_db(key)
|
113
|
-
elsif absfilename
|
114
|
-
# create empty db
|
115
|
-
@db = DBTree.create_db(key)
|
116
|
-
elsif File.exist?(@bot.botclass + "/#{key}.db")
|
117
|
-
# db already exists, use it
|
118
|
-
@db = DBTree.open_db(@bot.botclass + "/#{key}.db")
|
119
|
-
else
|
120
|
-
# create empty db
|
121
|
-
@db = DBTree.create_db(@bot.botclass + "/#{key}.db")
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def method_missing(method, *args, &block)
|
126
|
-
return @db.send(method, *args, &block)
|
127
|
-
end
|
128
|
-
|
129
|
-
def DBTree.create_db(name)
|
130
|
-
debug "DBTree: creating empty db #{name}"
|
131
|
-
return @@env.open_db(BDB::CIBtree, name, nil, BDB::CREATE | BDB::EXCL, 0600)
|
132
|
-
end
|
133
|
-
|
134
|
-
def DBTree.open_db(name)
|
135
|
-
debug "DBTree: opening existing db #{name}"
|
136
|
-
return @@env.open_db(BDB::CIBtree, name, nil, "r+", 0600)
|
137
|
-
end
|
138
|
-
|
139
|
-
def DBTree.cleanup_logs()
|
140
|
-
begin
|
141
|
-
debug "DBTree: checkpointing ..."
|
142
|
-
@@env.checkpoint
|
143
|
-
rescue Exception => e
|
144
|
-
debug "Failed: #{e.pretty_inspect}"
|
145
|
-
end
|
146
|
-
begin
|
147
|
-
debug "DBTree: flushing log ..."
|
148
|
-
@@env.log_flush
|
149
|
-
logs = @@env.log_archive(BDB::ARCH_ABS)
|
150
|
-
debug "DBTree: deleting archivable logs: #{logs.join(', ')}."
|
151
|
-
logs.each { |log|
|
152
|
-
File.delete(log)
|
153
|
-
}
|
154
|
-
rescue Exception => e
|
155
|
-
debug "Failed: #{e.pretty_inspect}"
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def DBTree.stats()
|
160
|
-
begin
|
161
|
-
debug "General stats:"
|
162
|
-
debug @@env.stat
|
163
|
-
debug "Lock stats:"
|
164
|
-
debug @@env.lock_stat
|
165
|
-
debug "Log stats:"
|
166
|
-
debug @@env.log_stat
|
167
|
-
debug "Txn stats:"
|
168
|
-
debug @@env.txn_stat
|
169
|
-
rescue
|
170
|
-
debug "Couldn't dump stats"
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
def DBTree.cleanup_env()
|
175
|
-
begin
|
176
|
-
debug "DBTree: checking transactions ..."
|
177
|
-
has_active_txn = @@env.txn_stat["st_nactive"] > 0
|
178
|
-
if has_active_txn
|
179
|
-
warning "DBTree: not all transactions completed!"
|
180
|
-
end
|
181
|
-
DBTree.cleanup_logs
|
182
|
-
debug "DBTree: closing environment #{@@env}"
|
183
|
-
path = @@env.home
|
184
|
-
@@env.close
|
185
|
-
@@env = nil
|
186
|
-
if has_active_txn
|
187
|
-
debug "DBTree: keeping file because of incomplete transactions"
|
188
|
-
else
|
189
|
-
debug "DBTree: cleaning up environment in #{path}"
|
190
|
-
BDB::Env.remove("#{path}")
|
191
|
-
end
|
192
|
-
rescue Exception => e
|
193
|
-
error "failed to clean up environment: #{e.pretty_inspect}"
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
end
|
198
|
-
|
199
|
-
end
|