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
@@ -1,32 +0,0 @@
|
|
1
|
-
100 auth
|
2
|
-
90 quit
|
3
|
-
90 restart
|
4
|
-
85 config
|
5
|
-
80 nick
|
6
|
-
80 nickserv
|
7
|
-
80 qauth
|
8
|
-
80 http
|
9
|
-
85 autoop
|
10
|
-
70 opme
|
11
|
-
70 mode
|
12
|
-
70 say
|
13
|
-
70 action
|
14
|
-
40 quiet
|
15
|
-
40 talk
|
16
|
-
50 part
|
17
|
-
50 hide
|
18
|
-
50 join
|
19
|
-
15 delquote
|
20
|
-
12 msginsult
|
21
|
-
12 remind_other
|
22
|
-
12 markov
|
23
|
-
5 rmlart
|
24
|
-
5 rmpraise
|
25
|
-
5 keycmd
|
26
|
-
5 lart
|
27
|
-
5 addlart
|
28
|
-
5 addpraise
|
29
|
-
5 remind
|
30
|
-
5 keyword
|
31
|
-
5 addquote
|
32
|
-
5 getquote
|
@@ -1 +0,0 @@
|
|
1
|
-
10 *!*@*
|
data/lib/rbot/auth.rb
DELETED
@@ -1,314 +0,0 @@
|
|
1
|
-
module Irc
|
2
|
-
|
3
|
-
# globmask:: glob to test with
|
4
|
-
# netmask:: netmask to test against
|
5
|
-
# Compare a netmask with a standard IRC glob, e.g foo!bar@baz.com would
|
6
|
-
# match *!*@baz.com, foo!*@*, *!bar@*, etc.
|
7
|
-
def Irc.netmaskmatch( globmask, netmask )
|
8
|
-
regmask = Regexp.escape( globmask )
|
9
|
-
regmask.gsub!( /\\\*/, '.*' )
|
10
|
-
return true if(netmask =~ /#{regmask}/i)
|
11
|
-
return false
|
12
|
-
end
|
13
|
-
|
14
|
-
# check if a string is an actual IRC hostmask
|
15
|
-
def Irc.ismask?(mask)
|
16
|
-
mask =~ /^.+!.+@.+$/
|
17
|
-
end
|
18
|
-
|
19
|
-
Struct.new( 'UserData', :level, :password, :hostmasks )
|
20
|
-
|
21
|
-
# User-level authentication to allow/disallow access to bot commands based
|
22
|
-
# on hostmask and userlevel.
|
23
|
-
class IrcAuth
|
24
|
-
BotConfig.register BotConfigStringValue.new( 'auth.password',
|
25
|
-
:default => 'rbotauth', :wizard => true,
|
26
|
-
:desc => 'Your password for maxing your auth with the bot (used to associate new hostmasks with your owner-status etc)' )
|
27
|
-
BotConfig.register BotConfigIntegerValue.new( 'auth.default_level',
|
28
|
-
:default => 10, :wizard => true,
|
29
|
-
:desc => 'The default level for new/unknown users' )
|
30
|
-
|
31
|
-
# create a new IrcAuth instance.
|
32
|
-
# bot:: associated bot class
|
33
|
-
def initialize(bot)
|
34
|
-
@bot = bot
|
35
|
-
@users = Hash.new do
|
36
|
-
Struct::UserData.new(@bot.config['auth.default_level'], '', [])
|
37
|
-
end
|
38
|
-
@levels = Hash.new(0)
|
39
|
-
@currentUsers = Hash.new( nil )
|
40
|
-
if( File.exist?( "#{@bot.botclass}/users.yaml" ) )
|
41
|
-
File.open( "#{@bot.botclass}/users.yaml" ) { |file|
|
42
|
-
# work around YAML not maintaining the default proc
|
43
|
-
@loadedusers = YAML::parse(file).transform
|
44
|
-
@users.update(@loadedusers)
|
45
|
-
}
|
46
|
-
end
|
47
|
-
if(File.exist?("#{@bot.botclass}/levels.rbot"))
|
48
|
-
IO.foreach("#{@bot.botclass}/levels.rbot") do |line|
|
49
|
-
if(line =~ /\s*(\d+)\s*(\S+)/)
|
50
|
-
level = $1.to_i
|
51
|
-
command = $2
|
52
|
-
@levels[command] = level
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
if @levels.length < 1
|
57
|
-
raise RuntimeError, "No valid levels.rbot found! If you really want a free-for-all bot and this isn't the result of a previous error, write a proper levels.rbot"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# save current users and levels to files.
|
62
|
-
# levels are written to #{botclass}/levels.rbot
|
63
|
-
# users are written to #{botclass}/users.yaml
|
64
|
-
def save
|
65
|
-
Dir.mkdir("#{@bot.botclass}") if(!File.exist?("#{@bot.botclass}"))
|
66
|
-
begin
|
67
|
-
debug "Writing new users.yaml ..."
|
68
|
-
File.open("#{@bot.botclass}/users.yaml.new", 'w') do |file|
|
69
|
-
file.puts @users.to_yaml
|
70
|
-
end
|
71
|
-
debug "Officializing users.yaml ..."
|
72
|
-
File.rename("#{@bot.botclass}/users.yaml.new",
|
73
|
-
"#{@bot.botclass}/users.yaml")
|
74
|
-
rescue
|
75
|
-
error "failed to write configuration file users.yaml! #{$!}"
|
76
|
-
error "#{e.class}: #{e}"
|
77
|
-
error e.backtrace.join("\n")
|
78
|
-
end
|
79
|
-
begin
|
80
|
-
debug "Writing new levels.rbot ..."
|
81
|
-
File.open("#{@bot.botclass}/levels.rbot.new", 'w') do |file|
|
82
|
-
@levels.each do |key, value|
|
83
|
-
file.puts "#{value} #{key}"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
debug "Officializing levels.rbot ..."
|
87
|
-
File.rename("#{@bot.botclass}/levels.rbot.new",
|
88
|
-
"#{@bot.botclass}/levels.rbot")
|
89
|
-
rescue
|
90
|
-
error "failed to write configuration file levels.rbot! #{$!}"
|
91
|
-
error "#{e.class}: #{e}"
|
92
|
-
error e.backtrace.join("\n")
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# command:: command user wishes to perform
|
97
|
-
# mask:: hostmask of user
|
98
|
-
# tell:: optional recipient for "insufficient auth" message
|
99
|
-
#
|
100
|
-
# returns true if user with hostmask +mask+ is permitted to perform
|
101
|
-
# +command+ optionally pass tell as the target for the "insufficient auth"
|
102
|
-
# message, if the user is not authorised
|
103
|
-
def allow?( command, mask, tell=nil )
|
104
|
-
auth = @users[matchingUser(mask)].level # Directly using @users[] is possible, because UserData has a default setting
|
105
|
-
if( auth >= @levels[command] )
|
106
|
-
return true
|
107
|
-
else
|
108
|
-
debug "#{mask} is not allowed to perform #{command}"
|
109
|
-
@bot.say tell, "insufficient \"#{command}\" auth (have #{auth}, need #{@levels[command]})" if tell
|
110
|
-
return false
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
# add user with hostmask matching +mask+ with initial auth level +level+
|
115
|
-
def useradd( username, level=@bot.config['auth.default_level'], password='', hostmask='*!*@*' )
|
116
|
-
@users[username] = Struct::UserData.new( level, password, [hostmask] ) if ! @users.has_key? username
|
117
|
-
end
|
118
|
-
|
119
|
-
# mask:: mask of user to remove
|
120
|
-
# remove user with mask +mask+
|
121
|
-
def userdel( username )
|
122
|
-
@users.delete( username ) if @users.has_key? username
|
123
|
-
end
|
124
|
-
|
125
|
-
def usermod( username, item, value=nil )
|
126
|
-
if @users.has_key?( username )
|
127
|
-
case item
|
128
|
-
when 'hostmask'
|
129
|
-
if Irc.ismask?( value )
|
130
|
-
@users[username].hostmasks = [ value ]
|
131
|
-
return true
|
132
|
-
end
|
133
|
-
when '+hostmask'
|
134
|
-
if Irc.ismask?( value )
|
135
|
-
@users[username].hostmasks += [ value ]
|
136
|
-
return true
|
137
|
-
end
|
138
|
-
when '-hostmask'
|
139
|
-
if Irc.ismask?( value )
|
140
|
-
@users[username].hostmasks -= [ value ]
|
141
|
-
return true
|
142
|
-
end
|
143
|
-
when 'password'
|
144
|
-
@users[username].password = value
|
145
|
-
return true
|
146
|
-
when 'level'
|
147
|
-
@users[username].level = value.to_i
|
148
|
-
return true
|
149
|
-
else
|
150
|
-
debug "usermod: Tried to modify unknown item #{item}"
|
151
|
-
# @bot.say tell, "Unknown item #{item}" if tell
|
152
|
-
end
|
153
|
-
end
|
154
|
-
return false
|
155
|
-
end
|
156
|
-
|
157
|
-
# command:: command to adjust
|
158
|
-
# level:: new auth level for the command
|
159
|
-
# set required auth level of +command+ to +level+
|
160
|
-
def setlevel(command, level)
|
161
|
-
@levels[command] = level
|
162
|
-
end
|
163
|
-
|
164
|
-
def matchingUser( mask )
|
165
|
-
currentUser = nil
|
166
|
-
currentLevel = 0
|
167
|
-
@users.each { |user, data| # TODO Will get easier if YPaths are used...
|
168
|
-
if data.level > currentLevel
|
169
|
-
data.hostmasks.each { |hostmask|
|
170
|
-
if Irc.netmaskmatch( hostmask, mask )
|
171
|
-
currentUser = user
|
172
|
-
currentLevel = data.level
|
173
|
-
end
|
174
|
-
}
|
175
|
-
end
|
176
|
-
}
|
177
|
-
currentUser
|
178
|
-
end
|
179
|
-
|
180
|
-
def identify( mask, username, password )
|
181
|
-
return false unless @users.has_key?(username) && @users[username].password == password
|
182
|
-
@bot.auth.usermod( username, '+hostmask', mask )
|
183
|
-
return true
|
184
|
-
end
|
185
|
-
|
186
|
-
# return all currently defined commands (for which auth is required) and
|
187
|
-
# their required authlevels
|
188
|
-
def showlevels
|
189
|
-
reply = 'Current levels are:'
|
190
|
-
@levels.sort.each { |key, value|
|
191
|
-
reply += " #{key}(#{value})"
|
192
|
-
}
|
193
|
-
reply
|
194
|
-
end
|
195
|
-
|
196
|
-
# return all currently defined users and their authlevels
|
197
|
-
def showusers
|
198
|
-
reply = 'Current users are:'
|
199
|
-
@users.sort.each { |key, value|
|
200
|
-
reply += " #{key}(#{value.level})"
|
201
|
-
}
|
202
|
-
reply
|
203
|
-
end
|
204
|
-
|
205
|
-
def showdetails( username )
|
206
|
-
if @users.has_key? username
|
207
|
-
reply = "#{username}(#{@users[username].level}):"
|
208
|
-
@users[username].hostmasks.each { |hostmask|
|
209
|
-
reply += " #{hostmask}"
|
210
|
-
}
|
211
|
-
end
|
212
|
-
reply
|
213
|
-
end
|
214
|
-
|
215
|
-
# module help
|
216
|
-
def help(topic='')
|
217
|
-
case topic
|
218
|
-
when 'setlevel'
|
219
|
-
return 'setlevel <command> <level> => Sets required level for <command> to <level> (private addressing only)'
|
220
|
-
when 'useradd'
|
221
|
-
return 'useradd <username> => Add user <mask>, you still need to set him up correctly (private addressing only)'
|
222
|
-
when 'userdel'
|
223
|
-
return 'userdel <username> => Remove user <username> (private addressing only)'
|
224
|
-
when 'usermod'
|
225
|
-
return 'usermod <username> <item> <value> => Modify <username>s settings. Valid <item>s are: hostmask, (+|-)hostmask, password, level (private addressing only)'
|
226
|
-
when 'auth'
|
227
|
-
return 'auth <masterpw> => Create a user with your hostmask and master password as bot master (private addressing only)'
|
228
|
-
when 'levels'
|
229
|
-
return 'levels => list commands and their required levels (private addressing only)'
|
230
|
-
when 'users'
|
231
|
-
return 'users [<username>]=> list users and their levels or details about <username> (private addressing only)'
|
232
|
-
when 'whoami'
|
233
|
-
return 'whoami => Show as whom you are recognized (private addressing only)'
|
234
|
-
when 'identify'
|
235
|
-
return 'identify <username> <password> => Identify your hostmask as belonging to <username> (private addressing only)'
|
236
|
-
else
|
237
|
-
return 'Auth module (User authentication) topics: setlevel, useradd, userdel, usermod, auth, levels, users, whoami, identify'
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
# privmsg handler
|
242
|
-
def privmsg(m)
|
243
|
-
if(m.address? && m.private?)
|
244
|
-
case m.message
|
245
|
-
when (/^setlevel\s+(\S+)\s+(\d+)$/)
|
246
|
-
if( @bot.auth.allow?( 'auth', m.source, m.replyto ) )
|
247
|
-
@bot.auth.setlevel( $1, $2.to_i )
|
248
|
-
m.reply "level for #$1 set to #$2"
|
249
|
-
end
|
250
|
-
when( /^useradd\s+(\S+)/ ) # FIXME Needs review!!! (\s+(\S+)(\s+(\S+)(\s+(\S+))?)?)? Should this part be added to make complete useradds possible?
|
251
|
-
if( @bot.auth.allow?( 'auth', m.source, m.replyto ) )
|
252
|
-
@bot.auth.useradd( $1 )
|
253
|
-
m.reply "added user #$1, please set him up correctly"
|
254
|
-
end
|
255
|
-
when( /^userdel\s+(\S+)/ )
|
256
|
-
if( @bot.auth.allow?( 'auth', m.source, m.replyto ) )
|
257
|
-
@bot.auth.userdel( $1 )
|
258
|
-
m.reply "user #$1 is gone"
|
259
|
-
end
|
260
|
-
when( /^usermod\s+(\S+)\s+(\S+)\s+(\S+)/ )
|
261
|
-
if( @bot.auth.allow?('auth', m.source, m.replyto ) )
|
262
|
-
if( @bot.auth.usermod( $1, $2, $3 ) )
|
263
|
-
m.reply "Set #$2 of #$1 to #$3"
|
264
|
-
else
|
265
|
-
m.reply "Failed to set #$2 of #$1 to #$3"
|
266
|
-
end
|
267
|
-
end
|
268
|
-
when( /^setpassword\s+(\S+)/ )
|
269
|
-
password = $1
|
270
|
-
user = @bot.auth.matchingUser( m.source )
|
271
|
-
if user
|
272
|
-
if @bot.auth.usermod(user, 'password', password)
|
273
|
-
m.reply "Your password has been set to #{password}"
|
274
|
-
else
|
275
|
-
m.reply "Couldn't set password"
|
276
|
-
end
|
277
|
-
else
|
278
|
-
m.reply 'You don\'t belong to any user.'
|
279
|
-
end
|
280
|
-
when (/^auth\s+(\S+)/)
|
281
|
-
if( $1 == @bot.config['auth.password'] )
|
282
|
-
if ! @users.has_key? 'master'
|
283
|
-
@bot.auth.useradd( 'master', 1000, @bot.config['auth.password'], m.source )
|
284
|
-
else
|
285
|
-
@bot.auth.usermod( 'master', '+hostmask', m.source )
|
286
|
-
end
|
287
|
-
m.reply 'Identified, security level maxed out'
|
288
|
-
else
|
289
|
-
m.reply 'Incorrect password'
|
290
|
-
end
|
291
|
-
when( /^identify\s+(\S+)\s+(\S+)/ )
|
292
|
-
if @bot.auth.identify( m.source, $1, $2 )
|
293
|
-
m.reply "Identified as #$1 (#{@users[$1].level})"
|
294
|
-
else
|
295
|
-
m.reply 'Incorrect username/password'
|
296
|
-
end
|
297
|
-
when( 'whoami' )
|
298
|
-
user = @bot.auth.matchingUser( m.source )
|
299
|
-
if user
|
300
|
-
m.reply "I recognize you as #{user} (#{@users[user].level})"
|
301
|
-
else
|
302
|
-
m.reply 'You don\'t belong to any user.'
|
303
|
-
end
|
304
|
-
when( /^users\s+(\S+)/ )
|
305
|
-
m.reply @bot.auth.showdetails( $1 ) if( @bot.auth.allow?( 'auth', m.source, m.replyto ) )
|
306
|
-
when ( 'levels' )
|
307
|
-
m.reply @bot.auth.showlevels if( @bot.auth.allow?( 'config', m.source, m.replyto ) )
|
308
|
-
when ( 'users' )
|
309
|
-
m.reply @bot.auth.showusers if( @bot.auth.allow?( 'users', m.source, m.replyto ) )
|
310
|
-
end
|
311
|
-
end
|
312
|
-
end
|
313
|
-
end
|
314
|
-
end
|
data/lib/rbot/channel.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
module Irc
|
2
|
-
|
3
|
-
# class to store IRC channel data (users, topic, per-channel configurations)
|
4
|
-
class IRCChannel
|
5
|
-
# name of channel
|
6
|
-
attr_reader :name
|
7
|
-
|
8
|
-
# current channel topic
|
9
|
-
attr_reader :topic
|
10
|
-
|
11
|
-
# hash containing users currently in the channel
|
12
|
-
attr_accessor :users
|
13
|
-
|
14
|
-
# if true, bot won't talk in this channel
|
15
|
-
attr_accessor :quiet
|
16
|
-
|
17
|
-
# name:: channel name
|
18
|
-
# create a new IRCChannel
|
19
|
-
def initialize(name)
|
20
|
-
@name = name
|
21
|
-
@users = Hash.new
|
22
|
-
@quiet = false
|
23
|
-
@topic = Topic.new
|
24
|
-
end
|
25
|
-
|
26
|
-
# eg @bot.channels[chan].topic = topic
|
27
|
-
def topic=(name)
|
28
|
-
@topic.name = name
|
29
|
-
end
|
30
|
-
|
31
|
-
# class to store IRC channel topic information
|
32
|
-
class Topic
|
33
|
-
# topic name
|
34
|
-
attr_accessor :name
|
35
|
-
|
36
|
-
# timestamp
|
37
|
-
attr_accessor :timestamp
|
38
|
-
|
39
|
-
# topic set by
|
40
|
-
attr_accessor :by
|
41
|
-
|
42
|
-
def initialize
|
43
|
-
@name = ""
|
44
|
-
end
|
45
|
-
|
46
|
-
# when called like "puts @bots.channels[chan].topic"
|
47
|
-
def to_s
|
48
|
-
@name
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
data/lib/rbot/httputil.rb
DELETED
@@ -1,309 +0,0 @@
|
|
1
|
-
module Irc
|
2
|
-
module Utils
|
3
|
-
|
4
|
-
require 'resolv'
|
5
|
-
require 'net/http'
|
6
|
-
require 'net/https'
|
7
|
-
Net::HTTP.version_1_2
|
8
|
-
|
9
|
-
# class for making http requests easier (mainly for plugins to use)
|
10
|
-
# this class can check the bot proxy configuration to determine if a proxy
|
11
|
-
# needs to be used, which includes support for per-url proxy configuration.
|
12
|
-
class HttpUtil
|
13
|
-
BotConfig.register BotConfigBooleanValue.new('http.use_proxy',
|
14
|
-
:default => false, :desc => "should a proxy be used for HTTP requests?")
|
15
|
-
BotConfig.register BotConfigStringValue.new('http.proxy_uri', :default => false,
|
16
|
-
:desc => "Proxy server to use for HTTP requests (URI, e.g http://proxy.host:port)")
|
17
|
-
BotConfig.register BotConfigStringValue.new('http.proxy_user',
|
18
|
-
:default => nil,
|
19
|
-
:desc => "User for authenticating with the http proxy (if required)")
|
20
|
-
BotConfig.register BotConfigStringValue.new('http.proxy_pass',
|
21
|
-
:default => nil,
|
22
|
-
:desc => "Password for authenticating with the http proxy (if required)")
|
23
|
-
BotConfig.register BotConfigArrayValue.new('http.proxy_include',
|
24
|
-
:default => [],
|
25
|
-
:desc => "List of regexps to check against a URI's hostname/ip to see if we should use the proxy to access this URI. All URIs are proxied by default if the proxy is set, so this is only required to re-include URIs that might have been excluded by the exclude list. e.g. exclude /.*\.foo\.com/, include bar\.foo\.com")
|
26
|
-
BotConfig.register BotConfigArrayValue.new('http.proxy_exclude',
|
27
|
-
:default => [],
|
28
|
-
:desc => "List of regexps to check against a URI's hostname/ip to see if we should use avoid the proxy to access this URI and access it directly")
|
29
|
-
BotConfig.register BotConfigIntegerValue.new('http.max_redir',
|
30
|
-
:default => 5,
|
31
|
-
:desc => "Maximum number of redirections to be used when getting a document")
|
32
|
-
BotConfig.register BotConfigIntegerValue.new('http.expire_time',
|
33
|
-
:default => 60,
|
34
|
-
:desc => "After how many minutes since last use a cached document is considered to be expired")
|
35
|
-
BotConfig.register BotConfigIntegerValue.new('http.max_cache_time',
|
36
|
-
:default => 60*24,
|
37
|
-
:desc => "After how many minutes since first use a cached document is considered to be expired")
|
38
|
-
BotConfig.register BotConfigIntegerValue.new('http.no_expire_cache',
|
39
|
-
:default => false,
|
40
|
-
:desc => "Set this to true if you want the bot to never expire the cached pages")
|
41
|
-
|
42
|
-
def initialize(bot)
|
43
|
-
@bot = bot
|
44
|
-
@cache = Hash.new
|
45
|
-
@headers = {
|
46
|
-
'User-Agent' => "rbot http util #{$version} (http://linuxbrit.co.uk/rbot/)",
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
# if http_proxy_include or http_proxy_exclude are set, then examine the
|
51
|
-
# uri to see if this is a proxied uri
|
52
|
-
# the in/excludes are a list of regexps, and each regexp is checked against
|
53
|
-
# the server name, and its IP addresses
|
54
|
-
def proxy_required(uri)
|
55
|
-
use_proxy = true
|
56
|
-
if @bot.config["http.proxy_exclude"].empty? && @bot.config["http.proxy_include"].empty?
|
57
|
-
return use_proxy
|
58
|
-
end
|
59
|
-
|
60
|
-
list = [uri.host]
|
61
|
-
begin
|
62
|
-
list.concat Resolv.getaddresses(uri.host)
|
63
|
-
rescue StandardError => err
|
64
|
-
warning "couldn't resolve host uri.host"
|
65
|
-
end
|
66
|
-
|
67
|
-
unless @bot.config["http.proxy_exclude"].empty?
|
68
|
-
re = @bot.config["http.proxy_exclude"].collect{|r| Regexp.new(r)}
|
69
|
-
re.each do |r|
|
70
|
-
list.each do |item|
|
71
|
-
if r.match(item)
|
72
|
-
use_proxy = false
|
73
|
-
break
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
unless @bot.config["http.proxy_include"].empty?
|
79
|
-
re = @bot.config["http.proxy_include"].collect{|r| Regexp.new(r)}
|
80
|
-
re.each do |r|
|
81
|
-
list.each do |item|
|
82
|
-
if r.match(item)
|
83
|
-
use_proxy = true
|
84
|
-
break
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
debug "using proxy for uri #{uri}?: #{use_proxy}"
|
90
|
-
return use_proxy
|
91
|
-
end
|
92
|
-
|
93
|
-
# uri:: Uri to create a proxy for
|
94
|
-
#
|
95
|
-
# return a net/http Proxy object, which is configured correctly for
|
96
|
-
# proxying based on the bot's proxy configuration.
|
97
|
-
# This will include per-url proxy configuration based on the bot config
|
98
|
-
# +http_proxy_include/exclude+ options.
|
99
|
-
def get_proxy(uri)
|
100
|
-
proxy = nil
|
101
|
-
proxy_host = nil
|
102
|
-
proxy_port = nil
|
103
|
-
proxy_user = nil
|
104
|
-
proxy_pass = nil
|
105
|
-
|
106
|
-
if @bot.config["http.use_proxy"]
|
107
|
-
if (ENV['http_proxy'])
|
108
|
-
proxy = URI.parse ENV['http_proxy'] rescue nil
|
109
|
-
end
|
110
|
-
if (@bot.config["http.proxy_uri"])
|
111
|
-
proxy = URI.parse @bot.config["http.proxy_uri"] rescue nil
|
112
|
-
end
|
113
|
-
if proxy
|
114
|
-
debug "proxy is set to #{proxy.host} port #{proxy.port}"
|
115
|
-
if proxy_required(uri)
|
116
|
-
proxy_host = proxy.host
|
117
|
-
proxy_port = proxy.port
|
118
|
-
proxy_user = @bot.config["http.proxy_user"]
|
119
|
-
proxy_pass = @bot.config["http.proxy_pass"]
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
h = Net::HTTP.new(uri.host, uri.port, proxy_host, proxy_port, proxy_user, proxy_port)
|
125
|
-
h.use_ssl = true if uri.scheme == "https"
|
126
|
-
return h
|
127
|
-
end
|
128
|
-
|
129
|
-
# uri:: uri to query (Uri object)
|
130
|
-
# readtimeout:: timeout for reading the response
|
131
|
-
# opentimeout:: timeout for opening the connection
|
132
|
-
#
|
133
|
-
# simple get request, returns (if possible) response body following redirs
|
134
|
-
# and caching if requested
|
135
|
-
# if a block is given, it yields the urls it gets redirected to
|
136
|
-
# TODO we really need something to implement proper caching
|
137
|
-
def get(uri_or_str, readtimeout=10, opentimeout=5, max_redir=@bot.config["http.max_redir"], cache=false)
|
138
|
-
if uri_or_str.class <= URI
|
139
|
-
uri = uri_or_str
|
140
|
-
else
|
141
|
-
uri = URI.parse(uri_or_str.to_s)
|
142
|
-
end
|
143
|
-
|
144
|
-
proxy = get_proxy(uri)
|
145
|
-
proxy.open_timeout = opentimeout
|
146
|
-
proxy.read_timeout = readtimeout
|
147
|
-
|
148
|
-
begin
|
149
|
-
proxy.start() {|http|
|
150
|
-
yield uri.request_uri() if block_given?
|
151
|
-
resp = http.get(uri.request_uri(), @headers)
|
152
|
-
case resp
|
153
|
-
when Net::HTTPSuccess
|
154
|
-
if cache && !(resp.key?('cache-control') && resp['cache-control']=='must-revalidate')
|
155
|
-
k = uri.to_s
|
156
|
-
@cache[k] = Hash.new
|
157
|
-
@cache[k][:body] = resp.body
|
158
|
-
@cache[k][:last_mod] = Time.httpdate(resp['last-modified']) if resp.key?('last-modified')
|
159
|
-
if resp.key?('date')
|
160
|
-
@cache[k][:first_use] = Time.httpdate(resp['date'])
|
161
|
-
@cache[k][:last_use] = Time.httpdate(resp['date'])
|
162
|
-
else
|
163
|
-
now = Time.new
|
164
|
-
@cache[k][:first_use] = now
|
165
|
-
@cache[k][:last_use] = now
|
166
|
-
end
|
167
|
-
@cache[k][:count] = 1
|
168
|
-
end
|
169
|
-
return resp.body
|
170
|
-
when Net::HTTPRedirection
|
171
|
-
debug "Redirecting #{uri} to #{resp['location']}"
|
172
|
-
yield resp['location'] if block_given?
|
173
|
-
if max_redir > 0
|
174
|
-
return get( URI.parse(resp['location']), readtimeout, opentimeout, max_redir-1, cache)
|
175
|
-
else
|
176
|
-
warning "Max redirection reached, not going to #{resp['location']}"
|
177
|
-
end
|
178
|
-
else
|
179
|
-
debug "HttpUtil.get return code #{resp.code} #{resp.body}"
|
180
|
-
end
|
181
|
-
return nil
|
182
|
-
}
|
183
|
-
rescue StandardError, Timeout::Error => e
|
184
|
-
error "HttpUtil.get exception: #{e.inspect}, while trying to get #{uri}"
|
185
|
-
debug e.backtrace.join("\n")
|
186
|
-
end
|
187
|
-
return nil
|
188
|
-
end
|
189
|
-
|
190
|
-
# just like the above, but only gets the head
|
191
|
-
def head(uri_or_str, readtimeout=10, opentimeout=5, max_redir=@bot.config["http.max_redir"])
|
192
|
-
if uri_or_str.class <= URI
|
193
|
-
uri = uri_or_str
|
194
|
-
else
|
195
|
-
uri = URI.parse(uri_or_str.to_s)
|
196
|
-
end
|
197
|
-
|
198
|
-
proxy = get_proxy(uri)
|
199
|
-
proxy.open_timeout = opentimeout
|
200
|
-
proxy.read_timeout = readtimeout
|
201
|
-
|
202
|
-
begin
|
203
|
-
proxy.start() {|http|
|
204
|
-
yield uri.request_uri() if block_given?
|
205
|
-
resp = http.head(uri.request_uri(), @headers)
|
206
|
-
case resp
|
207
|
-
when Net::HTTPSuccess
|
208
|
-
return resp
|
209
|
-
when Net::HTTPRedirection
|
210
|
-
debug "Redirecting #{uri} to #{resp['location']}"
|
211
|
-
yield resp['location'] if block_given?
|
212
|
-
if max_redir > 0
|
213
|
-
return head( URI.parse(resp['location']), readtimeout, opentimeout, max_redir-1)
|
214
|
-
else
|
215
|
-
warning "Max redirection reached, not going to #{resp['location']}"
|
216
|
-
end
|
217
|
-
else
|
218
|
-
debug "HttpUtil.head return code #{resp.code}"
|
219
|
-
end
|
220
|
-
return nil
|
221
|
-
}
|
222
|
-
rescue StandardError, Timeout::Error => e
|
223
|
-
error "HttpUtil.head exception: #{e.inspect}, while trying to get #{uri}"
|
224
|
-
debug e.backtrace.join("\n")
|
225
|
-
end
|
226
|
-
return nil
|
227
|
-
end
|
228
|
-
|
229
|
-
# gets a page from the cache if it's still (assumed to be) valid
|
230
|
-
# TODO remove stale cached pages, except when called with noexpire=true
|
231
|
-
def get_cached(uri_or_str, readtimeout=10, opentimeout=5,
|
232
|
-
max_redir=@bot.config['http.max_redir'],
|
233
|
-
noexpire=@bot.config['http.no_expire_cache'])
|
234
|
-
if uri_or_str.class <= URI
|
235
|
-
uri = uri_or_str
|
236
|
-
else
|
237
|
-
uri = URI.parse(uri_or_str.to_s)
|
238
|
-
end
|
239
|
-
|
240
|
-
k = uri.to_s
|
241
|
-
if !@cache.key?(k)
|
242
|
-
remove_stale_cache unless noexpire
|
243
|
-
return get(uri, readtimeout, opentimeout, max_redir, true)
|
244
|
-
end
|
245
|
-
now = Time.new
|
246
|
-
begin
|
247
|
-
# See if the last-modified header can be used
|
248
|
-
# Assumption: the page was not modified if both the header
|
249
|
-
# and the cached copy have the last-modified value, and it's the same time
|
250
|
-
# If only one of the cached copy and the header have the value, or if the
|
251
|
-
# value is different, we assume that the cached copyis invalid and therefore
|
252
|
-
# get a new one.
|
253
|
-
# On our first try, we tested for last-modified in the webpage first,
|
254
|
-
# and then on the local cache. however, this is stupid (in general),
|
255
|
-
# so we only test for the remote page if the local copy had the header
|
256
|
-
# in the first place.
|
257
|
-
if @cache[k].key?(:last_mod)
|
258
|
-
h = head(uri, readtimeout, opentimeout, max_redir)
|
259
|
-
if h.key?('last-modified')
|
260
|
-
if Time.httpdate(h['last-modified']) == @cache[k][:last_mod]
|
261
|
-
if h.key?('date')
|
262
|
-
@cache[k][:last_use] = Time.httpdate(h['date'])
|
263
|
-
else
|
264
|
-
@cache[k][:last_use] = now
|
265
|
-
end
|
266
|
-
@cache[k][:count] += 1
|
267
|
-
return @cache[k][:body]
|
268
|
-
end
|
269
|
-
remove_stale_cache unless noexpire
|
270
|
-
return get(uri, readtimeout, opentimeout, max_redir, true)
|
271
|
-
end
|
272
|
-
remove_stale_cache unless noexpire
|
273
|
-
return get(uri, readtimeout, opentimeout, max_redir, true)
|
274
|
-
end
|
275
|
-
rescue => e
|
276
|
-
warning "Error #{e.inspect} getting the page #{uri}, using cache"
|
277
|
-
debug e.backtrace.join("\n")
|
278
|
-
return @cache[k][:body]
|
279
|
-
end
|
280
|
-
# If we still haven't returned, we are dealing with a non-redirected document
|
281
|
-
# that doesn't have the last-modified attribute
|
282
|
-
debug "Could not use last-modified attribute for URL #{uri}, guessing cache validity"
|
283
|
-
if noexpire or !expired?(@cache[k], now)
|
284
|
-
@cache[k][:count] += 1
|
285
|
-
@cache[k][:last_use] = now
|
286
|
-
debug "Using cache"
|
287
|
-
return @cache[k][:body]
|
288
|
-
end
|
289
|
-
debug "Cache expired, getting anew"
|
290
|
-
@cache.delete(k)
|
291
|
-
remove_stale_cache unless noexpire
|
292
|
-
return get(uri, readtimeout, opentimeout, max_redir, true)
|
293
|
-
end
|
294
|
-
|
295
|
-
def expired?(hash, time)
|
296
|
-
(time - hash[:last_use] > @bot.config['http.expire_time']*60) or
|
297
|
-
(time - hash[:first_use] > @bot.config['http.max_cache_time']*60)
|
298
|
-
end
|
299
|
-
|
300
|
-
def remove_stale_cache
|
301
|
-
now = Time.new
|
302
|
-
@cache.reject! { |k, val|
|
303
|
-
!val.key?(:last_modified) && expired?(val, now)
|
304
|
-
}
|
305
|
-
end
|
306
|
-
|
307
|
-
end
|
308
|
-
end
|
309
|
-
end
|