rbot 0.9.10 → 0.9.12
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +22 -4
- data/COPYING +5 -18
- data/ChangeLog +396 -0
- data/README +23 -25
- data/REQUIREMENTS +58 -12
- data/Rakefile +215 -0
- data/bin/rbot +47 -25
- data/bin/rbot-remote +76 -0
- data/data/rbot/languages/french.lang +5 -5
- data/data/rbot/languages/german.lang +4 -4
- data/data/rbot/languages/italian.lang +53 -0
- data/data/rbot/languages/japanese.lang +43 -0
- data/data/rbot/languages/russian.lang +60 -60
- data/data/rbot/languages/traditional_chinese.lang +75 -0
- data/data/rbot/plugins/alias.rb +192 -0
- data/data/rbot/plugins/autoop.rb +74 -37
- data/data/rbot/plugins/autorejoin.rb +15 -5
- data/data/rbot/plugins/bans.rb +454 -150
- data/data/rbot/plugins/bash.rb +173 -31
- data/data/rbot/plugins/botsnack.rb +37 -0
- data/data/rbot/plugins/cal.rb +11 -2
- data/data/rbot/plugins/chanserv.rb +132 -0
- data/data/rbot/plugins/chucknorris.rb +2 -2
- data/data/rbot/plugins/chucknorris.yml.gz +0 -0
- data/data/rbot/plugins/debugger.rb +136 -0
- data/data/rbot/plugins/deepthoughts.rb +89 -95
- data/data/rbot/plugins/delicious.rb +109 -0
- data/data/rbot/plugins/dice.rb +77 -25
- data/data/rbot/plugins/dict.rb +243 -0
- data/data/rbot/plugins/dictclient.rb +211 -0
- data/data/rbot/plugins/digg.rb +2 -2
- data/data/rbot/plugins/excuse.rb +4 -4
- data/data/rbot/plugins/factoids.rb +506 -0
- data/data/rbot/plugins/figlet.rb +127 -18
- data/data/rbot/plugins/fish.rb +93 -33
- data/data/rbot/plugins/forecast.rb +40 -27
- data/data/rbot/plugins/fortune.rb +86 -11
- data/data/rbot/plugins/freshmeat.rb +46 -12
- data/data/rbot/plugins/games/azgame.rb +565 -0
- data/data/rbot/plugins/games/quiz.rb +961 -0
- data/data/rbot/plugins/games/roshambo.rb +62 -0
- data/data/rbot/plugins/{roulette.rb → games/roulette.rb} +58 -8
- data/data/rbot/plugins/games/shiritori.rb +485 -0
- data/data/rbot/plugins/games/uno.rb +1205 -0
- data/data/rbot/plugins/games/wheelfortune.rb +615 -0
- data/data/rbot/plugins/grouphug.rb +76 -22
- data/data/rbot/plugins/hl2.rb +97 -0
- data/data/rbot/plugins/host.rb +10 -1
- data/data/rbot/plugins/httpd.rb.disabled +1 -0
- data/data/rbot/plugins/imdb.rb +511 -47
- data/data/rbot/plugins/insult.rb +32 -37
- data/data/rbot/plugins/iplookup.rb +224 -224
- data/data/rbot/plugins/karma.rb +45 -21
- data/data/rbot/plugins/keywords.rb +258 -160
- data/data/rbot/plugins/lart.rb +126 -95
- data/data/rbot/plugins/lastfm.rb +421 -12
- data/data/rbot/plugins/linkbot.rb +75 -0
- data/data/rbot/plugins/markov.rb +103 -46
- data/data/rbot/plugins/math.rb +6 -5
- data/data/rbot/plugins/modes.rb +114 -0
- data/data/rbot/plugins/nickrecover.rb +97 -0
- data/data/rbot/plugins/nickserv.rb +111 -48
- data/data/rbot/plugins/nslookup.rb +15 -19
- data/data/rbot/plugins/plugin.header +11 -0
- data/data/rbot/plugins/quakeauth.rb +74 -11
- data/data/rbot/plugins/quotes.rb +189 -233
- data/data/rbot/plugins/reaction.rb +415 -0
- data/data/rbot/plugins/remind.rb +11 -15
- data/data/rbot/plugins/remotectl.rb +29 -0
- data/data/rbot/plugins/ri.rb +74 -0
- data/data/rbot/plugins/rot13.rb +16 -1
- data/data/rbot/plugins/rss.rb +1219 -585
- data/data/rbot/plugins/salut.rb +226 -0
- data/data/rbot/plugins/script.rb +184 -0
- data/data/rbot/plugins/search.rb +233 -0
- data/data/rbot/plugins/seen.rb +44 -40
- data/data/rbot/plugins/shortenurls.rb +93 -0
- data/data/rbot/plugins/slashdot.rb +49 -11
- data/data/rbot/plugins/spell.rb +37 -27
- data/data/rbot/plugins/theyfightcrime.rb +36 -39
- data/data/rbot/plugins/threat.rb +25 -22
- data/data/rbot/plugins/time.rb +135 -0
- data/data/rbot/plugins/topic.rb +107 -50
- data/data/rbot/plugins/translator.rb +360 -0
- data/data/rbot/plugins/tube.rb +28 -40
- data/data/rbot/plugins/twitter.rb +187 -0
- data/data/rbot/plugins/urban.rb +62 -53
- data/data/rbot/plugins/url.rb +193 -409
- data/data/rbot/plugins/usermodes.rb +26 -0
- data/data/rbot/plugins/wall.rb +60 -0
- data/data/rbot/plugins/weather.rb +254 -598
- data/data/rbot/plugins/wow.rb +41 -37
- data/data/rbot/plugins/wserver.rb +17 -25
- data/data/rbot/plugins/youtube.rb +237 -0
- data/data/rbot/templates/lart/{larts → larts-english} +0 -0
- data/data/rbot/templates/lart/larts-italian +25 -0
- data/data/rbot/templates/lart/larts-japanese +10 -0
- data/data/rbot/templates/lart/{praises → praises-english} +0 -0
- data/data/rbot/templates/lart/praises-italian +4 -0
- data/data/rbot/templates/lart/praises-japanese +3 -0
- data/data/rbot/templates/quiz/win_messages +11 -0
- data/data/rbot/templates/salut/salut-english +40 -0
- data/data/rbot/templates/salut/salut-french +29 -0
- data/data/rbot/templates/salut/salut-italian +51 -0
- data/data/rbot/templates/salut/salut-japanese +31 -0
- data/lib/rbot/botuser.rb +940 -0
- data/lib/rbot/config-compat.rb +23 -0
- data/lib/rbot/config.rb +211 -276
- data/lib/rbot/core/auth.rb +1063 -0
- data/lib/rbot/core/basics.rb +214 -0
- data/lib/rbot/core/config.rb +330 -0
- data/lib/rbot/core/filters_ui.rb +64 -0
- data/lib/rbot/core/irclog.rb +292 -0
- data/lib/rbot/core/remote.rb +401 -0
- data/lib/rbot/core/unicode.rb +91 -0
- data/lib/rbot/core/userdata.rb +200 -0
- data/lib/rbot/core/utils/extends.rb +444 -0
- data/lib/rbot/core/utils/filters.rb +154 -0
- data/lib/rbot/core/utils/httputil.rb +689 -0
- data/lib/rbot/core/utils/utils.rb +717 -0
- data/lib/rbot/dbhash.rb +30 -9
- data/lib/rbot/irc.rb +1966 -0
- data/lib/rbot/ircbot.rb +816 -675
- data/lib/rbot/ircsocket.rb +246 -232
- data/lib/rbot/language.rb +86 -8
- data/lib/rbot/load-gettext.rb +154 -0
- data/lib/rbot/maskdb.rb +162 -0
- data/lib/rbot/message.rb +392 -65
- data/lib/rbot/messagemapper.rb +438 -94
- data/lib/rbot/pkgconfig.rb +6 -0
- data/lib/rbot/plugins.rb +713 -172
- data/lib/rbot/post-config.rb +1 -0
- data/lib/rbot/rbotconfig.rb +31 -12
- data/lib/rbot/registry.rb +79 -48
- data/lib/rbot/rfc2812.rb +927 -519
- data/lib/rbot/timer.rb +232 -167
- data/po/en_US/rbot-alias.po +82 -0
- data/po/en_US/rbot-autoop.po +0 -0
- data/po/en_US/rbot-autorejoin.po +0 -0
- data/po/en_US/rbot-azgame.po +200 -0
- data/po/en_US/rbot-bans.po +0 -0
- data/po/en_US/rbot-bash.po +0 -0
- data/po/en_US/rbot-botsnack.po +0 -0
- data/po/en_US/rbot-cal.po +3 -0
- data/po/en_US/rbot-chanserv.po +0 -0
- data/po/en_US/rbot-chucknorris.po +0 -0
- data/po/en_US/rbot-debugger.po +0 -0
- data/po/en_US/rbot-deepthoughts.po +0 -0
- data/po/en_US/rbot-delicious.po +0 -0
- data/po/en_US/rbot-dice.po +0 -0
- data/po/en_US/rbot-dict.po +0 -0
- data/po/en_US/rbot-dictclient.po +124 -0
- data/po/en_US/rbot-digg.po +0 -0
- data/po/en_US/rbot-eightball.po +0 -0
- data/po/en_US/rbot-excuse.po +0 -0
- data/po/en_US/rbot-factoids.po +107 -0
- data/po/en_US/rbot-figlet.po +36 -0
- data/po/en_US/rbot-fish.po +0 -0
- data/po/en_US/rbot-forecast.po +0 -0
- data/po/en_US/rbot-fortune.po +0 -0
- data/po/en_US/rbot-freshmeat.po +0 -0
- data/po/en_US/rbot-grouphug.po +18 -0
- data/po/en_US/rbot-hl2.po +0 -0
- data/po/en_US/rbot-host.po +3 -0
- data/po/en_US/rbot-imdb.po +0 -0
- data/po/en_US/rbot-insult.po +0 -0
- data/po/en_US/rbot-iplookup.po +0 -0
- data/po/en_US/rbot-karma.po +0 -0
- data/po/en_US/rbot-keywords.po +24 -0
- data/po/en_US/rbot-lart.po +0 -0
- data/po/en_US/rbot-lastfm.po +172 -0
- data/po/en_US/rbot-linkbot.po +0 -0
- data/po/en_US/rbot-markov.po +20 -0
- data/po/en_US/rbot-math.po +0 -0
- data/po/en_US/rbot-modes.po +0 -0
- data/po/en_US/rbot-nickrecover.po +40 -0
- data/po/en_US/rbot-nickserv.po +104 -0
- data/po/en_US/rbot-nslookup.po +0 -0
- data/po/en_US/rbot-quakeauth.po +0 -0
- data/po/en_US/rbot-quiz.po +0 -0
- data/po/en_US/rbot-quotes.po +108 -0
- data/po/en_US/rbot-reaction.po +0 -0
- data/po/en_US/rbot-remind.po +0 -0
- data/po/en_US/rbot-remotectl.po +0 -0
- data/po/en_US/rbot-ri.po +0 -0
- data/po/en_US/rbot-roshambo.po +0 -0
- data/po/en_US/rbot-rot13.po +0 -0
- data/po/en_US/rbot-roulette.po +0 -0
- data/po/en_US/rbot-rss.po +20 -0
- data/po/en_US/rbot-salut.po +0 -0
- data/po/en_US/rbot-script.po +0 -0
- data/po/en_US/rbot-search.po +0 -0
- data/po/en_US/rbot-seen.po +0 -0
- data/po/en_US/rbot-shiritori.po +113 -0
- data/po/en_US/rbot-shortenurls.po +0 -0
- data/po/en_US/rbot-slashdot.po +0 -0
- data/po/en_US/rbot-spell.po +54 -0
- data/po/en_US/rbot-theyfightcrime.po +0 -0
- data/po/en_US/rbot-threat.po +0 -0
- data/po/en_US/rbot-time.po +0 -0
- data/po/en_US/rbot-topic.po +0 -0
- data/po/en_US/rbot-translator.po +77 -0
- data/po/en_US/rbot-tube.po +0 -0
- data/po/en_US/rbot-twitter.po +24 -0
- data/po/en_US/rbot-uno.po +512 -0
- data/po/en_US/rbot-urban.po +0 -0
- data/po/en_US/rbot-url.po +0 -0
- data/po/en_US/rbot-usermodes.po +0 -0
- data/po/en_US/rbot-wall.po +33 -0
- data/po/en_US/rbot-weather.po +0 -0
- data/po/en_US/rbot-wheelfortune.po +205 -0
- data/po/en_US/rbot-wow.po +0 -0
- data/po/en_US/rbot-wserver.po +0 -0
- data/po/en_US/rbot-youtube.po +58 -0
- data/po/en_US/rbot.po +1097 -0
- data/po/fr/rbot-alias.po +97 -0
- data/po/fr/rbot-autoop.po +0 -0
- data/po/fr/rbot-autorejoin.po +0 -0
- data/po/fr/rbot-azgame.po +204 -0
- data/po/fr/rbot-bans.po +0 -0
- data/po/fr/rbot-bash.po +0 -0
- data/po/fr/rbot-botsnack.po +0 -0
- data/po/fr/rbot-cal.po +3 -0
- data/po/fr/rbot-chanserv.po +0 -0
- data/po/fr/rbot-chucknorris.po +0 -0
- data/po/fr/rbot-debugger.po +0 -0
- data/po/fr/rbot-deepthoughts.po +0 -0
- data/po/fr/rbot-delicious.po +0 -0
- data/po/fr/rbot-dice.po +0 -0
- data/po/fr/rbot-dict.po +0 -0
- data/po/fr/rbot-dictclient.po +134 -0
- data/po/fr/rbot-digg.po +0 -0
- data/po/fr/rbot-eightball.po +0 -0
- data/po/fr/rbot-excuse.po +0 -0
- data/po/fr/rbot-factoids.po +111 -0
- data/po/fr/rbot-figlet.po +37 -0
- data/po/fr/rbot-fish.po +0 -0
- data/po/fr/rbot-forecast.po +0 -0
- data/po/fr/rbot-fortune.po +0 -0
- data/po/fr/rbot-freshmeat.po +0 -0
- data/po/fr/rbot-grouphug.po +18 -0
- data/po/fr/rbot-hl2.po +0 -0
- data/po/fr/rbot-host.po +3 -0
- data/po/fr/rbot-imdb.po +0 -0
- data/po/fr/rbot-insult.po +0 -0
- data/po/fr/rbot-iplookup.po +0 -0
- data/po/fr/rbot-karma.po +0 -0
- data/po/fr/rbot-keywords.po +24 -0
- data/po/fr/rbot-lart.po +0 -0
- data/po/fr/rbot-lastfm.po +172 -0
- data/po/fr/rbot-linkbot.po +0 -0
- data/po/fr/rbot-markov.po +20 -0
- data/po/fr/rbot-math.po +0 -0
- data/po/fr/rbot-modes.po +0 -0
- data/po/fr/rbot-nickrecover.po +36 -0
- data/po/fr/rbot-nickserv.po +116 -0
- data/po/fr/rbot-nslookup.po +0 -0
- data/po/fr/rbot-quakeauth.po +0 -0
- data/po/fr/rbot-quiz.po +0 -0
- data/po/fr/rbot-quotes.po +138 -0
- data/po/fr/rbot-reaction.po +0 -0
- data/po/fr/rbot-remind.po +0 -0
- data/po/fr/rbot-remotectl.po +0 -0
- data/po/fr/rbot-ri.po +0 -0
- data/po/fr/rbot-roshambo.po +0 -0
- data/po/fr/rbot-rot13.po +0 -0
- data/po/fr/rbot-roulette.po +0 -0
- data/po/fr/rbot-rss.po +20 -0
- data/po/fr/rbot-salut.po +0 -0
- data/po/fr/rbot-script.po +0 -0
- data/po/fr/rbot-search.po +0 -0
- data/po/fr/rbot-seen.po +0 -0
- data/po/fr/rbot-shiritori.po +119 -0
- data/po/fr/rbot-shortenurls.po +0 -0
- data/po/fr/rbot-slashdot.po +0 -0
- data/po/fr/rbot-spell.po +56 -0
- data/po/fr/rbot-theyfightcrime.po +0 -0
- data/po/fr/rbot-threat.po +0 -0
- data/po/fr/rbot-time.po +0 -0
- data/po/fr/rbot-topic.po +0 -0
- data/po/fr/rbot-translator.po +90 -0
- data/po/fr/rbot-tube.po +0 -0
- data/po/fr/rbot-twitter.po +24 -0
- data/po/fr/rbot-uno.po +521 -0
- data/po/fr/rbot-urban.po +0 -0
- data/po/fr/rbot-url.po +0 -0
- data/po/fr/rbot-usermodes.po +0 -0
- data/po/fr/rbot-wall.po +33 -0
- data/po/fr/rbot-weather.po +0 -0
- data/po/fr/rbot-wheelfortune.po +255 -0
- data/po/fr/rbot-wow.po +0 -0
- data/po/fr/rbot-wserver.po +0 -0
- data/po/fr/rbot-youtube.po +64 -0
- data/po/fr/rbot.po +1133 -0
- data/po/it/rbot-alias.po +82 -0
- data/po/it/rbot-autoop.po +0 -0
- data/po/it/rbot-autorejoin.po +0 -0
- data/po/it/rbot-azgame.po +186 -0
- data/po/it/rbot-bans.po +0 -0
- data/po/it/rbot-bash.po +0 -0
- data/po/it/rbot-botsnack.po +0 -0
- data/po/it/rbot-cal.po +3 -0
- data/po/it/rbot-chanserv.po +0 -0
- data/po/it/rbot-chucknorris.po +0 -0
- data/po/it/rbot-debugger.po +0 -0
- data/po/it/rbot-deepthoughts.po +0 -0
- data/po/it/rbot-delicious.po +0 -0
- data/po/it/rbot-dice.po +0 -0
- data/po/it/rbot-dict.po +0 -0
- data/po/it/rbot-dictclient.po +111 -0
- data/po/it/rbot-digg.po +0 -0
- data/po/it/rbot-eightball.po +0 -0
- data/po/it/rbot-excuse.po +0 -0
- data/po/it/rbot-factoids.po +110 -0
- data/po/it/rbot-figlet.po +36 -0
- data/po/it/rbot-fish.po +0 -0
- data/po/it/rbot-forecast.po +0 -0
- data/po/it/rbot-fortune.po +0 -0
- data/po/it/rbot-freshmeat.po +0 -0
- data/po/it/rbot-grouphug.po +18 -0
- data/po/it/rbot-hl2.po +0 -0
- data/po/it/rbot-host.po +3 -0
- data/po/it/rbot-imdb.po +0 -0
- data/po/it/rbot-insult.po +0 -0
- data/po/it/rbot-iplookup.po +0 -0
- data/po/it/rbot-karma.po +0 -0
- data/po/it/rbot-keywords.po +24 -0
- data/po/it/rbot-lart.po +0 -0
- data/po/it/rbot-lastfm.po +172 -0
- data/po/it/rbot-linkbot.po +0 -0
- data/po/it/rbot-markov.po +20 -0
- data/po/it/rbot-math.po +0 -0
- data/po/it/rbot-modes.po +0 -0
- data/po/it/rbot-nickrecover.po +36 -0
- data/po/it/rbot-nickserv.po +104 -0
- data/po/it/rbot-nslookup.po +0 -0
- data/po/it/rbot-quakeauth.po +0 -0
- data/po/it/rbot-quiz.po +0 -0
- data/po/it/rbot-quotes.po +108 -0
- data/po/it/rbot-reaction.po +0 -0
- data/po/it/rbot-remind.po +0 -0
- data/po/it/rbot-remotectl.po +0 -0
- data/po/it/rbot-ri.po +0 -0
- data/po/it/rbot-roshambo.po +0 -0
- data/po/it/rbot-rot13.po +0 -0
- data/po/it/rbot-roulette.po +0 -0
- data/po/it/rbot-rss.po +20 -0
- data/po/it/rbot-salut.po +0 -0
- data/po/it/rbot-script.po +0 -0
- data/po/it/rbot-search.po +0 -0
- data/po/it/rbot-seen.po +0 -0
- data/po/it/rbot-shiritori.po +102 -0
- data/po/it/rbot-shortenurls.po +0 -0
- data/po/it/rbot-slashdot.po +0 -0
- data/po/it/rbot-spell.po +54 -0
- data/po/it/rbot-theyfightcrime.po +0 -0
- data/po/it/rbot-threat.po +0 -0
- data/po/it/rbot-time.po +0 -0
- data/po/it/rbot-topic.po +0 -0
- data/po/it/rbot-translator.po +77 -0
- data/po/it/rbot-tube.po +0 -0
- data/po/it/rbot-twitter.po +24 -0
- data/po/it/rbot-uno.po +564 -0
- data/po/it/rbot-urban.po +0 -0
- data/po/it/rbot-url.po +0 -0
- data/po/it/rbot-usermodes.po +0 -0
- data/po/it/rbot-wall.po +33 -0
- data/po/it/rbot-weather.po +0 -0
- data/po/it/rbot-wheelfortune.po +251 -0
- data/po/it/rbot-wow.po +0 -0
- data/po/it/rbot-wserver.po +0 -0
- data/po/it/rbot-youtube.po +64 -0
- data/po/it/rbot.po +1127 -0
- data/po/ja/rbot-alias.po +82 -0
- data/po/ja/rbot-autoop.po +0 -0
- data/po/ja/rbot-autorejoin.po +0 -0
- data/po/ja/rbot-azgame.po +194 -0
- data/po/ja/rbot-bans.po +0 -0
- data/po/ja/rbot-bash.po +0 -0
- data/po/ja/rbot-botsnack.po +0 -0
- data/po/ja/rbot-cal.po +3 -0
- data/po/ja/rbot-chanserv.po +0 -0
- data/po/ja/rbot-chucknorris.po +0 -0
- data/po/ja/rbot-debugger.po +0 -0
- data/po/ja/rbot-deepthoughts.po +0 -0
- data/po/ja/rbot-delicious.po +0 -0
- data/po/ja/rbot-dice.po +0 -0
- data/po/ja/rbot-dict.po +0 -0
- data/po/ja/rbot-dictclient.po +111 -0
- data/po/ja/rbot-digg.po +0 -0
- data/po/ja/rbot-eightball.po +0 -0
- data/po/ja/rbot-excuse.po +0 -0
- data/po/ja/rbot-factoids.po +107 -0
- data/po/ja/rbot-figlet.po +36 -0
- data/po/ja/rbot-fish.po +0 -0
- data/po/ja/rbot-forecast.po +0 -0
- data/po/ja/rbot-fortune.po +0 -0
- data/po/ja/rbot-freshmeat.po +0 -0
- data/po/ja/rbot-grouphug.po +18 -0
- data/po/ja/rbot-hl2.po +0 -0
- data/po/ja/rbot-host.po +3 -0
- data/po/ja/rbot-imdb.po +0 -0
- data/po/ja/rbot-insult.po +0 -0
- data/po/ja/rbot-iplookup.po +0 -0
- data/po/ja/rbot-karma.po +0 -0
- data/po/ja/rbot-keywords.po +24 -0
- data/po/ja/rbot-lart.po +0 -0
- data/po/ja/rbot-lastfm.po +172 -0
- data/po/ja/rbot-linkbot.po +0 -0
- data/po/ja/rbot-markov.po +20 -0
- data/po/ja/rbot-math.po +0 -0
- data/po/ja/rbot-modes.po +0 -0
- data/po/ja/rbot-nickrecover.po +36 -0
- data/po/ja/rbot-nickserv.po +104 -0
- data/po/ja/rbot-nslookup.po +0 -0
- data/po/ja/rbot-quakeauth.po +0 -0
- data/po/ja/rbot-quiz.po +0 -0
- data/po/ja/rbot-quotes.po +108 -0
- data/po/ja/rbot-reaction.po +0 -0
- data/po/ja/rbot-remind.po +0 -0
- data/po/ja/rbot-remotectl.po +0 -0
- data/po/ja/rbot-ri.po +0 -0
- data/po/ja/rbot-roshambo.po +0 -0
- data/po/ja/rbot-rot13.po +0 -0
- data/po/ja/rbot-roulette.po +0 -0
- data/po/ja/rbot-rss.po +20 -0
- data/po/ja/rbot-salut.po +0 -0
- data/po/ja/rbot-script.po +0 -0
- data/po/ja/rbot-search.po +0 -0
- data/po/ja/rbot-seen.po +0 -0
- data/po/ja/rbot-shiritori.po +115 -0
- data/po/ja/rbot-shortenurls.po +0 -0
- data/po/ja/rbot-slashdot.po +0 -0
- data/po/ja/rbot-spell.po +54 -0
- data/po/ja/rbot-theyfightcrime.po +0 -0
- data/po/ja/rbot-threat.po +0 -0
- data/po/ja/rbot-time.po +0 -0
- data/po/ja/rbot-topic.po +0 -0
- data/po/ja/rbot-translator.po +77 -0
- data/po/ja/rbot-tube.po +0 -0
- data/po/ja/rbot-twitter.po +24 -0
- data/po/ja/rbot-uno.po +512 -0
- data/po/ja/rbot-urban.po +0 -0
- data/po/ja/rbot-url.po +0 -0
- data/po/ja/rbot-usermodes.po +0 -0
- data/po/ja/rbot-wall.po +33 -0
- data/po/ja/rbot-weather.po +0 -0
- data/po/ja/rbot-wheelfortune.po +205 -0
- data/po/ja/rbot-wow.po +0 -0
- data/po/ja/rbot-wserver.po +0 -0
- data/po/ja/rbot-youtube.po +58 -0
- data/po/ja/rbot.po +999 -0
- data/po/rbot-alias.pot +83 -0
- data/po/rbot-autoop.pot +0 -0
- data/po/rbot-autorejoin.pot +0 -0
- data/po/rbot-azgame.pot +187 -0
- data/po/rbot-bans.pot +0 -0
- data/po/rbot-bash.pot +0 -0
- data/po/rbot-botsnack.pot +0 -0
- data/po/rbot-cal.pot +21 -0
- data/po/rbot-chanserv.pot +0 -0
- data/po/rbot-chucknorris.pot +0 -0
- data/po/rbot-debugger.pot +0 -0
- data/po/rbot-deepthoughts.pot +0 -0
- data/po/rbot-delicious.pot +0 -0
- data/po/rbot-dice.pot +0 -0
- data/po/rbot-dict.pot +0 -0
- data/po/rbot-dictclient.pot +112 -0
- data/po/rbot-digg.pot +0 -0
- data/po/rbot-eightball.pot +0 -0
- data/po/rbot-excuse.pot +0 -0
- data/po/rbot-factoids.pot +108 -0
- data/po/rbot-figlet.pot +37 -0
- data/po/rbot-fish.pot +0 -0
- data/po/rbot-forecast.pot +0 -0
- data/po/rbot-fortune.pot +0 -0
- data/po/rbot-freshmeat.pot +0 -0
- data/po/rbot-grouphug.pot +36 -0
- data/po/rbot-hl2.pot +0 -0
- data/po/rbot-host.pot +21 -0
- data/po/rbot-imdb.pot +0 -0
- data/po/rbot-insult.pot +0 -0
- data/po/rbot-iplookup.pot +0 -0
- data/po/rbot-karma.pot +0 -0
- data/po/rbot-keywords.pot +25 -0
- data/po/rbot-lart.pot +0 -0
- data/po/rbot-lastfm.pot +190 -0
- data/po/rbot-linkbot.pot +0 -0
- data/po/rbot-markov.pot +21 -0
- data/po/rbot-math.pot +0 -0
- data/po/rbot-modes.pot +0 -0
- data/po/rbot-nickrecover.pot +37 -0
- data/po/rbot-nickserv.pot +105 -0
- data/po/rbot-nslookup.pot +0 -0
- data/po/rbot-quakeauth.pot +0 -0
- data/po/rbot-quiz.pot +0 -0
- data/po/rbot-quotes.pot +109 -0
- data/po/rbot-reaction.pot +0 -0
- data/po/rbot-remind.pot +0 -0
- data/po/rbot-remotectl.pot +0 -0
- data/po/rbot-ri.pot +0 -0
- data/po/rbot-roshambo.pot +0 -0
- data/po/rbot-rot13.pot +0 -0
- data/po/rbot-roulette.pot +0 -0
- data/po/rbot-rss.pot +21 -0
- data/po/rbot-salut.pot +0 -0
- data/po/rbot-script.pot +0 -0
- data/po/rbot-search.pot +0 -0
- data/po/rbot-seen.pot +0 -0
- data/po/rbot-shiritori.pot +103 -0
- data/po/rbot-shortenurls.pot +0 -0
- data/po/rbot-slashdot.pot +0 -0
- data/po/rbot-spell.pot +55 -0
- data/po/rbot-theyfightcrime.pot +0 -0
- data/po/rbot-threat.pot +0 -0
- data/po/rbot-time.pot +0 -0
- data/po/rbot-topic.pot +0 -0
- data/po/rbot-translator.pot +78 -0
- data/po/rbot-tube.pot +0 -0
- data/po/rbot-twitter.pot +25 -0
- data/po/rbot-uno.pot +513 -0
- data/po/rbot-urban.pot +0 -0
- data/po/rbot-url.pot +0 -0
- data/po/rbot-usermodes.pot +0 -0
- data/po/rbot-wall.pot +33 -0
- data/po/rbot-weather.pot +0 -0
- data/po/rbot-wheelfortune.pot +206 -0
- data/po/rbot-wow.pot +0 -0
- data/po/rbot-wserver.pot +0 -0
- data/po/rbot-youtube.pot +59 -0
- data/po/rbot.pot +1004 -0
- data/po/zh_CN/rbot-alias.po +82 -0
- data/po/zh_CN/rbot-autoop.po +0 -0
- data/po/zh_CN/rbot-autorejoin.po +0 -0
- data/po/zh_CN/rbot-azgame.po +186 -0
- data/po/zh_CN/rbot-bans.po +0 -0
- data/po/zh_CN/rbot-bash.po +0 -0
- data/po/zh_CN/rbot-botsnack.po +0 -0
- data/po/zh_CN/rbot-cal.po +3 -0
- data/po/zh_CN/rbot-chanserv.po +0 -0
- data/po/zh_CN/rbot-chucknorris.po +0 -0
- data/po/zh_CN/rbot-debugger.po +0 -0
- data/po/zh_CN/rbot-deepthoughts.po +0 -0
- data/po/zh_CN/rbot-delicious.po +0 -0
- data/po/zh_CN/rbot-dice.po +0 -0
- data/po/zh_CN/rbot-dict.po +0 -0
- data/po/zh_CN/rbot-dictclient.po +111 -0
- data/po/zh_CN/rbot-digg.po +0 -0
- data/po/zh_CN/rbot-eightball.po +0 -0
- data/po/zh_CN/rbot-excuse.po +0 -0
- data/po/zh_CN/rbot-factoids.po +107 -0
- data/po/zh_CN/rbot-figlet.po +36 -0
- data/po/zh_CN/rbot-fish.po +0 -0
- data/po/zh_CN/rbot-forecast.po +0 -0
- data/po/zh_CN/rbot-fortune.po +0 -0
- data/po/zh_CN/rbot-freshmeat.po +0 -0
- data/po/zh_CN/rbot-grouphug.po +18 -0
- data/po/zh_CN/rbot-hl2.po +0 -0
- data/po/zh_CN/rbot-host.po +3 -0
- data/po/zh_CN/rbot-imdb.po +0 -0
- data/po/zh_CN/rbot-insult.po +0 -0
- data/po/zh_CN/rbot-iplookup.po +0 -0
- data/po/zh_CN/rbot-karma.po +0 -0
- data/po/zh_CN/rbot-keywords.po +24 -0
- data/po/zh_CN/rbot-lart.po +0 -0
- data/po/zh_CN/rbot-lastfm.po +172 -0
- data/po/zh_CN/rbot-linkbot.po +0 -0
- data/po/zh_CN/rbot-markov.po +20 -0
- data/po/zh_CN/rbot-math.po +0 -0
- data/po/zh_CN/rbot-modes.po +0 -0
- data/po/zh_CN/rbot-nickrecover.po +36 -0
- data/po/zh_CN/rbot-nickserv.po +104 -0
- data/po/zh_CN/rbot-nslookup.po +0 -0
- data/po/zh_CN/rbot-quakeauth.po +0 -0
- data/po/zh_CN/rbot-quiz.po +0 -0
- data/po/zh_CN/rbot-quotes.po +108 -0
- data/po/zh_CN/rbot-reaction.po +0 -0
- data/po/zh_CN/rbot-remind.po +0 -0
- data/po/zh_CN/rbot-remotectl.po +0 -0
- data/po/zh_CN/rbot-ri.po +0 -0
- data/po/zh_CN/rbot-roshambo.po +0 -0
- data/po/zh_CN/rbot-rot13.po +0 -0
- data/po/zh_CN/rbot-roulette.po +0 -0
- data/po/zh_CN/rbot-rss.po +20 -0
- data/po/zh_CN/rbot-salut.po +0 -0
- data/po/zh_CN/rbot-script.po +0 -0
- data/po/zh_CN/rbot-search.po +0 -0
- data/po/zh_CN/rbot-seen.po +0 -0
- data/po/zh_CN/rbot-shiritori.po +102 -0
- data/po/zh_CN/rbot-shortenurls.po +0 -0
- data/po/zh_CN/rbot-slashdot.po +0 -0
- data/po/zh_CN/rbot-spell.po +54 -0
- data/po/zh_CN/rbot-theyfightcrime.po +0 -0
- data/po/zh_CN/rbot-threat.po +0 -0
- data/po/zh_CN/rbot-time.po +0 -0
- data/po/zh_CN/rbot-topic.po +0 -0
- data/po/zh_CN/rbot-translator.po +77 -0
- data/po/zh_CN/rbot-tube.po +0 -0
- data/po/zh_CN/rbot-twitter.po +24 -0
- data/po/zh_CN/rbot-uno.po +512 -0
- data/po/zh_CN/rbot-urban.po +0 -0
- data/po/zh_CN/rbot-url.po +0 -0
- data/po/zh_CN/rbot-usermodes.po +0 -0
- data/po/zh_CN/rbot-wall.po +33 -0
- data/po/zh_CN/rbot-weather.po +0 -0
- data/po/zh_CN/rbot-wheelfortune.po +205 -0
- data/po/zh_CN/rbot-wow.po +0 -0
- data/po/zh_CN/rbot-wserver.po +0 -0
- data/po/zh_CN/rbot-youtube.po +58 -0
- data/po/zh_CN/rbot.po +1006 -0
- data/po/zh_TW/rbot-alias.po +82 -0
- data/po/zh_TW/rbot-autoop.po +0 -0
- data/po/zh_TW/rbot-autorejoin.po +0 -0
- data/po/zh_TW/rbot-azgame.po +186 -0
- data/po/zh_TW/rbot-bans.po +0 -0
- data/po/zh_TW/rbot-bash.po +0 -0
- data/po/zh_TW/rbot-botsnack.po +0 -0
- data/po/zh_TW/rbot-cal.po +3 -0
- data/po/zh_TW/rbot-chanserv.po +0 -0
- data/po/zh_TW/rbot-chucknorris.po +0 -0
- data/po/zh_TW/rbot-debugger.po +0 -0
- data/po/zh_TW/rbot-deepthoughts.po +0 -0
- data/po/zh_TW/rbot-delicious.po +0 -0
- data/po/zh_TW/rbot-dice.po +0 -0
- data/po/zh_TW/rbot-dict.po +0 -0
- data/po/zh_TW/rbot-dictclient.po +111 -0
- data/po/zh_TW/rbot-digg.po +0 -0
- data/po/zh_TW/rbot-eightball.po +0 -0
- data/po/zh_TW/rbot-excuse.po +0 -0
- data/po/zh_TW/rbot-factoids.po +107 -0
- data/po/zh_TW/rbot-figlet.po +36 -0
- data/po/zh_TW/rbot-fish.po +0 -0
- data/po/zh_TW/rbot-forecast.po +0 -0
- data/po/zh_TW/rbot-fortune.po +0 -0
- data/po/zh_TW/rbot-freshmeat.po +0 -0
- data/po/zh_TW/rbot-grouphug.po +18 -0
- data/po/zh_TW/rbot-hl2.po +0 -0
- data/po/zh_TW/rbot-host.po +3 -0
- data/po/zh_TW/rbot-imdb.po +0 -0
- data/po/zh_TW/rbot-insult.po +0 -0
- data/po/zh_TW/rbot-iplookup.po +0 -0
- data/po/zh_TW/rbot-karma.po +0 -0
- data/po/zh_TW/rbot-keywords.po +24 -0
- data/po/zh_TW/rbot-lart.po +0 -0
- data/po/zh_TW/rbot-lastfm.po +172 -0
- data/po/zh_TW/rbot-linkbot.po +0 -0
- data/po/zh_TW/rbot-markov.po +20 -0
- data/po/zh_TW/rbot-math.po +0 -0
- data/po/zh_TW/rbot-modes.po +0 -0
- data/po/zh_TW/rbot-nickrecover.po +36 -0
- data/po/zh_TW/rbot-nickserv.po +104 -0
- data/po/zh_TW/rbot-nslookup.po +0 -0
- data/po/zh_TW/rbot-quakeauth.po +0 -0
- data/po/zh_TW/rbot-quiz.po +0 -0
- data/po/zh_TW/rbot-quotes.po +108 -0
- data/po/zh_TW/rbot-reaction.po +0 -0
- data/po/zh_TW/rbot-remind.po +0 -0
- data/po/zh_TW/rbot-remotectl.po +0 -0
- data/po/zh_TW/rbot-ri.po +0 -0
- data/po/zh_TW/rbot-roshambo.po +0 -0
- data/po/zh_TW/rbot-rot13.po +0 -0
- data/po/zh_TW/rbot-roulette.po +0 -0
- data/po/zh_TW/rbot-rss.po +20 -0
- data/po/zh_TW/rbot-salut.po +0 -0
- data/po/zh_TW/rbot-script.po +0 -0
- data/po/zh_TW/rbot-search.po +0 -0
- data/po/zh_TW/rbot-seen.po +0 -0
- data/po/zh_TW/rbot-shiritori.po +102 -0
- data/po/zh_TW/rbot-shortenurls.po +0 -0
- data/po/zh_TW/rbot-slashdot.po +0 -0
- data/po/zh_TW/rbot-spell.po +54 -0
- data/po/zh_TW/rbot-theyfightcrime.po +0 -0
- data/po/zh_TW/rbot-threat.po +0 -0
- data/po/zh_TW/rbot-time.po +0 -0
- data/po/zh_TW/rbot-topic.po +0 -0
- data/po/zh_TW/rbot-translator.po +77 -0
- data/po/zh_TW/rbot-tube.po +0 -0
- data/po/zh_TW/rbot-twitter.po +24 -0
- data/po/zh_TW/rbot-uno.po +512 -0
- data/po/zh_TW/rbot-urban.po +0 -0
- data/po/zh_TW/rbot-url.po +0 -0
- data/po/zh_TW/rbot-usermodes.po +0 -0
- data/po/zh_TW/rbot-wall.po +33 -0
- data/po/zh_TW/rbot-weather.po +0 -0
- data/po/zh_TW/rbot-wheelfortune.po +205 -0
- data/po/zh_TW/rbot-wow.po +0 -0
- data/po/zh_TW/rbot-wserver.po +0 -0
- data/po/zh_TW/rbot-youtube.po +58 -0
- data/po/zh_TW/rbot.po +1034 -0
- data/setup.rb +800 -574
- metadata +723 -108
- data/data/rbot/contrib/plugins/figlet.rb +0 -20
- data/data/rbot/contrib/plugins/ri.rb +0 -83
- data/data/rbot/plugins/demauro.rb +0 -95
- data/data/rbot/plugins/google.rb +0 -53
- data/data/rbot/plugins/opme.rb +0 -19
- data/data/rbot/plugins/roshambo.rb +0 -54
- data/data/rbot/plugins/rubyurl.rb +0 -39
- data/data/rbot/plugins/tinyurl.rb +0 -39
- data/data/rbot/plugins/xmlrpc.rb.disabled +0 -52
- data/data/rbot/templates/levels.rbot +0 -32
- data/data/rbot/templates/users.rbot +0 -1
- data/lib/rbot/auth.rb +0 -314
- data/lib/rbot/channel.rb +0 -54
- data/lib/rbot/httputil.rb +0 -309
- data/lib/rbot/utils.rb +0 -83
data/data/rbot/plugins/threat.rb
CHANGED
@@ -16,36 +16,39 @@ class ThreatPlugin < Plugin
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def privmsg(m)
|
19
|
-
|
19
|
+
color = ""
|
20
20
|
red = "\x0304" # severe
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
orange = "\x0307" # high
|
22
|
+
yellow = "\x0308" # elevated
|
23
|
+
blue = "\x0312" # guarded
|
24
|
+
green = "\x0303" # low
|
25
|
+
black = "\x0301" # default
|
26
|
+
|
27
|
+
page = @bot.httputil.get("http://www.dhs.gov/index.shtm")
|
28
|
+
|
29
|
+
if page =~ /\"Current National Threat Level is (.*?)\"/
|
29
30
|
state = $1
|
30
|
-
|
31
|
-
case state
|
31
|
+
case state
|
32
32
|
when "severe"
|
33
|
-
|
33
|
+
color = red
|
34
34
|
when "high"
|
35
|
-
|
35
|
+
color = orange
|
36
36
|
when "elevated"
|
37
|
-
|
37
|
+
color = yellow
|
38
38
|
when "guarded"
|
39
|
-
|
39
|
+
color = blue
|
40
40
|
when "low"
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
color = green
|
42
|
+
else
|
43
|
+
color = black
|
44
|
+
end
|
45
|
+
|
46
|
+
m.reply color + "Today " + m.sourcenick + " the threat level is " + state.capitalize
|
47
|
+
else
|
48
|
+
m.reply "I was unable to retrieve the threat level"
|
49
|
+
end
|
47
50
|
|
48
|
-
|
51
|
+
return
|
49
52
|
end
|
50
53
|
|
51
54
|
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
#-- vim:sw=2:et
|
2
|
+
#++
|
3
|
+
#
|
4
|
+
# :title: Time Zone Plugin for rbot
|
5
|
+
#
|
6
|
+
# Author:: Ian Monroe <ian@monroe.nu>
|
7
|
+
# Copyright:: (C) 2006 Ian Monroe
|
8
|
+
# License:: MIT license
|
9
|
+
|
10
|
+
require 'tzinfo'
|
11
|
+
|
12
|
+
class TimePlugin < Plugin
|
13
|
+
|
14
|
+
def help(plugin, topic="")
|
15
|
+
"time <time zone> to get the local time of a certain location. <time zone> can be <Continent/City> or <two character country code>. time <nick> to see the local time of that person if their time zone is set. time admin set <nick> <time zone> to set the time zone for another user. time [admin] reset [nick] to let the bot forget about the tzinfo about someone"
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
super
|
20
|
+
# this plugin only wants to store strings
|
21
|
+
class << @registry
|
22
|
+
def store(val)
|
23
|
+
val
|
24
|
+
end
|
25
|
+
def restore(val)
|
26
|
+
val
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def getTime(m, zone )
|
32
|
+
if zone.length == 2 then #country code
|
33
|
+
zone.upcase!
|
34
|
+
zone = 'GB' if zone == 'UK' #country doesn't know its own name
|
35
|
+
begin
|
36
|
+
nationZones = TZInfo::Country.get(zone).zone_identifiers
|
37
|
+
if nationZones.size == 1 then
|
38
|
+
zone = nationZones[0]
|
39
|
+
else
|
40
|
+
m.reply "#{zone} has the cities of #{nationZones.join( ', ' )}."
|
41
|
+
end
|
42
|
+
rescue TZInfo::InvalidCountryCode
|
43
|
+
m.reply "#{zone} is not a valid country code."
|
44
|
+
end
|
45
|
+
end
|
46
|
+
['/', '_'].each { |sp|
|
47
|
+
arr = Array.new
|
48
|
+
zone.split(sp).each{ |s|
|
49
|
+
s[0] = s[0,1].upcase
|
50
|
+
s[1, s.length] = s[1, s.length].downcase if sp == '/'
|
51
|
+
arr.push(s) }
|
52
|
+
zone = arr.join( sp )
|
53
|
+
}
|
54
|
+
|
55
|
+
tz = TZInfo::Timezone.get( zone )
|
56
|
+
"#{tz.friendly_identifier} - #{tz.now.strftime( '%a %b %d %H:%M' )} #{tz.current_period.abbreviation}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def showTime(m, params)
|
60
|
+
zone = params[:where].join('_')
|
61
|
+
if params[:where].size > 0 then
|
62
|
+
begin
|
63
|
+
m.reply getTime( m, zone )
|
64
|
+
rescue TZInfo::InvalidTimezoneIdentifier
|
65
|
+
if @registry.has_key?( zone ) then
|
66
|
+
zone = @registry[ zone ]
|
67
|
+
m.reply getTime( m, zone )
|
68
|
+
else
|
69
|
+
m.reply "#{zone} is an unknown time."
|
70
|
+
end
|
71
|
+
end
|
72
|
+
else
|
73
|
+
if @registry.has_key?( m.sourcenick) then
|
74
|
+
zone = @registry[ m.sourcenick ]
|
75
|
+
m.reply "#{m.sourcenick}: #{getTime( m, zone )}"
|
76
|
+
else
|
77
|
+
m.reply "#{m.sourcenick}: use time set <Continent/City> to set your timezone."
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def setUserZone( m, params )
|
83
|
+
if params[:where].size > 0 then
|
84
|
+
s = setZone( m, m.sourcenick, params[:where].join('_') )
|
85
|
+
else
|
86
|
+
m.reply "Requires Continent/City or country code"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def resetUserZone( m, params )
|
91
|
+
s = resetZone( m, m.sourcenick)
|
92
|
+
end
|
93
|
+
|
94
|
+
def setAdminZone( m, params )
|
95
|
+
if params[:who] and params[:where].size > 0 then
|
96
|
+
s = setZone( m, params[:who], params[:where].join('_') )
|
97
|
+
else
|
98
|
+
m.reply "Requires a nick and the Continent/City or country code"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def resetAdminZone( m, params )
|
103
|
+
if params[:who]
|
104
|
+
s = resetZone( m, params[:who])
|
105
|
+
else
|
106
|
+
m.reply "Requires a nick"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def setZone( m, user, zone )
|
111
|
+
begin
|
112
|
+
getTime( m, zone )
|
113
|
+
rescue TZInfo::InvalidTimezoneIdentifier
|
114
|
+
m.reply "#{zone} is an invalid timezone. Format is Continent/City or a two character country code."
|
115
|
+
return
|
116
|
+
end
|
117
|
+
@registry[ user ] = zone
|
118
|
+
m.reply "Ok, I'll remember that #{user} is on the #{zone} timezone"
|
119
|
+
end
|
120
|
+
|
121
|
+
def resetZone( m, user )
|
122
|
+
@registry.delete(user)
|
123
|
+
m.reply "Ok, I've forgotten #{user}'s timezone"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
plugin = TimePlugin.new
|
128
|
+
|
129
|
+
plugin.default_auth('admin', false)
|
130
|
+
|
131
|
+
plugin.map 'time set [time][zone] [to] *where', :action=> 'setUserZone', :defaults => {:where => false}
|
132
|
+
plugin.map 'time reset [time][zone]', :action=> 'resetUserZone'
|
133
|
+
plugin.map 'time admin set [time][zone] [for] :who [to] *where', :action=> 'setAdminZone', :defaults => {:who => false, :where => false}
|
134
|
+
plugin.map 'time admin reset [time][zone] [for] :who', :action=> 'resetAdminZone', :defaults => {:who => false}
|
135
|
+
plugin.map 'time *where', :action => 'showTime', :defaults => {:where => false}
|
data/data/rbot/plugins/topic.rb
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
|
1
|
+
#-- vim:sw=2:et
|
2
|
+
#++
|
3
|
+
#
|
4
|
+
# :title: Topic manipulation plugin for rbot
|
5
|
+
#
|
6
|
+
# Author:: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
|
7
|
+
# Copyright:: (C) 2006-2007 Giuseppe Bilotta
|
8
|
+
# License:: GPL v2
|
9
|
+
#
|
2
10
|
# Add a bunch of topic manipulation features
|
3
11
|
|
4
12
|
class TopicPlugin < Plugin
|
@@ -31,8 +39,10 @@ class TopicPlugin < Plugin
|
|
31
39
|
return "topic clear => clears the topic"
|
32
40
|
when "set"
|
33
41
|
return "topic set <text> => sets the topic to <text>"
|
42
|
+
when "undo"
|
43
|
+
return "topic undo => undoes the latest change to the topic"
|
34
44
|
else
|
35
|
-
return "topic add(at)|prepend|del(ete)|replace|sep(arator)|learn|restore|clear|set: " + \
|
45
|
+
return "topic add(at)|prepend|del(ete)|replace|sep(arator)|learn|restore|clear|set|undo: " + \
|
36
46
|
"manipulate the topic of the current channel; use topic <#channel> <command> " + \
|
37
47
|
"for private addressing"
|
38
48
|
end
|
@@ -42,17 +52,16 @@ class TopicPlugin < Plugin
|
|
42
52
|
def handletopic(m, param)
|
43
53
|
return unless m.kind_of?(PrivMessage)
|
44
54
|
if m.public?
|
45
|
-
ch = m.channel
|
55
|
+
ch = m.channel
|
46
56
|
else
|
47
|
-
ch = param[:channel]
|
57
|
+
ch = m.server.get_channel(param[:channel])
|
58
|
+
unless ch
|
59
|
+
m.reply("I am not in channel #{param[:channel]}")
|
60
|
+
return
|
61
|
+
end
|
48
62
|
end
|
49
63
|
cmd = param[:command]
|
50
|
-
txt = param[:text].
|
51
|
-
|
52
|
-
unless @bot.channels.has_key?(ch)
|
53
|
-
m.reply "I am not in channel #{ch}"
|
54
|
-
return
|
55
|
-
end
|
64
|
+
txt = param[:text].to_s
|
56
65
|
|
57
66
|
case cmd
|
58
67
|
when /^a(dd|ppend)$/
|
@@ -89,12 +98,15 @@ class TopicPlugin < Plugin
|
|
89
98
|
end
|
90
99
|
when 'restore'
|
91
100
|
restoretopic(m, ch)
|
101
|
+
when 'undo'
|
102
|
+
undotopic(m, ch)
|
92
103
|
else
|
93
104
|
m.reply 'unknown command'
|
94
105
|
end
|
95
106
|
end
|
96
107
|
|
97
108
|
def topicsep(m, ch, txt)
|
109
|
+
return if !@bot.auth.allow?("topic::edit::separator", m.source, m.replyto)
|
98
110
|
if txt
|
99
111
|
sep = txt.strip
|
100
112
|
if sep != ""
|
@@ -105,41 +117,50 @@ class TopicPlugin < Plugin
|
|
105
117
|
end
|
106
118
|
|
107
119
|
def setsep(ch, sep)
|
108
|
-
|
109
|
-
|
120
|
+
raise unless ch.class <= Irc::Channel
|
121
|
+
# TODO multiserver
|
122
|
+
k = ch.downcase
|
123
|
+
|
124
|
+
if @registry.has_key?(k)
|
125
|
+
data = @registry[k]
|
110
126
|
else
|
111
127
|
data = Hash.new
|
112
128
|
end
|
113
129
|
|
114
130
|
oldsep = getsep(ch)
|
115
|
-
topic =
|
131
|
+
topic = ch.topic.text
|
116
132
|
topicarray = topic.split(/\s+#{Regexp.escape(oldsep)}\s*/)
|
117
133
|
|
118
134
|
if sep != oldsep and topicarray.length > 0
|
119
135
|
newtopic = topicarray.join(" #{sep} ")
|
120
|
-
@bot.topic ch, newtopic
|
136
|
+
@bot.topic ch, newtopic if newtopic != topic
|
121
137
|
end
|
122
138
|
|
123
139
|
data[:separator] = sep
|
124
|
-
@registry[
|
140
|
+
@registry[k] = data
|
125
141
|
end
|
126
142
|
|
127
143
|
def getsep(ch)
|
128
|
-
|
129
|
-
|
130
|
-
|
144
|
+
raise unless ch.class <= Irc::Channel
|
145
|
+
# TODO multiserver
|
146
|
+
k = ch.downcase
|
147
|
+
|
148
|
+
if @registry.has_key?(k)
|
149
|
+
if @registry[k].has_key?(:separator)
|
150
|
+
return @registry[k][:separator]
|
131
151
|
end
|
132
152
|
end
|
133
153
|
return @separator
|
134
154
|
end
|
135
155
|
|
136
|
-
def topicaddat(m,
|
137
|
-
|
138
|
-
|
156
|
+
def topicaddat(m, ch, num, txt)
|
157
|
+
return if !@bot.auth.allow?("topic::edit::add", m.source, m.replyto)
|
158
|
+
sep = getsep(ch)
|
159
|
+
topic = ch.topic.text
|
139
160
|
topicarray = topic.split(/\s+#{Regexp.escape(sep)}\s*/)
|
140
161
|
topicarray.insert(num, txt)
|
141
162
|
newtopic = topicarray.join(" #{sep} ")
|
142
|
-
|
163
|
+
changetopic(m, ch, newtopic)
|
143
164
|
end
|
144
165
|
|
145
166
|
def topicappend(m, ch, txt)
|
@@ -150,55 +171,91 @@ class TopicPlugin < Plugin
|
|
150
171
|
topicaddat(m, ch, 0, txt)
|
151
172
|
end
|
152
173
|
|
153
|
-
def topicdel(m,
|
154
|
-
|
155
|
-
|
174
|
+
def topicdel(m, ch, num)
|
175
|
+
return if !@bot.auth.allow?("topic::edit::del", m.source, m.replyto)
|
176
|
+
sep = getsep(ch)
|
177
|
+
topic = ch.topic.text
|
156
178
|
topicarray = topic.split(/\s+#{Regexp.escape(sep)}\s*/)
|
157
179
|
topicarray.delete_at(num)
|
158
180
|
newtopic = topicarray.join(" #{sep} ")
|
159
|
-
|
181
|
+
changetopic(m, ch, newtopic)
|
160
182
|
end
|
161
183
|
|
162
|
-
def learntopic(m,
|
163
|
-
return if !@bot.auth.allow?("
|
164
|
-
topic =
|
165
|
-
|
166
|
-
|
184
|
+
def learntopic(m, ch)
|
185
|
+
return if !@bot.auth.allow?("topic::store::store", m.source, m.replyto)
|
186
|
+
topic = ch.topic.text
|
187
|
+
k = ch.downcase
|
188
|
+
if @registry.has_key?(k)
|
189
|
+
data = @registry[k]
|
167
190
|
else
|
168
191
|
data = Hash.new
|
169
192
|
end
|
170
193
|
data[:topic] = topic
|
171
|
-
@registry[
|
194
|
+
@registry[k] = data
|
172
195
|
m.okay
|
173
196
|
end
|
174
197
|
|
175
|
-
def replacetopic(m,
|
176
|
-
return if !@bot.auth.allow?("topic", m.source, m.replyto)
|
177
|
-
sep = getsep(
|
178
|
-
topic =
|
198
|
+
def replacetopic(m, ch, num, txt)
|
199
|
+
return if !@bot.auth.allow?("topic::edit::replace", m.source, m.replyto)
|
200
|
+
sep = getsep(ch)
|
201
|
+
topic = ch.topic.text
|
179
202
|
topicarray = topic.split(/\s+#{Regexp.escape(sep)}\s*/)
|
180
203
|
topicarray[num] = txt
|
181
204
|
newtopic = topicarray.join(" #{sep} ")
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
def restoretopic(m,
|
186
|
-
return if !@bot.auth.allow?("
|
187
|
-
|
188
|
-
|
189
|
-
|
205
|
+
changetopic(m, ch, newtopic)
|
206
|
+
end
|
207
|
+
|
208
|
+
def restoretopic(m, ch)
|
209
|
+
return if !@bot.auth.allow?("topic::store::restore", m.source, m.replyto)
|
210
|
+
k = ch.downcase
|
211
|
+
if @registry.has_key?(k) && @registry[k].has_key?(:topic)
|
212
|
+
topic = @registry[k][:topic]
|
213
|
+
topicset(m, ch, topic)
|
214
|
+
else
|
215
|
+
m.reply "I don't remember any topic for #{ch}"
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def topicset(m, ch, text)
|
220
|
+
return if !@bot.auth.allow?("topic::edit::replace", m.source, m.replyto)
|
221
|
+
changetopic(m, ch, text)
|
222
|
+
end
|
223
|
+
|
224
|
+
# This method changes the topic on channel +ch+ to +text+, storing
|
225
|
+
# the previous topic for undo
|
226
|
+
def changetopic(m, ch, text)
|
227
|
+
k = ch.downcase
|
228
|
+
if @registry.has_key?(k)
|
229
|
+
data = @registry[k]
|
190
230
|
else
|
191
|
-
|
231
|
+
data = Hash.new
|
192
232
|
end
|
233
|
+
|
234
|
+
data[:oldtopic] = ch.topic.text
|
235
|
+
@registry[k] = data
|
236
|
+
|
237
|
+
@bot.topic ch, text
|
193
238
|
end
|
194
239
|
|
195
|
-
def
|
196
|
-
|
197
|
-
@
|
240
|
+
def undotopic(m, ch)
|
241
|
+
k = ch.downcase
|
242
|
+
if @registry.has_key?(k)
|
243
|
+
data = @registry[k]
|
244
|
+
if data.has_key?(:oldtopic)
|
245
|
+
changetopic(m, ch, data[:oldtopic].dup)
|
246
|
+
return
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
m.reply "No recent changes were recorded for #{ch}"
|
198
251
|
end
|
199
252
|
|
200
253
|
end
|
201
254
|
plugin = TopicPlugin.new
|
202
|
-
|
203
|
-
plugin.map 'topic :
|
255
|
+
|
256
|
+
plugin.map 'topic :command [*text]', :action => 'handletopic', :public => true, :private => false
|
257
|
+
plugin.map 'topic :channel :command [*text]', :action => 'handletopic', :public => false, :private => true
|
258
|
+
|
259
|
+
plugin.default_auth('*', false)
|
260
|
+
|
204
261
|
|
@@ -0,0 +1,360 @@
|
|
1
|
+
#-- vim:sw=2:et
|
2
|
+
#++
|
3
|
+
#
|
4
|
+
# :title: Translator plugin for rbot
|
5
|
+
#
|
6
|
+
# Author:: Yaohan Chen <yaohan.chen@gmail.com>
|
7
|
+
# Copyright:: (C) 2007 Yaohan Chen
|
8
|
+
# License:: GPLv2
|
9
|
+
#
|
10
|
+
# This plugin allows using rbot to translate text on a few translation services
|
11
|
+
#
|
12
|
+
# TODO
|
13
|
+
#
|
14
|
+
# * Configuration for whether to show translation engine
|
15
|
+
# * Optionally sync default translators with karma.rb ranking
|
16
|
+
|
17
|
+
require 'set'
|
18
|
+
require 'timeout'
|
19
|
+
|
20
|
+
# base class for implementing a translation service
|
21
|
+
# = Attributes
|
22
|
+
# direction:: supported translation directions, a hash where each key is a source
|
23
|
+
# language name, and each value is Set of target language names. The
|
24
|
+
# methods in the Direction module are convenient for initializing this
|
25
|
+
# attribute
|
26
|
+
class Translator
|
27
|
+
INFO = 'Some translation service'
|
28
|
+
|
29
|
+
class UnsupportedDirectionError < ArgumentError
|
30
|
+
end
|
31
|
+
|
32
|
+
class NoTranslationError < RuntimeError
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_reader :directions, :cache
|
36
|
+
|
37
|
+
def initialize(directions, cache={})
|
38
|
+
@directions = directions
|
39
|
+
@cache = cache
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# whether the translator supports this direction
|
44
|
+
def support?(from, to)
|
45
|
+
from != to && @directions[from].include?(to)
|
46
|
+
end
|
47
|
+
|
48
|
+
# this implements argument checking and caching. subclasses should define the
|
49
|
+
# do_translate method to implement actual translation
|
50
|
+
def translate(text, from, to)
|
51
|
+
raise UnsupportedDirectionError unless support?(from, to)
|
52
|
+
raise ArgumentError, _("Cannot translate empty string") if text.empty?
|
53
|
+
request = [text, from, to]
|
54
|
+
unless @cache.has_key? request
|
55
|
+
translation = do_translate(text, from, to)
|
56
|
+
raise NoTranslationError if translation.empty?
|
57
|
+
@cache[request] = translation
|
58
|
+
else
|
59
|
+
@cache[request]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
module Direction
|
64
|
+
# given the set of supported languages, return a hash suitable for the directions
|
65
|
+
# attribute which includes any language to any other language
|
66
|
+
def self.all_to_all(languages)
|
67
|
+
directions = all_to_none(languages)
|
68
|
+
languages.each {|l| directions[l] = languages.to_set}
|
69
|
+
directions
|
70
|
+
end
|
71
|
+
|
72
|
+
# a hash suitable for the directions attribute which includes any language from/to
|
73
|
+
# the given set of languages (center_languages)
|
74
|
+
def self.all_from_to(languages, center_languages)
|
75
|
+
directions = all_to_none(languages)
|
76
|
+
center_languages.each {|l| directions[l] = languages - [l]}
|
77
|
+
(languages - center_languages).each {|l| directions[l] = center_languages.to_set}
|
78
|
+
directions
|
79
|
+
end
|
80
|
+
|
81
|
+
# get a hash from a list of pairs
|
82
|
+
def self.pairs(list_of_pairs)
|
83
|
+
languages = list_of_pairs.flatten.to_set
|
84
|
+
directions = all_to_none(languages)
|
85
|
+
list_of_pairs.each do |(from, to)|
|
86
|
+
directions[from] << to
|
87
|
+
end
|
88
|
+
directions
|
89
|
+
end
|
90
|
+
|
91
|
+
# an empty hash with empty sets as default values
|
92
|
+
def self.all_to_none(languages)
|
93
|
+
Hash.new do |h, k|
|
94
|
+
# always return empty set when the key is non-existent, but put empty set in the
|
95
|
+
# hash only if the key is one of the languages
|
96
|
+
if languages.include? k
|
97
|
+
h[k] = Set.new
|
98
|
+
else
|
99
|
+
Set.new
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
class NiftyTranslator < Translator
|
108
|
+
INFO = '@nifty Translation <http://nifty.amikai.com/amitext/indexUTF8.jsp>'
|
109
|
+
|
110
|
+
def initialize(cache={})
|
111
|
+
require 'mechanize'
|
112
|
+
super(Translator::Direction.all_from_to(%w[ja en zh_CN ko], %w[ja]), cache)
|
113
|
+
@form = WWW::Mechanize.new.
|
114
|
+
get('http://nifty.amikai.com/amitext/indexUTF8.jsp').
|
115
|
+
forms.name('translateForm').first
|
116
|
+
end
|
117
|
+
|
118
|
+
def do_translate(text, from, to)
|
119
|
+
@form.radiobuttons.name('langpair').value = "#{from},#{to}".upcase
|
120
|
+
@form.fields.name('sourceText').value = text
|
121
|
+
|
122
|
+
@form.submit(@form.buttons.name('translate')).
|
123
|
+
forms.name('translateForm').fields.name('translatedText').value
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
class ExciteTranslator < Translator
|
129
|
+
INFO = 'Excite.jp Translation <http://www.excite.co.jp/world/>'
|
130
|
+
|
131
|
+
def initialize(cache={})
|
132
|
+
require 'mechanize'
|
133
|
+
require 'iconv'
|
134
|
+
|
135
|
+
super(Translator::Direction.all_from_to(%w[ja en zh_CN zh_TW ko], %w[ja]), cache)
|
136
|
+
|
137
|
+
@forms = Hash.new do |h, k|
|
138
|
+
case k
|
139
|
+
when 'en'
|
140
|
+
h[k] = open_form('english')
|
141
|
+
when 'zh_CN', 'zh_TW'
|
142
|
+
# this way we don't need to fetch the same page twice
|
143
|
+
h['zh_CN'] = h['zh_TW'] = open_form('chinese')
|
144
|
+
when 'ko'
|
145
|
+
h[k] = open_form('korean')
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def open_form(name)
|
151
|
+
WWW::Mechanize.new.get("http://www.excite.co.jp/world/#{name}").
|
152
|
+
forms.name('world').first
|
153
|
+
end
|
154
|
+
|
155
|
+
def do_translate(text, from, to)
|
156
|
+
non_ja_language = from != 'ja' ? from : to
|
157
|
+
form = @forms[non_ja_language]
|
158
|
+
|
159
|
+
if non_ja_language =~ /zh_(CN|TW)/
|
160
|
+
form.fields.name('wb_lp').value = "#{from}#{to}".sub(/_(?:CN|TW)/, '').upcase
|
161
|
+
form.fields.name('big5').value = ($1 == 'TW' ? 'yes' : 'no')
|
162
|
+
else
|
163
|
+
# the en<->ja page is in Shift_JIS while other pages are UTF-8
|
164
|
+
text = Iconv.iconv('Shift_JIS', 'UTF-8', text) if non_ja_language == 'en'
|
165
|
+
form.fields.name('wb_lp').value = "#{from}#{to}".upcase
|
166
|
+
end
|
167
|
+
form.fields.name('before').value = text
|
168
|
+
result = form.submit.forms.name('world').fields.name('after').value
|
169
|
+
# the en<->ja page is in Shift_JIS while other pages are UTF-8
|
170
|
+
if non_ja_language == 'en'
|
171
|
+
Iconv.iconv('UTF-8', 'Shift_JIS', result)
|
172
|
+
else
|
173
|
+
result
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
|
180
|
+
class GoogleTranslator < Translator
|
181
|
+
INFO = 'Google Translate <http://www.google.com/translate_t>'
|
182
|
+
|
183
|
+
def initialize(cache={})
|
184
|
+
require 'mechanize'
|
185
|
+
load_form!
|
186
|
+
language_pairs = @lang_list.options.map do |o|
|
187
|
+
# these options have values like "en|zh-CN"; map to things like ['en', 'zh_CN'].
|
188
|
+
o.value.split('|').map {|l| l.sub('-', '_')}
|
189
|
+
end
|
190
|
+
super(Translator::Direction.pairs(language_pairs), cache)
|
191
|
+
end
|
192
|
+
|
193
|
+
def load_form!
|
194
|
+
agent = WWW::Mechanize.new
|
195
|
+
# without faking the user agent, Google Translate will serve non-UTF-8 text
|
196
|
+
agent.user_agent_alias = 'Linux Konqueror'
|
197
|
+
@form = agent.get('http://www.google.com/translate_t').
|
198
|
+
forms.action('/translate_t').first
|
199
|
+
@lang_list = @form.fields.name('langpair')
|
200
|
+
end
|
201
|
+
|
202
|
+
def do_translate(text, from, to)
|
203
|
+
load_form!
|
204
|
+
|
205
|
+
@lang_list.value = "#{from}|#{to}".sub('_', '-')
|
206
|
+
@form.fields.name('text').value = text
|
207
|
+
@form.submit.parser.search('div#result_box').inner_html
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
|
212
|
+
class BabelfishTranslator < Translator
|
213
|
+
INFO = 'AltaVista Babel Fish Translation <http://babelfish.altavista.com/babelfish/>'
|
214
|
+
|
215
|
+
def initialize(cache)
|
216
|
+
require 'mechanize'
|
217
|
+
|
218
|
+
@form = WWW::Mechanize.new.get('http://babelfish.altavista.com/babelfish/').
|
219
|
+
forms.name('frmTrText').first
|
220
|
+
@lang_list = @form.fields.name('lp')
|
221
|
+
language_pairs = @lang_list.options.map {|o| o.value.split('_')}.
|
222
|
+
reject {|p| p.empty?}
|
223
|
+
super(Translator::Direction.pairs(language_pairs), cache)
|
224
|
+
end
|
225
|
+
|
226
|
+
def do_translate(text, from, to)
|
227
|
+
if @form.fields.name('trtext').empty?
|
228
|
+
@form.add_field!('trtext', text)
|
229
|
+
else
|
230
|
+
@form.fields.name('trtext').value = text
|
231
|
+
end
|
232
|
+
@lang_list.value = "#{from}_#{to}"
|
233
|
+
@form.submit.parser.search("td.s/div[@style]").inner_html
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
class WorldlingoTranslator < Translator
|
238
|
+
INFO = 'WorldLingo Free Online Translator <http://www.worldlingo.com/en/products_services/worldlingo_translator.html>'
|
239
|
+
|
240
|
+
LANGUAGES = %w[en fr de it pt es ru nl el sv ar ja ko zh_CN zh_TW]
|
241
|
+
def initialize(cache)
|
242
|
+
require 'uri'
|
243
|
+
super(Translator::Direction.all_to_all(LANGUAGES), cache)
|
244
|
+
end
|
245
|
+
|
246
|
+
def translate(text, from, to)
|
247
|
+
response = Irc::Utils.bot.httputil.get_response(URI.escape(
|
248
|
+
"http://www.worldlingo.com/SEfpX0LV2xIxsIIELJ,2E5nOlz5RArCY,/texttranslate?wl_srcenc=utf-8&wl_trgenc=utf-8&wl_text=#{text}&wl_srclang=#{from.upcase}&wl_trglang=#{to.upcase}"))
|
249
|
+
# WorldLingo seems to respond an XML when error occurs
|
250
|
+
case response['Content-Type']
|
251
|
+
when %r'text/plain'
|
252
|
+
response.body
|
253
|
+
else
|
254
|
+
raise Translator::NoTranslationError
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
class TranslatorPlugin < Plugin
|
260
|
+
Config.register Config::IntegerValue.new('translator.timeout',
|
261
|
+
:default => 30, :validate => Proc.new{|v| v > 0},
|
262
|
+
:desc => _("Number of seconds to wait for the translation service before timeout"))
|
263
|
+
|
264
|
+
TRANSLATORS = {
|
265
|
+
'nifty' => NiftyTranslator,
|
266
|
+
'excite' => ExciteTranslator,
|
267
|
+
'google_translate' => GoogleTranslator,
|
268
|
+
'babelfish' => BabelfishTranslator,
|
269
|
+
'worldlingo' => WorldlingoTranslator,
|
270
|
+
}
|
271
|
+
|
272
|
+
def initialize
|
273
|
+
super
|
274
|
+
|
275
|
+
@translators = {}
|
276
|
+
TRANSLATORS.each_pair do |name, c|
|
277
|
+
begin
|
278
|
+
@translators[name] = c.new(@registry.sub_registry(name))
|
279
|
+
map "#{name} :from :to *phrase",
|
280
|
+
:action => :cmd_translate, :thread => true
|
281
|
+
rescue Exception
|
282
|
+
warning _("Translator %{name} cannot be used: %{reason}") %
|
283
|
+
{:name => name, :reason => $!}
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
Config.register Config::ArrayValue.new('translator.default_list',
|
288
|
+
:default => TRANSLATORS.keys,
|
289
|
+
:validate => Proc.new {|l| l.all? {|t| TRANSLATORS.has_key?(t)}},
|
290
|
+
:desc => _("List of translators to try in order when translator name not specified"),
|
291
|
+
:on_change => Proc.new {|bot, v| update_default})
|
292
|
+
update_default
|
293
|
+
end
|
294
|
+
|
295
|
+
def help(plugin, topic=nil)
|
296
|
+
if @translators.has_key?(plugin)
|
297
|
+
translator = @translators[plugin]
|
298
|
+
_('%{translator} <from> <to> <phrase> => Look up phrase using %{info}, supported from -> to languages: %{directions}') % {
|
299
|
+
:translator => plugin,
|
300
|
+
:info => translator.class::INFO,
|
301
|
+
:directions => translator.directions.map do |source, targets|
|
302
|
+
_('%{source} -> %{targets}') %
|
303
|
+
{:source => source, :targets => targets.to_a.join(', ')}
|
304
|
+
end.join(' | ')
|
305
|
+
}
|
306
|
+
else
|
307
|
+
_('Command: <translator> <from> <to> <phrase>, where <translator> is one of: %{translators}. If "translator" is used in place of the translator name, the first translator in translator.default_list which supports the specified direction will be picked automatically. Use "help <translator>" to look up supported from and to languages') %
|
308
|
+
{:translators => @translators.keys.join(', ')}
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
def update_default
|
313
|
+
@default_translators = bot.config['translator.default_list'] & @translators.keys
|
314
|
+
end
|
315
|
+
|
316
|
+
def cmd_translator(m, params)
|
317
|
+
from, to = params[:from], params[:to]
|
318
|
+
translator = @default_translators.find {|t| @translators[t].support?(from, to)}
|
319
|
+
if translator
|
320
|
+
cmd_translate m, params.merge({:translator => translator, :show_provider => true})
|
321
|
+
else
|
322
|
+
m.reply _('None of the default translators (translator.default_list) supports translating from %{source} to %{target}') % {:source => from, :target => to}
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
def cmd_translate(m, params)
|
327
|
+
# get the first word of the command
|
328
|
+
tname = params[:translator] || m.message[/\A(\w+)\s/, 1]
|
329
|
+
translator = @translators[tname]
|
330
|
+
from, to, phrase = params[:from], params[:to], params[:phrase].to_s
|
331
|
+
if translator
|
332
|
+
begin
|
333
|
+
translation = Timeout.timeout(@bot.config['translator.timeout']) do
|
334
|
+
translator.translate(phrase, from, to)
|
335
|
+
end
|
336
|
+
m.reply(if params[:show_provider]
|
337
|
+
_('%{translation} (provided by %{translator})') %
|
338
|
+
{:translation => translation, :translator => tname}
|
339
|
+
else
|
340
|
+
translation
|
341
|
+
end)
|
342
|
+
|
343
|
+
rescue Translator::UnsupportedDirectionError
|
344
|
+
m.reply _("%{translator} doesn't support translating from %{source} to %{target}") %
|
345
|
+
{:translator => tname, :source => from, :target => to}
|
346
|
+
rescue Translator::NoTranslationError
|
347
|
+
m.reply _('%{translator} failed to provide a translation') %
|
348
|
+
{:translator => tname}
|
349
|
+
rescue Timeout::Error
|
350
|
+
m.reply _('The translator timed out')
|
351
|
+
end
|
352
|
+
else
|
353
|
+
m.reply _('No translator called %{name}') % {:name => tname}
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
plugin = TranslatorPlugin.new
|
359
|
+
plugin.map 'translator :from :to *phrase',
|
360
|
+
:action => :cmd_translator, :thread => true
|