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
@@ -0,0 +1,29 @@
|
|
1
|
+
#-- vim:sw=4:et
|
2
|
+
#++
|
3
|
+
#
|
4
|
+
# :title: RemoteCtl plugin
|
5
|
+
#
|
6
|
+
# Author:: jsn (dmitry kim) <dmitry dot kim at gmail dot org>
|
7
|
+
# Copyright:: (C) 2007 dmitry kim
|
8
|
+
# License:: in public domain
|
9
|
+
#
|
10
|
+
# Adds druby remote command execution to rbot. See 'bin/rbot-remote' for
|
11
|
+
# example usage.
|
12
|
+
|
13
|
+
class RemoteCtlPlugin < Plugin
|
14
|
+
include RemotePlugin
|
15
|
+
|
16
|
+
def remote_command(m, params)
|
17
|
+
s = params[:string].to_s
|
18
|
+
u = @bot.server.user("remote:#{m.source.username}")
|
19
|
+
@bot.auth.login(u, m.source.username, m.source.password)
|
20
|
+
fake_message(s, :source => u)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
me = RemoteCtlPlugin.new
|
25
|
+
|
26
|
+
me.remote_map 'dispatch *string',
|
27
|
+
:action => 'remote_command'
|
28
|
+
|
29
|
+
me.default_auth('*', false)
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#-- vim:sw=2:et
|
2
|
+
#++
|
3
|
+
#
|
4
|
+
# :title: 'ri' -- ruby documentation plugin
|
5
|
+
#
|
6
|
+
# Author:: Eric Hodel <drbrain@segment7.net> (aka drbrain)
|
7
|
+
# Author:: Michael Brailsford <brailsmt@yahoo.com> aka brailsmt
|
8
|
+
# Author:: dmitry kim <dmitry dot kim at gmail dot com>
|
9
|
+
# Copyright:: (C) 2007, dmitry kim
|
10
|
+
# Copyright:: (C) Eric Hodel
|
11
|
+
# Copyright:: (C) Michael Brailsford
|
12
|
+
# License:: MIT
|
13
|
+
#
|
14
|
+
|
15
|
+
class RiPlugin < Plugin
|
16
|
+
|
17
|
+
RI_COMMAND = %w{ri -f simple -T}
|
18
|
+
|
19
|
+
Config.register Config::IntegerValue.new('ri.max_length',
|
20
|
+
:default => 512,
|
21
|
+
:desc => "Maximum length of ri entry (in bytes) which is ok to be sent to channels or other users")
|
22
|
+
|
23
|
+
def help(plugin, topic="")
|
24
|
+
"ri <something> => returns ruby documentation for <something>; ri [tell] <whom> [about] <something> => sends the documentation entry about <something> to <whom> using /msg"
|
25
|
+
end
|
26
|
+
|
27
|
+
def ri(m, params)
|
28
|
+
tgt = nil
|
29
|
+
if params[:who]
|
30
|
+
if m.private?
|
31
|
+
if params[:who] != m.sourcenick
|
32
|
+
m.reply '"ri tell <who>" syntax is only allowed in public channels'
|
33
|
+
return
|
34
|
+
end
|
35
|
+
elsif !(tgt = m.channel.users[params[:who]])
|
36
|
+
m.reply "sorry, i don't see user #{params[:who]} here on #{m.channel}"
|
37
|
+
return
|
38
|
+
end
|
39
|
+
end
|
40
|
+
args = RI_COMMAND.dup
|
41
|
+
if a = params[:something]
|
42
|
+
if a == '-c'
|
43
|
+
args.push(a)
|
44
|
+
else
|
45
|
+
args.push('--')
|
46
|
+
args.push(a)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
begin
|
50
|
+
ret = Utils.safe_exec(*args)
|
51
|
+
rescue
|
52
|
+
return m.reply("failed to execute ri")
|
53
|
+
end
|
54
|
+
ret = ret.gsub(/\t/, " ").split(/\n/).join(" ").gsub(/\s\s+/, ' ')
|
55
|
+
|
56
|
+
if ret.length > @bot.config['ri.max_length']
|
57
|
+
if !m.private? && tgt.to_s != m.sourcenick
|
58
|
+
return m.reply('entry is too long to send to the channel or to some other user, use /msg to ask me about it')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
if tgt
|
62
|
+
@bot.say(tgt, ret)
|
63
|
+
m.okay
|
64
|
+
else
|
65
|
+
m.reply(ret)
|
66
|
+
end
|
67
|
+
return
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
plugin = RiPlugin.new
|
72
|
+
plugin.map 'ri :something', :requirements => {:something => /^((-c)|(\w\S+))$/}
|
73
|
+
plugin.map 'ri [tell] :who [about] :something',
|
74
|
+
:requirements => {:something => /^((-c)|(\w\S+))$/}
|
data/data/rbot/plugins/rot13.rb
CHANGED
@@ -1,9 +1,24 @@
|
|
1
|
+
#-- vim:sw=2:et
|
2
|
+
#++
|
3
|
+
#
|
4
|
+
# :title: ROT13 plugin
|
5
|
+
#
|
1
6
|
class RotPlugin < Plugin
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
@bot.register_filter(:rot13) { |s|
|
10
|
+
ss = s.dup
|
11
|
+
ss[:text] = s[:text].tr("A-Za-z", "N-ZA-Mn-za-m")
|
12
|
+
ss
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
2
16
|
def help(plugin, topic="")
|
3
17
|
"rot13 <string> => encode <string> to rot13 or back"
|
4
18
|
end
|
19
|
+
|
5
20
|
def rot13(m, params)
|
6
|
-
m.reply params[:string].
|
21
|
+
m.reply @bot.filter(:rot13, params[:string].to_s)
|
7
22
|
end
|
8
23
|
end
|
9
24
|
plugin = RotPlugin.new
|
data/data/rbot/plugins/rss.rb
CHANGED
@@ -1,585 +1,1219 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
end
|
225
|
-
|
226
|
-
def
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
def
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
end
|
284
|
-
|
285
|
-
|
286
|
-
end
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
end
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
if
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
1
|
+
#-- vim:sw=2:et
|
2
|
+
#++
|
3
|
+
#
|
4
|
+
# :title: RSS feed plugin for rbot
|
5
|
+
#
|
6
|
+
# Author:: Stanislav Karchebny <berkus@madfire.net>
|
7
|
+
# Author:: Ian Monroe <ian@monroe.nu>
|
8
|
+
# Author:: Mark Kretschmann <markey@web.de>
|
9
|
+
# Author:: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
|
10
|
+
#
|
11
|
+
# Copyright:: (C) 2004 Stanislav Karchebny
|
12
|
+
# Copyright:: (C) 2005 Ian Monroe, Mark Kretschmann
|
13
|
+
# Copyright:: (C) 2006-2007 Giuseppe Bilotta
|
14
|
+
#
|
15
|
+
# License:: MIT license
|
16
|
+
|
17
|
+
require 'rss'
|
18
|
+
|
19
|
+
# Try to load rss/content/2.0 so we can access the data in <content:encoded>
|
20
|
+
# tags.
|
21
|
+
begin
|
22
|
+
require 'rss/content/2.0'
|
23
|
+
rescue LoadError
|
24
|
+
end
|
25
|
+
|
26
|
+
module ::RSS
|
27
|
+
|
28
|
+
# Add support for Slashdot namespace in RDF. The code is just an adaptation
|
29
|
+
# of the DublinCore code.
|
30
|
+
unless defined?(SLASH_PREFIX)
|
31
|
+
SLASH_PREFIX = 'slash'
|
32
|
+
SLASH_URI = "http://purl.org/rss/1.0/modules/slash/"
|
33
|
+
|
34
|
+
RDF.install_ns(SLASH_PREFIX, SLASH_URI)
|
35
|
+
|
36
|
+
module BaseSlashModel
|
37
|
+
def append_features(klass)
|
38
|
+
super
|
39
|
+
|
40
|
+
return if klass.instance_of?(Module)
|
41
|
+
SlashModel::ELEMENT_NAME_INFOS.each do |name, plural_name|
|
42
|
+
plural = plural_name || "#{name}s"
|
43
|
+
full_name = "#{SLASH_PREFIX}_#{name}"
|
44
|
+
full_plural_name = "#{SLASH_PREFIX}_#{plural}"
|
45
|
+
klass_name = "Slash#{Utils.to_class_name(name)}"
|
46
|
+
|
47
|
+
# This will fail with older version of the Ruby RSS module
|
48
|
+
begin
|
49
|
+
klass.install_have_children_element(name, SLASH_URI, "*",
|
50
|
+
full_name, full_plural_name)
|
51
|
+
klass.install_must_call_validator(SLASH_PREFIX, SLASH_URI)
|
52
|
+
rescue ArgumentError
|
53
|
+
klass.module_eval("install_have_children_element(#{full_name.dump}, #{full_plural_name.dump})")
|
54
|
+
end
|
55
|
+
|
56
|
+
klass.module_eval(<<-EOC, *get_file_and_line_from_caller(0))
|
57
|
+
remove_method :#{full_name} if method_defined? :#{full_name}
|
58
|
+
remove_method :#{full_name}= if method_defined? :#{full_name}=
|
59
|
+
remove_method :set_#{full_name} if method_defined? :set_#{full_name}
|
60
|
+
|
61
|
+
def #{full_name}
|
62
|
+
@#{full_name}.first and @#{full_name}.first.value
|
63
|
+
end
|
64
|
+
|
65
|
+
def #{full_name}=(new_value)
|
66
|
+
@#{full_name}[0] = Utils.new_with_value_if_need(#{klass_name}, new_value)
|
67
|
+
end
|
68
|
+
alias set_#{full_name} #{full_name}=
|
69
|
+
EOC
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
module SlashModel
|
75
|
+
extend BaseModel
|
76
|
+
extend BaseSlashModel
|
77
|
+
|
78
|
+
TEXT_ELEMENTS = {
|
79
|
+
"department" => nil,
|
80
|
+
"section" => nil,
|
81
|
+
"comments" => nil,
|
82
|
+
"hit_parade" => nil
|
83
|
+
}
|
84
|
+
|
85
|
+
ELEMENT_NAME_INFOS = SlashModel::TEXT_ELEMENTS.to_a
|
86
|
+
|
87
|
+
ELEMENTS = TEXT_ELEMENTS.keys
|
88
|
+
|
89
|
+
ELEMENTS.each do |name, plural_name|
|
90
|
+
module_eval(<<-EOC, *get_file_and_line_from_caller(0))
|
91
|
+
class Slash#{Utils.to_class_name(name)} < Element
|
92
|
+
include RSS10
|
93
|
+
|
94
|
+
content_setup
|
95
|
+
|
96
|
+
class << self
|
97
|
+
def required_prefix
|
98
|
+
SLASH_PREFIX
|
99
|
+
end
|
100
|
+
|
101
|
+
def required_uri
|
102
|
+
SLASH_URI
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
@tag_name = #{name.dump}
|
107
|
+
|
108
|
+
alias_method(:value, :content)
|
109
|
+
alias_method(:value=, :content=)
|
110
|
+
|
111
|
+
def initialize(*args)
|
112
|
+
begin
|
113
|
+
if Utils.element_initialize_arguments?(args)
|
114
|
+
super
|
115
|
+
else
|
116
|
+
super()
|
117
|
+
self.content = args[0]
|
118
|
+
end
|
119
|
+
# Older Ruby RSS module
|
120
|
+
rescue NoMethodError
|
121
|
+
super()
|
122
|
+
self.content = args[0]
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def full_name
|
127
|
+
tag_name_with_prefix(SLASH_PREFIX)
|
128
|
+
end
|
129
|
+
|
130
|
+
def maker_target(target)
|
131
|
+
target.new_#{name}
|
132
|
+
end
|
133
|
+
|
134
|
+
def setup_maker_attributes(#{name})
|
135
|
+
#{name}.content = content
|
136
|
+
end
|
137
|
+
end
|
138
|
+
EOC
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
class RDF
|
143
|
+
class Item; include SlashModel; end
|
144
|
+
end
|
145
|
+
|
146
|
+
SlashModel::ELEMENTS.each do |name|
|
147
|
+
class_name = Utils.to_class_name(name)
|
148
|
+
BaseListener.install_class_name(SLASH_URI, name, "Slash#{class_name}")
|
149
|
+
end
|
150
|
+
|
151
|
+
SlashModel::ELEMENTS.collect! {|name| "#{SLASH_PREFIX}_#{name}"}
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
class ::RssBlob
|
157
|
+
attr_accessor :url, :handle, :type, :refresh_rate, :xml, :title, :items,
|
158
|
+
:mutex, :watchers, :last_fetched
|
159
|
+
|
160
|
+
def initialize(url,handle=nil,type=nil,watchers=[], xml=nil, lf = nil)
|
161
|
+
@url = url
|
162
|
+
if handle
|
163
|
+
@handle = handle
|
164
|
+
else
|
165
|
+
@handle = url
|
166
|
+
end
|
167
|
+
@type = type
|
168
|
+
@watchers=[]
|
169
|
+
@refresh_rate = nil
|
170
|
+
@xml = xml
|
171
|
+
@title = nil
|
172
|
+
@items = nil
|
173
|
+
@mutex = Mutex.new
|
174
|
+
@last_fetched = lf
|
175
|
+
sanitize_watchers(watchers)
|
176
|
+
end
|
177
|
+
|
178
|
+
def dup
|
179
|
+
@mutex.synchronize do
|
180
|
+
self.class.new(@url,
|
181
|
+
@handle,
|
182
|
+
@type ? @type.dup : nil,
|
183
|
+
@watchers.dup,
|
184
|
+
@xml ? @xml.dup : nil,
|
185
|
+
@last_fetched)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# Downcase all watchers, possibly turning them into Strings if they weren't
|
190
|
+
def sanitize_watchers(list=@watchers)
|
191
|
+
ls = list.dup
|
192
|
+
@watchers.clear
|
193
|
+
ls.each { |w|
|
194
|
+
add_watch(w)
|
195
|
+
}
|
196
|
+
end
|
197
|
+
|
198
|
+
def watched?
|
199
|
+
!@watchers.empty?
|
200
|
+
end
|
201
|
+
|
202
|
+
def watched_by?(who)
|
203
|
+
@watchers.include?(who.downcase)
|
204
|
+
end
|
205
|
+
|
206
|
+
def add_watch(who)
|
207
|
+
if watched_by?(who)
|
208
|
+
return nil
|
209
|
+
end
|
210
|
+
@mutex.synchronize do
|
211
|
+
@watchers << who.downcase
|
212
|
+
end
|
213
|
+
return who
|
214
|
+
end
|
215
|
+
|
216
|
+
def rm_watch(who)
|
217
|
+
@mutex.synchronize do
|
218
|
+
@watchers.delete(who.downcase)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def to_a
|
223
|
+
[@handle,@url,@type,@refresh_rate,@watchers]
|
224
|
+
end
|
225
|
+
|
226
|
+
def to_s(watchers=false)
|
227
|
+
if watchers
|
228
|
+
a = self.to_a.flatten
|
229
|
+
else
|
230
|
+
a = self.to_a[0,3]
|
231
|
+
end
|
232
|
+
a.compact.join(" | ")
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
class RSSFeedsPlugin < Plugin
|
237
|
+
Config.register Config::IntegerValue.new('rss.head_max',
|
238
|
+
:default => 100, :validate => Proc.new{|v| v > 0 && v < 200},
|
239
|
+
:desc => "How many characters to use of a RSS item header")
|
240
|
+
|
241
|
+
Config.register Config::IntegerValue.new('rss.text_max',
|
242
|
+
:default => 200, :validate => Proc.new{|v| v > 0 && v < 400},
|
243
|
+
:desc => "How many characters to use of a RSS item text")
|
244
|
+
|
245
|
+
Config.register Config::IntegerValue.new('rss.thread_sleep',
|
246
|
+
:default => 300, :validate => Proc.new{|v| v > 30},
|
247
|
+
:desc => "How many seconds to sleep before checking RSS feeds again")
|
248
|
+
|
249
|
+
Config.register Config::BooleanValue.new('rss.show_updated',
|
250
|
+
:default => true,
|
251
|
+
:desc => "Whether feed items for which the description was changed should be shown as new")
|
252
|
+
|
253
|
+
Config.register Config::BooleanValue.new('rss.show_links',
|
254
|
+
:default => true,
|
255
|
+
:desc => "Whether to display links from the text of a feed item.")
|
256
|
+
|
257
|
+
# Make an 'unique' ID for a given item, based on appropriate bot options
|
258
|
+
# Currently only suppored is bot.config['rss.show_updated']: when false,
|
259
|
+
# only the guid/link is accounted for.
|
260
|
+
|
261
|
+
def block_rescue(df = nil, &block)
|
262
|
+
v = block.call rescue nil
|
263
|
+
(String === v && '' != v) ? v : nil
|
264
|
+
end
|
265
|
+
|
266
|
+
def make_uid(item)
|
267
|
+
uid = [
|
268
|
+
(block_rescue do item.guid.content end ||
|
269
|
+
block_rescue do item.guid end ||
|
270
|
+
block_rescue do item.link.href end ||
|
271
|
+
block_rescue do item.link end
|
272
|
+
)
|
273
|
+
]
|
274
|
+
if @bot.config['rss.show_updated']
|
275
|
+
uid.push(
|
276
|
+
block_rescue do item.content.content end ||
|
277
|
+
block_rescue do item.description end
|
278
|
+
)
|
279
|
+
uid.unshift(
|
280
|
+
block_rescue do item.title.content end ||
|
281
|
+
block_rescue do item.title end
|
282
|
+
)
|
283
|
+
end
|
284
|
+
# debug "taking hash of #{uid.inspect}"
|
285
|
+
uid.hash
|
286
|
+
end
|
287
|
+
|
288
|
+
|
289
|
+
# We used to save the Mutex with the RssBlob, which was idiotic. And
|
290
|
+
# since Mutexes dumped in one version might not be resotrable in another,
|
291
|
+
# we need a few tricks to be able to restore data from other versions of Ruby
|
292
|
+
#
|
293
|
+
# When migrating 1.8.6 => 1.8.5, all we need to do is define an empty
|
294
|
+
# #marshal_load() method for Mutex. For 1.8.5 => 1.8.6 we need something
|
295
|
+
# dirtier, as seen later on in the initialization code.
|
296
|
+
unless Mutex.new.respond_to?(:marshal_load)
|
297
|
+
class ::Mutex
|
298
|
+
def marshal_load(str)
|
299
|
+
return
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
# Auxiliary method used to collect two lines for rss output filters,
|
305
|
+
# running substitutions against DataStream _s_ optionally joined
|
306
|
+
# with hash _h_
|
307
|
+
def make_stream(line1, line2, s, h={})
|
308
|
+
ss = s.merge(h)
|
309
|
+
DataStream.new([line1, line2].compact.join("\n") % ss, ss)
|
310
|
+
end
|
311
|
+
|
312
|
+
# Define default RSS filters
|
313
|
+
#
|
314
|
+
# TODO: load personal ones
|
315
|
+
def define_filters
|
316
|
+
@outkey = :"rss.out"
|
317
|
+
@bot.register_filter(:blog, @outkey) { |s|
|
318
|
+
author = s[:author] ? (s[:author] + " ") : ""
|
319
|
+
abt = s[:category] ? "about #{s[:category]} " : ""
|
320
|
+
line1 = "%{handle}%{date}%{author}blogged %{abt}at %{link}"
|
321
|
+
line2 = "%{handle}%{title} - %{desc}"
|
322
|
+
make_stream(line1, line2, s, :author => author, :abt => abt)
|
323
|
+
}
|
324
|
+
@bot.register_filter(:photoblog, @outkey) { |s|
|
325
|
+
author = s[:author] ? (s[:author] + " ") : ""
|
326
|
+
abt = s[:category] ? "under #{s[:category]} " : ""
|
327
|
+
line1 = "%{handle}%{date}%{author}added an image %{abt}at %{link}"
|
328
|
+
line2 = "%{handle}%{title} - %{desc}"
|
329
|
+
make_stream(line1, line2, s, :author => author, :abt => abt)
|
330
|
+
}
|
331
|
+
@bot.register_filter(:news, @outkey) { |s|
|
332
|
+
line1 = "%{handle}%{date}%{title} @ %{link}" % s
|
333
|
+
line2 = "%{handle}%{date}%{desc}" % s
|
334
|
+
make_stream(line1, line2, s)
|
335
|
+
}
|
336
|
+
@bot.register_filter(:git, @outkey) { |s|
|
337
|
+
author = s[:author] ? (s[:author] + " ") : ""
|
338
|
+
line1 = "%{handle}%{date}%{author}committed %{title} @ %{link}"
|
339
|
+
make_stream(line1, nil, s, :author => author)
|
340
|
+
}
|
341
|
+
@bot.register_filter(:forum, @outkey) { |s|
|
342
|
+
line1 = "%{handle}%{date}%{title}%{at}%{link}"
|
343
|
+
make_stream(line1, nil, s)
|
344
|
+
}
|
345
|
+
@bot.register_filter(:wiki, @outkey) { |s|
|
346
|
+
line1 = "%{handle}%{date}%{title}%{at}%{link}"
|
347
|
+
line1 << "has been edited by %{author}. %{desc}"
|
348
|
+
make_stream(line1, nil, s)
|
349
|
+
}
|
350
|
+
@bot.register_filter(:gmane, @outkey) { |s|
|
351
|
+
line1 = "%{handle}%{date}Message %{title} sent by %{author}. %{desc}"
|
352
|
+
make_stream(line1, nil, s)
|
353
|
+
}
|
354
|
+
@bot.register_filter(:trac, @outkey) { |s|
|
355
|
+
author = s[:author].sub(/@\S+?\s*>/, "@...>") + ": " if s[:author]
|
356
|
+
line1 = "%{handle}%{date}%{author}%{title} @ %{link}"
|
357
|
+
line2 = nil
|
358
|
+
unless s[:item].title =~ /^(?:Changeset \[(?:[\da-f]+)\]|\(git commit\))/
|
359
|
+
line2 = "%{handle}%{date}%{desc}"
|
360
|
+
end
|
361
|
+
make_stream(line1, line2, s, :author => author)
|
362
|
+
}
|
363
|
+
@bot.register_filter(:"/.", @outkey) { |s|
|
364
|
+
dept = "(from the #{s[:item].slash_department} dept) " rescue nil
|
365
|
+
sec = " in section #{s[:item].slash_section}" rescue nil
|
366
|
+
line1 = "%{handle}%{date}%{dept}%{title}%{at}%{link} "
|
367
|
+
line1 << "(posted by %{author}%{sec})"
|
368
|
+
make_stream(line1, nil, s, :dept => dept, :sec => sec)
|
369
|
+
}
|
370
|
+
@bot.register_filter(:default, @outkey) { |s|
|
371
|
+
line1 = "%{handle}%{date}%{title}%{at}%{link}"
|
372
|
+
line1 << " (by %{author})" if s[:author]
|
373
|
+
make_stream(line1, nil, s)
|
374
|
+
}
|
375
|
+
|
376
|
+
# Define an HTML info filter too
|
377
|
+
@bot.register_filter(:rss, :htmlinfo) { |s| htmlinfo_filter(s) }
|
378
|
+
|
379
|
+
# This is the output format used by the input filter
|
380
|
+
@bot.register_filter(:htmlinfo, @outkey) { |s|
|
381
|
+
line1 = "%{title}%{at}%{link}"
|
382
|
+
make_stream(line1, nil, s)
|
383
|
+
}
|
384
|
+
end
|
385
|
+
|
386
|
+
FEED_NS = %r{xmlns.*http://(purl\.org/rss|www.w3c.org/1999/02/22-rdf)}
|
387
|
+
def htmlinfo_filter(s)
|
388
|
+
return nil unless s[:headers] and s[:headers]['x-rbot-location']
|
389
|
+
return nil unless s[:headers]['content-type'].first.match(/xml|rss|atom|rdf/i) or
|
390
|
+
(s[:text].include?("<rdf:RDF") and s[:text].include?("<channel")) or
|
391
|
+
s[:text].include?("<rss") or s[:text].include?("<feed") or
|
392
|
+
s[:text].match(FEED_NS)
|
393
|
+
blob = RssBlob.new(s[:headers]['x-rbot-location'],"", :htmlinfo)
|
394
|
+
unless (fetchRss(blob, nil) and parseRss(blob, nil) rescue nil)
|
395
|
+
debug "#{s.pretty_inspect} is not an RSS feed, despite the appearances"
|
396
|
+
return nil
|
397
|
+
end
|
398
|
+
output = []
|
399
|
+
blob.items.each { |it|
|
400
|
+
output << printFormattedRss(blob, it)[:text]
|
401
|
+
}
|
402
|
+
return {:title => blob.title, :content => output.join(" | ")}
|
403
|
+
end
|
404
|
+
|
405
|
+
# Display the known rss types
|
406
|
+
def rss_types(m, params)
|
407
|
+
ar = @bot.filter_names(@outkey)
|
408
|
+
ar.delete(:default)
|
409
|
+
m.reply ar.map { |k| k.to_s }.sort!.join(", ")
|
410
|
+
end
|
411
|
+
|
412
|
+
attr_reader :feeds
|
413
|
+
|
414
|
+
def initialize
|
415
|
+
super
|
416
|
+
|
417
|
+
define_filters
|
418
|
+
|
419
|
+
if @registry.has_key?(:feeds)
|
420
|
+
# When migrating from Ruby 1.8.5 to 1.8.6, dumped Mutexes may render the
|
421
|
+
# data unrestorable. If this happens, we patch the data, thus allowing
|
422
|
+
# the restore to work.
|
423
|
+
#
|
424
|
+
# This is actually pretty safe for a number of reasons:
|
425
|
+
# * the code is only called if standard marshalling fails
|
426
|
+
# * the string we look for is quite unlikely to appear randomly
|
427
|
+
# * if the string appears somewhere and the patched string isn't recoverable
|
428
|
+
# either, we'll get another (unrecoverable) error, which makes the rss
|
429
|
+
# plugin unsable, just like it was if no recovery was attempted
|
430
|
+
# * if the string appears somewhere and the patched string is recoverable,
|
431
|
+
# we may get a b0rked feed, which is eventually overwritten by a clean
|
432
|
+
# one, so the worst thing that can happen is that a feed update spams
|
433
|
+
# the watchers once
|
434
|
+
@registry.recovery = Proc.new { |val|
|
435
|
+
patched = val.sub(":\v@mutexo:\nMutex", ":\v@mutexo:\vObject")
|
436
|
+
ret = Marshal.restore(patched)
|
437
|
+
ret.each_value { |blob|
|
438
|
+
blob.mutex = nil
|
439
|
+
blob
|
440
|
+
}
|
441
|
+
}
|
442
|
+
|
443
|
+
@feeds = @registry[:feeds]
|
444
|
+
raise unless @feeds
|
445
|
+
|
446
|
+
@registry.recovery = nil
|
447
|
+
|
448
|
+
@feeds.keys.grep(/[A-Z]/) { |k|
|
449
|
+
@feeds[k.downcase] = @feeds[k]
|
450
|
+
@feeds.delete(k)
|
451
|
+
}
|
452
|
+
@feeds.each { |k, f|
|
453
|
+
f.mutex = Mutex.new
|
454
|
+
f.sanitize_watchers
|
455
|
+
parseRss(f) if f.xml
|
456
|
+
}
|
457
|
+
else
|
458
|
+
@feeds = Hash.new
|
459
|
+
end
|
460
|
+
@watch = Hash.new
|
461
|
+
rewatch_rss
|
462
|
+
end
|
463
|
+
|
464
|
+
def name
|
465
|
+
"rss"
|
466
|
+
end
|
467
|
+
|
468
|
+
def watchlist
|
469
|
+
@feeds.select { |h, f| f.watched? }
|
470
|
+
end
|
471
|
+
|
472
|
+
def cleanup
|
473
|
+
stop_watches
|
474
|
+
super
|
475
|
+
end
|
476
|
+
|
477
|
+
def save
|
478
|
+
unparsed = Hash.new()
|
479
|
+
@feeds.each { |k, f|
|
480
|
+
unparsed[k] = f.dup
|
481
|
+
# we don't want to save the mutex
|
482
|
+
unparsed[k].mutex = nil
|
483
|
+
}
|
484
|
+
@registry[:feeds] = unparsed
|
485
|
+
end
|
486
|
+
|
487
|
+
def stop_watch(handle)
|
488
|
+
if @watch.has_key?(handle)
|
489
|
+
begin
|
490
|
+
debug "Stopping watch #{handle}"
|
491
|
+
@bot.timer.remove(@watch[handle])
|
492
|
+
@watch.delete(handle)
|
493
|
+
rescue Exception => e
|
494
|
+
report_problem("Failed to stop watch for #{handle}", e, nil)
|
495
|
+
end
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
def stop_watches
|
500
|
+
@watch.each_key { |k|
|
501
|
+
stop_watch(k)
|
502
|
+
}
|
503
|
+
end
|
504
|
+
|
505
|
+
def help(plugin,topic="")
|
506
|
+
case topic
|
507
|
+
when "show"
|
508
|
+
"rss show #{Bold}handle#{Bold} [#{Bold}limit#{Bold}] : show #{Bold}limit#{Bold} (default: 5, max: 15) entries from rss #{Bold}handle#{Bold}; #{Bold}limit#{Bold} can also be in the form a..b, to display a specific range of items"
|
509
|
+
when "list"
|
510
|
+
"rss list [#{Bold}handle#{Bold}] : list all rss feeds (matching #{Bold}handle#{Bold})"
|
511
|
+
when "watched"
|
512
|
+
"rss watched [#{Bold}handle#{Bold}] [in #{Bold}chan#{Bold}]: list all watched rss feeds (matching #{Bold}handle#{Bold}) (in channel #{Bold}chan#{Bold})"
|
513
|
+
when "who", "watches", "who watches"
|
514
|
+
"rss who watches [#{Bold}handle#{Bold}]]: list all watchers for rss feeds (matching #{Bold}handle#{Bold})"
|
515
|
+
when "add"
|
516
|
+
"rss add #{Bold}handle#{Bold} #{Bold}url#{Bold} [#{Bold}type#{Bold}] : add a new rss called #{Bold}handle#{Bold} from url #{Bold}url#{Bold} (of type #{Bold}type#{Bold})"
|
517
|
+
when "change"
|
518
|
+
"rss change #{Bold}what#{Bold} of #{Bold}handle#{Bold} to #{Bold}new#{Bold} : change the #{Underline}handle#{Underline}, #{Underline}url#{Underline}, #{Underline}type#{Underline} or #{Underline}refresh#{Underline} rate of rss called #{Bold}handle#{Bold} to value #{Bold}new#{Bold}"
|
519
|
+
when /^(del(ete)?|rm)$/
|
520
|
+
"rss del(ete)|rm #{Bold}handle#{Bold} : delete rss feed #{Bold}handle#{Bold}"
|
521
|
+
when "replace"
|
522
|
+
"rss replace #{Bold}handle#{Bold} #{Bold}url#{Bold} [#{Bold}type#{Bold}] : try to replace the url of rss called #{Bold}handle#{Bold} with #{Bold}url#{Bold} (of type #{Bold}type#{Bold}); only works if nobody else is watching it"
|
523
|
+
when "forcereplace"
|
524
|
+
"rss forcereplace #{Bold}handle#{Bold} #{Bold}url#{Bold} [#{Bold}type#{Bold}] : replace the url of rss called #{Bold}handle#{Bold} with #{Bold}url#{Bold} (of type #{Bold}type#{Bold})"
|
525
|
+
when "watch"
|
526
|
+
"rss watch #{Bold}handle#{Bold} [#{Bold}url#{Bold} [#{Bold}type#{Bold}]] [in #{Bold}chan#{Bold}]: watch rss #{Bold}handle#{Bold} for changes (in channel #{Bold}chan#{Bold}); when the other parameters are present, the feed will be created if it doesn't exist yet"
|
527
|
+
when /(un|rm)watch/
|
528
|
+
"rss unwatch|rmwatch #{Bold}handle#{Bold} [in #{Bold}chan#{Bold}]: stop watching rss #{Bold}handle#{Bold} (in channel #{Bold}chan#{Bold}) for changes"
|
529
|
+
when /who(?: watche?s?)?/
|
530
|
+
"rss who watches #{Bold}handle#{Bold}: lists watches for rss #{Bold}handle#{Bold}"
|
531
|
+
when "rewatch"
|
532
|
+
"rss rewatch : restart threads that watch for changes in watched rss"
|
533
|
+
when "types"
|
534
|
+
"rss types : show the rss types for which an output format existi (all other types will use the default one)"
|
535
|
+
else
|
536
|
+
"manage RSS feeds: rss types|show|list|watched|add|change|del(ete)|rm|(force)replace|watch|unwatch|rmwatch|rewatch|who watches"
|
537
|
+
end
|
538
|
+
end
|
539
|
+
|
540
|
+
def report_problem(report, e=nil, m=nil)
|
541
|
+
if m && m.respond_to?(:reply)
|
542
|
+
m.reply report
|
543
|
+
else
|
544
|
+
warning report
|
545
|
+
end
|
546
|
+
if e
|
547
|
+
debug e.inspect
|
548
|
+
debug e.backtrace.join("\n") if e.respond_to?(:backtrace)
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
def show_rss(m, params)
|
553
|
+
handle = params[:handle]
|
554
|
+
lims = params[:limit].to_s.match(/(\d+)(?:..(\d+))?/)
|
555
|
+
debug lims.to_a.inspect
|
556
|
+
if lims[2]
|
557
|
+
ll = [[lims[1].to_i-1,lims[2].to_i-1].min, 0].max
|
558
|
+
ul = [[lims[1].to_i-1,lims[2].to_i-1].max, 14].min
|
559
|
+
rev = lims[1].to_i > lims[2].to_i
|
560
|
+
else
|
561
|
+
ll = 0
|
562
|
+
ul = [[lims[1].to_i-1, 0].max, 14].min
|
563
|
+
rev = false
|
564
|
+
end
|
565
|
+
|
566
|
+
feed = @feeds.fetch(handle.downcase, nil)
|
567
|
+
unless feed
|
568
|
+
m.reply "I don't know any feeds named #{handle}"
|
569
|
+
return
|
570
|
+
end
|
571
|
+
|
572
|
+
m.reply "lemme fetch it..."
|
573
|
+
title = items = nil
|
574
|
+
we_were_watching = false
|
575
|
+
|
576
|
+
if @watch.key?(feed.handle)
|
577
|
+
# If a feed is being watched, we run the watcher thread
|
578
|
+
# so that all watchers can be informed of changes to
|
579
|
+
# the feed. Before we do that, though, we remove the
|
580
|
+
# show requester from the watchlist, if present, lest
|
581
|
+
# he gets the update twice.
|
582
|
+
if feed.watched_by?(m.replyto)
|
583
|
+
we_were_watching = true
|
584
|
+
feed.rm_watch(m.replyto)
|
585
|
+
end
|
586
|
+
@bot.timer.reschedule(@watch[feed.handle], 0)
|
587
|
+
if we_were_watching
|
588
|
+
feed.add_watch(m.replyto)
|
589
|
+
end
|
590
|
+
else
|
591
|
+
fetched = fetchRss(feed, m, false)
|
592
|
+
end
|
593
|
+
return unless fetched or feed.xml
|
594
|
+
if fetched or not feed.items
|
595
|
+
parsed = parseRss(feed, m)
|
596
|
+
end
|
597
|
+
return unless feed.items
|
598
|
+
m.reply "using old data" unless fetched and parsed
|
599
|
+
|
600
|
+
title = feed.title
|
601
|
+
items = feed.items
|
602
|
+
|
603
|
+
# We sort the feeds in freshness order (newer ones first)
|
604
|
+
items = freshness_sort(items)
|
605
|
+
disp = items[ll..ul]
|
606
|
+
disp.reverse! if rev
|
607
|
+
|
608
|
+
m.reply "Channel : #{title}"
|
609
|
+
disp.each do |item|
|
610
|
+
printFormattedRss(feed, item, {:places=>[m.replyto],:handle=>nil,:date=>true})
|
611
|
+
end
|
612
|
+
end
|
613
|
+
|
614
|
+
def itemDate(item,ex=nil)
|
615
|
+
return item.pubDate if item.respond_to?(:pubDate) and item.pubDate
|
616
|
+
return item.date if item.respond_to?(:date) and item.date
|
617
|
+
return ex
|
618
|
+
end
|
619
|
+
|
620
|
+
def freshness_sort(items)
|
621
|
+
notime = Time.at(0)
|
622
|
+
items.sort { |a, b|
|
623
|
+
itemDate(b, notime) <=> itemDate(a, notime)
|
624
|
+
}
|
625
|
+
end
|
626
|
+
|
627
|
+
def list_rss(m, params)
|
628
|
+
wanted = params[:handle]
|
629
|
+
reply = String.new
|
630
|
+
@feeds.each { |handle, feed|
|
631
|
+
next if wanted and !handle.match(/#{wanted}/i)
|
632
|
+
reply << "#{feed.handle}: #{feed.url} (in format: #{feed.type ? feed.type : 'default'})"
|
633
|
+
(reply << " refreshing every #{Utils.secs_to_string(feed.refresh_rate)}") if feed.refresh_rate
|
634
|
+
(reply << " (watched)") if feed.watched_by?(m.replyto)
|
635
|
+
reply << "\n"
|
636
|
+
}
|
637
|
+
if reply.empty?
|
638
|
+
reply = "no feeds found"
|
639
|
+
reply << " matching #{wanted}" if wanted
|
640
|
+
end
|
641
|
+
m.reply reply, :max_lines => reply.length
|
642
|
+
end
|
643
|
+
|
644
|
+
def watched_rss(m, params)
|
645
|
+
wanted = params[:handle]
|
646
|
+
chan = params[:chan] || m.replyto
|
647
|
+
reply = String.new
|
648
|
+
watchlist.each { |handle, feed|
|
649
|
+
next if wanted and !handle.match(/#{wanted}/i)
|
650
|
+
next unless feed.watched_by?(chan)
|
651
|
+
reply << "#{feed.handle}: #{feed.url} (in format: #{feed.type ? feed.type : 'default'})"
|
652
|
+
(reply << " refreshing every #{Utils.secs_to_string(feed.refresh_rate)}") if feed.refresh_rate
|
653
|
+
reply << "\n"
|
654
|
+
}
|
655
|
+
if reply.empty?
|
656
|
+
reply = "no watched feeds"
|
657
|
+
reply << " matching #{wanted}" if wanted
|
658
|
+
end
|
659
|
+
m.reply reply
|
660
|
+
end
|
661
|
+
|
662
|
+
def who_watches(m, params)
|
663
|
+
wanted = params[:handle]
|
664
|
+
reply = String.new
|
665
|
+
watchlist.each { |handle, feed|
|
666
|
+
next if wanted and !handle.match(/#{wanted}/i)
|
667
|
+
reply << "#{feed.handle}: #{feed.url} (in format: #{feed.type ? feed.type : 'default'})"
|
668
|
+
(reply << " refreshing every #{Utils.secs_to_string(feed.refresh_rate)}") if feed.refresh_rate
|
669
|
+
reply << ": watched by #{feed.watchers.join(', ')}"
|
670
|
+
reply << "\n"
|
671
|
+
}
|
672
|
+
if reply.empty?
|
673
|
+
reply = "no watched feeds"
|
674
|
+
reply << " matching #{wanted}" if wanted
|
675
|
+
end
|
676
|
+
m.reply reply
|
677
|
+
end
|
678
|
+
|
679
|
+
def add_rss(m, params, force=false)
|
680
|
+
handle = params[:handle]
|
681
|
+
url = params[:url]
|
682
|
+
unless url.match(/https?/)
|
683
|
+
m.reply "I only deal with feeds from HTTP sources, so I can't use #{url} (maybe you forgot the handle?)"
|
684
|
+
return
|
685
|
+
end
|
686
|
+
type = params[:type]
|
687
|
+
if @feeds.fetch(handle.downcase, nil) && !force
|
688
|
+
m.reply "There is already a feed named #{handle} (URL: #{@feeds[handle.downcase].url})"
|
689
|
+
return
|
690
|
+
end
|
691
|
+
unless url
|
692
|
+
m.reply "You must specify both a handle and an url to add an RSS feed"
|
693
|
+
return
|
694
|
+
end
|
695
|
+
@feeds[handle.downcase] = RssBlob.new(url,handle,type)
|
696
|
+
reply = "Added RSS #{url} named #{handle}"
|
697
|
+
if type
|
698
|
+
reply << " (format: #{type})"
|
699
|
+
end
|
700
|
+
m.reply reply
|
701
|
+
return handle
|
702
|
+
end
|
703
|
+
|
704
|
+
def change_rss(m, params)
|
705
|
+
handle = params[:handle].downcase
|
706
|
+
feed = @feeds.fetch(handle, nil)
|
707
|
+
unless feed
|
708
|
+
m.reply "No such feed with handle #{handle}"
|
709
|
+
return
|
710
|
+
end
|
711
|
+
case params[:what].intern
|
712
|
+
when :handle
|
713
|
+
new = params[:new].downcase
|
714
|
+
if @feeds.key?(new) and @feeds[new]
|
715
|
+
m.reply "There already is a feed with handle #{new}"
|
716
|
+
return
|
717
|
+
else
|
718
|
+
feed.mutex.synchronize do
|
719
|
+
@feeds[new] = feed
|
720
|
+
@feeds.delete(handle)
|
721
|
+
feed.handle = new
|
722
|
+
end
|
723
|
+
handle = new
|
724
|
+
end
|
725
|
+
when :url
|
726
|
+
new = params[:new]
|
727
|
+
feed.mutex.synchronize do
|
728
|
+
feed.url = new
|
729
|
+
end
|
730
|
+
when :format, :type
|
731
|
+
new = params[:new]
|
732
|
+
new = nil if new == 'default'
|
733
|
+
feed.mutex.synchronize do
|
734
|
+
feed.type = new
|
735
|
+
end
|
736
|
+
when :refresh
|
737
|
+
new = params[:new].to_i
|
738
|
+
new = nil if new == 0
|
739
|
+
feed.mutex.synchronize do
|
740
|
+
feed.refresh_rate = new
|
741
|
+
end
|
742
|
+
else
|
743
|
+
m.reply "Don't know how to change #{params[:what]} for feeds"
|
744
|
+
return
|
745
|
+
end
|
746
|
+
m.reply "Feed changed:"
|
747
|
+
list_rss(m, {:handle => handle})
|
748
|
+
end
|
749
|
+
|
750
|
+
def del_rss(m, params, pass=false)
|
751
|
+
feed = unwatch_rss(m, params, true)
|
752
|
+
return unless feed
|
753
|
+
if feed.watched?
|
754
|
+
m.reply "someone else is watching #{feed.handle}, I won't remove it from my list"
|
755
|
+
return
|
756
|
+
end
|
757
|
+
@feeds.delete(feed.handle.downcase)
|
758
|
+
m.okay unless pass
|
759
|
+
return
|
760
|
+
end
|
761
|
+
|
762
|
+
def replace_rss(m, params)
|
763
|
+
handle = params[:handle]
|
764
|
+
if @feeds.key?(handle.downcase)
|
765
|
+
del_rss(m, {:handle => handle}, true)
|
766
|
+
end
|
767
|
+
if @feeds.key?(handle.downcase)
|
768
|
+
m.reply "can't replace #{feed.handle}"
|
769
|
+
else
|
770
|
+
add_rss(m, params, true)
|
771
|
+
end
|
772
|
+
end
|
773
|
+
|
774
|
+
def forcereplace_rss(m, params)
|
775
|
+
add_rss(m, params, true)
|
776
|
+
end
|
777
|
+
|
778
|
+
def watch_rss(m, params)
|
779
|
+
handle = params[:handle]
|
780
|
+
chan = params[:chan] || m.replyto
|
781
|
+
url = params[:url]
|
782
|
+
type = params[:type]
|
783
|
+
if url
|
784
|
+
add_rss(m, params)
|
785
|
+
end
|
786
|
+
feed = @feeds.fetch(handle.downcase, nil)
|
787
|
+
if feed
|
788
|
+
if feed.add_watch(chan)
|
789
|
+
watchRss(feed, m)
|
790
|
+
m.okay
|
791
|
+
else
|
792
|
+
m.reply "Already watching #{feed.handle} in #{chan}"
|
793
|
+
end
|
794
|
+
else
|
795
|
+
m.reply "Couldn't watch feed #{handle} (no such feed found)"
|
796
|
+
end
|
797
|
+
end
|
798
|
+
|
799
|
+
def unwatch_rss(m, params, pass=false)
|
800
|
+
handle = params[:handle].downcase
|
801
|
+
chan = params[:chan] || m.replyto
|
802
|
+
unless @feeds.has_key?(handle)
|
803
|
+
m.reply("dunno that feed")
|
804
|
+
return
|
805
|
+
end
|
806
|
+
feed = @feeds[handle]
|
807
|
+
if feed.rm_watch(chan)
|
808
|
+
m.reply "#{chan} has been removed from the watchlist for #{feed.handle}"
|
809
|
+
else
|
810
|
+
m.reply("#{chan} wasn't watching #{feed.handle}") unless pass
|
811
|
+
end
|
812
|
+
if !feed.watched?
|
813
|
+
stop_watch(handle)
|
814
|
+
end
|
815
|
+
return feed
|
816
|
+
end
|
817
|
+
|
818
|
+
def rewatch_rss(m=nil, params=nil)
|
819
|
+
if params and handle = params[:handle]
|
820
|
+
feed = @feeds.fetch(handle.downcase, nil)
|
821
|
+
if feed
|
822
|
+
@bot.timer.reschedule(@watch[feed.handle], (params[:delay] || 0).to_f)
|
823
|
+
m.okay if m
|
824
|
+
else
|
825
|
+
m.reply _("no such feed %{handle}") % { :handle => handle } if m
|
826
|
+
end
|
827
|
+
else
|
828
|
+
stop_watches
|
829
|
+
|
830
|
+
# Read watches from list.
|
831
|
+
watchlist.each{ |handle, feed|
|
832
|
+
watchRss(feed, m)
|
833
|
+
}
|
834
|
+
m.okay if m
|
835
|
+
end
|
836
|
+
end
|
837
|
+
|
838
|
+
private
|
839
|
+
def watchRss(feed, m=nil)
|
840
|
+
if @watch.has_key?(feed.handle)
|
841
|
+
report_problem("watcher thread for #{feed.handle} is already running", nil, m)
|
842
|
+
return
|
843
|
+
end
|
844
|
+
status = Hash.new
|
845
|
+
status[:failures] = 0
|
846
|
+
tmout = 0
|
847
|
+
if feed.last_fetched
|
848
|
+
tmout = feed.last_fetched + calculate_timeout(feed) - Time.now
|
849
|
+
tmout = 0 if tmout < 0
|
850
|
+
end
|
851
|
+
debug "scheduling a watcher for #{feed} in #{tmout} seconds"
|
852
|
+
@watch[feed.handle] = @bot.timer.add(tmout) {
|
853
|
+
debug "watcher for #{feed} wakes up"
|
854
|
+
failures = status[:failures]
|
855
|
+
begin
|
856
|
+
debug "fetching #{feed}"
|
857
|
+
first_run = !feed.last_fetched
|
858
|
+
oldxml = feed.xml ? feed.xml.dup : nil
|
859
|
+
unless fetchRss(feed)
|
860
|
+
failures += 1
|
861
|
+
else
|
862
|
+
if first_run
|
863
|
+
debug "first run for #{feed}, getting items"
|
864
|
+
parseRss(feed)
|
865
|
+
elsif oldxml and oldxml == feed.xml
|
866
|
+
debug "xml for #{feed} didn't change"
|
867
|
+
failures -= 1 if failures > 0
|
868
|
+
else
|
869
|
+
if not feed.items
|
870
|
+
debug "no previous items in feed #{feed}"
|
871
|
+
parseRss(feed)
|
872
|
+
failures -= 1 if failures > 0
|
873
|
+
else
|
874
|
+
# This one is used for debugging
|
875
|
+
otxt = []
|
876
|
+
|
877
|
+
# These are used for checking new items vs old ones
|
878
|
+
oids = Set.new feed.items.map { |item|
|
879
|
+
uid = make_uid item
|
880
|
+
otxt << item.to_s
|
881
|
+
debug [uid, item].inspect
|
882
|
+
debug [uid, otxt.last].inspect
|
883
|
+
uid
|
884
|
+
}
|
885
|
+
|
886
|
+
unless parseRss(feed)
|
887
|
+
debug "no items in feed #{feed}"
|
888
|
+
failures += 1
|
889
|
+
else
|
890
|
+
debug "Checking if new items are available for #{feed}"
|
891
|
+
failures -= 1 if failures > 0
|
892
|
+
# debug "Old:"
|
893
|
+
# debug oldxml
|
894
|
+
# debug "New:"
|
895
|
+
# debug feed.xml
|
896
|
+
|
897
|
+
dispItems = feed.items.reject { |item|
|
898
|
+
uid = make_uid item
|
899
|
+
txt = item.to_s
|
900
|
+
if oids.include?(uid)
|
901
|
+
debug "rejecting old #{uid} #{item.inspect}"
|
902
|
+
debug [uid, txt].inspect
|
903
|
+
true
|
904
|
+
else
|
905
|
+
debug "accepting new #{uid} #{item.inspect}"
|
906
|
+
debug [uid, txt].inspect
|
907
|
+
warning "same text! #{txt}" if otxt.include?(txt)
|
908
|
+
false
|
909
|
+
end
|
910
|
+
}
|
911
|
+
|
912
|
+
if dispItems.length > 0
|
913
|
+
debug "Found #{dispItems.length} new items in #{feed}"
|
914
|
+
# When displaying watched feeds, publish them from older to newer
|
915
|
+
dispItems.reverse.each { |item|
|
916
|
+
printFormattedRss(feed, item)
|
917
|
+
}
|
918
|
+
else
|
919
|
+
debug "No new items found in #{feed}"
|
920
|
+
end
|
921
|
+
end
|
922
|
+
end
|
923
|
+
end
|
924
|
+
end
|
925
|
+
rescue Exception => e
|
926
|
+
error "Error watching #{feed}: #{e.inspect}"
|
927
|
+
debug e.backtrace.join("\n")
|
928
|
+
failures += 1
|
929
|
+
end
|
930
|
+
|
931
|
+
status[:failures] = failures
|
932
|
+
|
933
|
+
seconds = calculate_timeout(feed, failures)
|
934
|
+
debug "watcher for #{feed} going to sleep #{seconds} seconds.."
|
935
|
+
begin
|
936
|
+
@bot.timer.reschedule(@watch[feed.handle], seconds)
|
937
|
+
rescue
|
938
|
+
warning "watcher for #{feed} failed to reschedule: #{$!.inspect}"
|
939
|
+
end
|
940
|
+
}
|
941
|
+
debug "watcher for #{feed} added"
|
942
|
+
end
|
943
|
+
|
944
|
+
def calculate_timeout(feed, failures = 0)
|
945
|
+
seconds = @bot.config['rss.thread_sleep']
|
946
|
+
feed.mutex.synchronize do
|
947
|
+
seconds = feed.refresh_rate if feed.refresh_rate
|
948
|
+
end
|
949
|
+
seconds *= failures + 1
|
950
|
+
seconds += seconds * (rand(100)-50)/100
|
951
|
+
return seconds
|
952
|
+
end
|
953
|
+
|
954
|
+
def select_nonempty(*ar)
|
955
|
+
# debug ar
|
956
|
+
ar.each { |i| return i unless i.nil_or_empty? }
|
957
|
+
return nil
|
958
|
+
end
|
959
|
+
|
960
|
+
def printFormattedRss(feed, item, opts=nil)
|
961
|
+
# debug item
|
962
|
+
places = feed.watchers
|
963
|
+
handle = feed.handle.empty? ? "" : "::#{feed.handle}:: "
|
964
|
+
date = String.new
|
965
|
+
if opts
|
966
|
+
places = opts[:places] if opts.key?(:places)
|
967
|
+
handle = opts[:handle].to_s if opts.key?(:handle)
|
968
|
+
if opts.key?(:date) && opts[:date]
|
969
|
+
if item.respond_to?(:updated)
|
970
|
+
if item.updated.content.class <= Time
|
971
|
+
date = item.updated.content.strftime("%Y/%m/%d %H:%M")
|
972
|
+
else
|
973
|
+
date = item.updated.content.to_s
|
974
|
+
end
|
975
|
+
elsif item.respond_to?(:source) and item.source.respond_to?(:updated)
|
976
|
+
if item.source.updated.content.class <= Time
|
977
|
+
date = item.source.updated.content.strftime("%Y/%m/%d %H:%M")
|
978
|
+
else
|
979
|
+
date = item.source.updated.content.to_s
|
980
|
+
end
|
981
|
+
elsif item.respond_to?(:pubDate)
|
982
|
+
if item.pubDate.class <= Time
|
983
|
+
date = item.pubDate.strftime("%Y/%m/%d %H:%M")
|
984
|
+
else
|
985
|
+
date = item.pubDate.to_s
|
986
|
+
end
|
987
|
+
elsif item.respond_to?(:date)
|
988
|
+
if item.date.class <= Time
|
989
|
+
date = item.date.strftime("%Y/%m/%d %H:%M")
|
990
|
+
else
|
991
|
+
date = item.date.to_s
|
992
|
+
end
|
993
|
+
else
|
994
|
+
date = "(no date)"
|
995
|
+
end
|
996
|
+
date += " :: "
|
997
|
+
end
|
998
|
+
end
|
999
|
+
|
1000
|
+
tit_opt = {}
|
1001
|
+
# Twitters don't need a cap on the title length since they have a hard
|
1002
|
+
# limit to 160 characters, and most of them are under 140 characters
|
1003
|
+
tit_opt[:limit] = @bot.config['rss.head_max'] unless feed.type == 'twitter'
|
1004
|
+
|
1005
|
+
if item.title
|
1006
|
+
base_title = item.title.to_s.dup
|
1007
|
+
# git changesets are SHA1 hashes (40 hex digits), way too long, get rid of them, as they are
|
1008
|
+
# visible in the URL anyway
|
1009
|
+
# TODO make this optional?
|
1010
|
+
base_title.sub!(/^Changeset \[([\da-f]{40})\]:/) { |c| "(git commit)"} if feed.type == 'trac'
|
1011
|
+
title = "#{Bold}#{base_title.ircify_html(tit_opt)}#{Bold}"
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
desc_opt = {}
|
1015
|
+
desc_opt[:limit] = @bot.config['rss.text_max']
|
1016
|
+
desc_opt[:a_href] = :link_out if @bot.config['rss.show_links']
|
1017
|
+
|
1018
|
+
# We prefer content_encoded here as it tends to provide more html formatting
|
1019
|
+
# for use with ircify_html.
|
1020
|
+
if item.respond_to?(:content_encoded) && item.content_encoded
|
1021
|
+
desc = item.content_encoded.ircify_html(desc_opt)
|
1022
|
+
elsif item.respond_to?(:description) && item.description
|
1023
|
+
desc = item.description.ircify_html(desc_opt)
|
1024
|
+
elsif item.respond_to?(:content) && item.content
|
1025
|
+
if item.content.type == "html"
|
1026
|
+
desc = item.content.content.ircify_html(desc_opt)
|
1027
|
+
else
|
1028
|
+
desc = item.content.content
|
1029
|
+
if desc.size > desc_opt[:limit]
|
1030
|
+
desc = desc.slice(0, desc_opt[:limit]) + "#{Reverse}...#{Reverse}"
|
1031
|
+
end
|
1032
|
+
end
|
1033
|
+
else
|
1034
|
+
desc = "(?)"
|
1035
|
+
end
|
1036
|
+
|
1037
|
+
link = item.link.href rescue item.link rescue nil
|
1038
|
+
link.strip! if link
|
1039
|
+
|
1040
|
+
category = select_nonempty((item.category.content rescue nil), (item.dc_subject rescue nil))
|
1041
|
+
category.strip! if category
|
1042
|
+
author = select_nonempty((item.author.name.content rescue nil), (item.dc_creator rescue nil), (item.author rescue nil))
|
1043
|
+
author.strip! if author
|
1044
|
+
|
1045
|
+
line1 = nil
|
1046
|
+
line2 = nil
|
1047
|
+
|
1048
|
+
at = ((item.title && item.link) ? ' @ ' : '')
|
1049
|
+
|
1050
|
+
key = @bot.global_filter_name(feed.type, @outkey)
|
1051
|
+
key = @bot.global_filter_name(:default, @outkey) unless @bot.has_filter?(key)
|
1052
|
+
|
1053
|
+
output = @bot.filter(key, :item => item, :handle => handle, :date => date,
|
1054
|
+
:title => title, :desc => desc, :link => link,
|
1055
|
+
:category => category, :author => author, :at => at)
|
1056
|
+
|
1057
|
+
return output if places.empty?
|
1058
|
+
|
1059
|
+
places.each { |loc|
|
1060
|
+
output.to_s.each_line { |line|
|
1061
|
+
@bot.say loc, line, :overlong => :truncate
|
1062
|
+
}
|
1063
|
+
}
|
1064
|
+
end
|
1065
|
+
|
1066
|
+
def fetchRss(feed, m=nil, cache=true)
|
1067
|
+
feed.last_fetched = Time.now
|
1068
|
+
begin
|
1069
|
+
# Use 60 sec timeout, cause the default is too low
|
1070
|
+
xml = @bot.httputil.get(feed.url,
|
1071
|
+
:read_timeout => 60,
|
1072
|
+
:open_timeout => 60,
|
1073
|
+
:cache => cache)
|
1074
|
+
rescue URI::InvalidURIError, URI::BadURIError => e
|
1075
|
+
report_problem("invalid rss feed #{feed.url}", e, m)
|
1076
|
+
return nil
|
1077
|
+
rescue => e
|
1078
|
+
report_problem("error getting #{feed.url}", e, m)
|
1079
|
+
return nil
|
1080
|
+
end
|
1081
|
+
debug "fetched #{feed}"
|
1082
|
+
unless xml
|
1083
|
+
report_problem("reading feed #{feed} failed", nil, m)
|
1084
|
+
return nil
|
1085
|
+
end
|
1086
|
+
# Ok, 0.9 feeds are not supported, maybe because
|
1087
|
+
# Netscape happily removed the DTD. So what we do is just to
|
1088
|
+
# reassign the 0.9 RDFs to 1.0, and hope it goes right.
|
1089
|
+
xml.gsub!("xmlns=\"http://my.netscape.com/rdf/simple/0.9/\"",
|
1090
|
+
"xmlns=\"http://purl.org/rss/1.0/\"")
|
1091
|
+
feed.mutex.synchronize do
|
1092
|
+
feed.xml = xml
|
1093
|
+
end
|
1094
|
+
return true
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
def parseRss(feed, m=nil)
|
1098
|
+
return nil unless feed.xml
|
1099
|
+
feed.mutex.synchronize do
|
1100
|
+
xml = feed.xml
|
1101
|
+
begin
|
1102
|
+
## do validate parse
|
1103
|
+
rss = RSS::Parser.parse(xml)
|
1104
|
+
debug "parsed and validated #{feed}"
|
1105
|
+
rescue RSS::InvalidRSSError
|
1106
|
+
## do non validate parse for invalid RSS 1.0
|
1107
|
+
begin
|
1108
|
+
rss = RSS::Parser.parse(xml, false)
|
1109
|
+
debug "parsed but not validated #{feed}"
|
1110
|
+
rescue RSS::Error => e
|
1111
|
+
report_problem("parsing rss stream failed, whoops =(", e, m)
|
1112
|
+
return nil
|
1113
|
+
end
|
1114
|
+
rescue RSS::Error => e
|
1115
|
+
report_problem("parsing rss stream failed, oioi", e, m)
|
1116
|
+
return nil
|
1117
|
+
rescue => e
|
1118
|
+
report_problem("processing error occured, sorry =(", e, m)
|
1119
|
+
return nil
|
1120
|
+
end
|
1121
|
+
items = []
|
1122
|
+
if rss.nil?
|
1123
|
+
if xml.match(/xmlns\s*=\s*(['"])http:\/\/www.w3.org\/2005\/Atom\1/) and not defined?(RSS::Atom)
|
1124
|
+
report_problem("#{feed.handle} @ #{feed.url} looks like an Atom feed, but your Ruby/RSS library doesn't seem to support it. Consider getting the latest version from http://raa.ruby-lang.org/project/rss/", nil, m)
|
1125
|
+
else
|
1126
|
+
report_problem("#{feed.handle} @ #{feed.url} doesn't seem to contain an RSS or Atom feed I can read", nil, m)
|
1127
|
+
end
|
1128
|
+
return nil
|
1129
|
+
else
|
1130
|
+
begin
|
1131
|
+
rss.output_encoding = 'UTF-8'
|
1132
|
+
rescue RSS::UnknownConvertMethod => e
|
1133
|
+
report_problem("bah! something went wrong =(", e, m)
|
1134
|
+
return nil
|
1135
|
+
end
|
1136
|
+
if rss.respond_to? :channel
|
1137
|
+
rss.channel.title ||= "(?)"
|
1138
|
+
title = rss.channel.title
|
1139
|
+
else
|
1140
|
+
title = rss.title.content
|
1141
|
+
end
|
1142
|
+
rss.items.each do |item|
|
1143
|
+
item.title ||= "(?)"
|
1144
|
+
items << item
|
1145
|
+
end
|
1146
|
+
end
|
1147
|
+
|
1148
|
+
if items.empty?
|
1149
|
+
report_problem("no items found in the feed, maybe try weed?", e, m)
|
1150
|
+
return nil
|
1151
|
+
end
|
1152
|
+
feed.title = title
|
1153
|
+
feed.items = items
|
1154
|
+
return true
|
1155
|
+
end
|
1156
|
+
end
|
1157
|
+
end
|
1158
|
+
|
1159
|
+
plugin = RSSFeedsPlugin.new
|
1160
|
+
|
1161
|
+
plugin.default_auth( 'edit', false )
|
1162
|
+
plugin.default_auth( 'edit:add', true)
|
1163
|
+
|
1164
|
+
plugin.map 'rss show :handle :limit',
|
1165
|
+
:action => 'show_rss',
|
1166
|
+
:requirements => {:limit => /^\d+(?:\.\.\d+)?$/},
|
1167
|
+
:defaults => {:limit => 5}
|
1168
|
+
plugin.map 'rss list :handle',
|
1169
|
+
:action => 'list_rss',
|
1170
|
+
:defaults => {:handle => nil}
|
1171
|
+
plugin.map 'rss watched :handle [in :chan]',
|
1172
|
+
:action => 'watched_rss',
|
1173
|
+
:defaults => {:handle => nil}
|
1174
|
+
plugin.map 'rss who watches :handle',
|
1175
|
+
:action => 'who_watches',
|
1176
|
+
:defaults => {:handle => nil}
|
1177
|
+
plugin.map 'rss add :handle :url :type',
|
1178
|
+
:action => 'add_rss',
|
1179
|
+
:auth_path => 'edit',
|
1180
|
+
:defaults => {:type => nil}
|
1181
|
+
plugin.map 'rss change :what of :handle to :new',
|
1182
|
+
:action => 'change_rss',
|
1183
|
+
:auth_path => 'edit',
|
1184
|
+
:requirements => { :what => /handle|url|format|type|refresh/ }
|
1185
|
+
plugin.map 'rss change :what for :handle to :new',
|
1186
|
+
:action => 'change_rss',
|
1187
|
+
:auth_path => 'edit',
|
1188
|
+
:requirements => { :what => /handle|url|format|type|refesh/ }
|
1189
|
+
plugin.map 'rss del :handle',
|
1190
|
+
:auth_path => 'edit:rm!',
|
1191
|
+
:action => 'del_rss'
|
1192
|
+
plugin.map 'rss delete :handle',
|
1193
|
+
:auth_path => 'edit:rm!',
|
1194
|
+
:action => 'del_rss'
|
1195
|
+
plugin.map 'rss rm :handle',
|
1196
|
+
:auth_path => 'edit:rm!',
|
1197
|
+
:action => 'del_rss'
|
1198
|
+
plugin.map 'rss replace :handle :url :type',
|
1199
|
+
:auth_path => 'edit',
|
1200
|
+
:action => 'replace_rss',
|
1201
|
+
:defaults => {:type => nil}
|
1202
|
+
plugin.map 'rss forcereplace :handle :url :type',
|
1203
|
+
:auth_path => 'edit',
|
1204
|
+
:action => 'forcereplace_rss',
|
1205
|
+
:defaults => {:type => nil}
|
1206
|
+
plugin.map 'rss watch :handle [in :chan]',
|
1207
|
+
:action => 'watch_rss',
|
1208
|
+
:defaults => {:url => nil, :type => nil}
|
1209
|
+
plugin.map 'rss watch :handle :url :type [in :chan]',
|
1210
|
+
:action => 'watch_rss',
|
1211
|
+
:defaults => {:url => nil, :type => nil}
|
1212
|
+
plugin.map 'rss unwatch :handle [in :chan]',
|
1213
|
+
:action => 'unwatch_rss'
|
1214
|
+
plugin.map 'rss rmwatch :handle [in :chan]',
|
1215
|
+
:action => 'unwatch_rss'
|
1216
|
+
plugin.map 'rss rewatch [:handle] [:delay]',
|
1217
|
+
:action => 'rewatch_rss'
|
1218
|
+
plugin.map 'rss types',
|
1219
|
+
:action => 'rss_types'
|