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,961 @@
|
|
1
|
+
#-- vim:sw=2:et
|
2
|
+
#++
|
3
|
+
#
|
4
|
+
# :title: Quiz plugin for rbot
|
5
|
+
#
|
6
|
+
# Author:: Mark Kretschmann <markey@web.de>
|
7
|
+
# Author:: Jocke Andersson <ajocke@gmail.com>
|
8
|
+
# Author:: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
|
9
|
+
# Author:: Yaohan Chen <yaohan.chen@gmail.com>
|
10
|
+
#
|
11
|
+
# Copyright:: (C) 2006 Mark Kretschmann, Jocke Andersson, Giuseppe Bilotta
|
12
|
+
# Copyright:: (C) 2007 Giuseppe Bilotta, Yaohan Chen
|
13
|
+
#
|
14
|
+
# License:: GPL v2
|
15
|
+
#
|
16
|
+
# A trivia quiz game. Fast paced, featureful and fun.
|
17
|
+
|
18
|
+
# FIXME:: interesting fact: in the Quiz class, @registry.has_key? seems to be
|
19
|
+
# case insensitive. Although this is all right for us, this leads to
|
20
|
+
# rank vs registry mismatches. So we have to make the @rank_table
|
21
|
+
# comparisons case insensitive as well. For the moment, redefine
|
22
|
+
# everything to downcase before matching the nick.
|
23
|
+
#
|
24
|
+
# TODO:: define a class for the rank table. We might also need it for scoring
|
25
|
+
# in other games.
|
26
|
+
#
|
27
|
+
# TODO:: when Ruby 2.0 gets out, fix the FIXME 2.0 UTF-8 workarounds
|
28
|
+
|
29
|
+
# Class for storing question/answer pairs
|
30
|
+
define_structure :QuizBundle, :question, :answer
|
31
|
+
|
32
|
+
# Class for storing player stats
|
33
|
+
define_structure :PlayerStats, :score, :jokers, :jokers_time
|
34
|
+
# Why do we still need jokers_time? //Firetech
|
35
|
+
|
36
|
+
# Maximum number of jokers a player can gain
|
37
|
+
Max_Jokers = 3
|
38
|
+
|
39
|
+
# Control codes
|
40
|
+
Color = "\003"
|
41
|
+
Bold = "\002"
|
42
|
+
|
43
|
+
|
44
|
+
#######################################################################
|
45
|
+
# CLASS QuizAnswer
|
46
|
+
# Abstract an answer to a quiz question, by providing self as a string
|
47
|
+
# and a core that can be answered as an alternative. It also provides
|
48
|
+
# a boolean that tells if the core is numeric or not
|
49
|
+
#######################################################################
|
50
|
+
class QuizAnswer
|
51
|
+
attr_writer :info
|
52
|
+
|
53
|
+
def initialize(str)
|
54
|
+
@string = str.strip
|
55
|
+
@core = nil
|
56
|
+
if @string =~ /#(.+)#/
|
57
|
+
@core = $1
|
58
|
+
@string.gsub!('#', '')
|
59
|
+
end
|
60
|
+
raise ArgumentError, "empty string can't be a valid answer!" if @string.empty?
|
61
|
+
raise ArgumentError, "empty core can't be a valid answer!" if @core and @core.empty?
|
62
|
+
|
63
|
+
@numeric = (core.to_i.to_s == core) || (core.to_f.to_s == core)
|
64
|
+
@info = nil
|
65
|
+
end
|
66
|
+
|
67
|
+
def core
|
68
|
+
@core || @string
|
69
|
+
end
|
70
|
+
|
71
|
+
def numeric?
|
72
|
+
@numeric
|
73
|
+
end
|
74
|
+
|
75
|
+
def valid?(str)
|
76
|
+
str.downcase == core.downcase || str.downcase == @string.downcase
|
77
|
+
end
|
78
|
+
|
79
|
+
def to_str
|
80
|
+
[@string, @info].join
|
81
|
+
end
|
82
|
+
alias :to_s :to_str
|
83
|
+
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
#######################################################################
|
89
|
+
# CLASS Quiz
|
90
|
+
# One Quiz instance per channel, contains channel specific data
|
91
|
+
#######################################################################
|
92
|
+
class Quiz
|
93
|
+
attr_accessor :registry, :registry_conf, :questions,
|
94
|
+
:question, :answers, :canonical_answer, :answer_array,
|
95
|
+
:first_try, :hint, :hintrange, :rank_table, :hinted, :has_errors,
|
96
|
+
:all_seps
|
97
|
+
|
98
|
+
def initialize( channel, registry )
|
99
|
+
if !channel
|
100
|
+
@registry = registry.sub_registry( 'private' )
|
101
|
+
else
|
102
|
+
@registry = registry.sub_registry( channel.downcase )
|
103
|
+
end
|
104
|
+
@has_errors = false
|
105
|
+
@registry.each_key { |k|
|
106
|
+
unless @registry.has_key?(k)
|
107
|
+
@has_errors = true
|
108
|
+
error "Data for #{k} is NOT ACCESSIBLE! Database corrupt?"
|
109
|
+
end
|
110
|
+
}
|
111
|
+
if @has_errors
|
112
|
+
debug @registry.to_a.map { |a| a.join(", ")}.join("\n")
|
113
|
+
end
|
114
|
+
|
115
|
+
@registry_conf = @registry.sub_registry( "config" )
|
116
|
+
|
117
|
+
# Per-channel list of sources. If empty, the default one (quiz/quiz.rbot)
|
118
|
+
# will be used. TODO
|
119
|
+
@registry_conf["sources"] = [] unless @registry_conf.has_key?( "sources" )
|
120
|
+
|
121
|
+
# Per-channel copy of the global questions table. Acts like a shuffled queue
|
122
|
+
# from which questions are taken, until empty. Then we refill it with questions
|
123
|
+
# from the global table.
|
124
|
+
@registry_conf["questions"] = [] unless @registry_conf.has_key?( "questions" )
|
125
|
+
|
126
|
+
# Autoask defaults to true
|
127
|
+
@registry_conf["autoask"] = true unless @registry_conf.has_key?( "autoask" )
|
128
|
+
|
129
|
+
# Autoask delay defaults to 0 (instantly)
|
130
|
+
@registry_conf["autoask_delay"] = 0 unless @registry_conf.has_key?( "autoask_delay" )
|
131
|
+
|
132
|
+
@questions = @registry_conf["questions"]
|
133
|
+
@question = nil
|
134
|
+
@answers = []
|
135
|
+
@canonical_answer = nil
|
136
|
+
# FIXME 2.0 UTF-8
|
137
|
+
@answer_array = []
|
138
|
+
@first_try = false
|
139
|
+
# FIXME 2.0 UTF-8
|
140
|
+
@hint = []
|
141
|
+
@hintrange = nil
|
142
|
+
@hinted = false
|
143
|
+
|
144
|
+
# True if the answers is entirely done by separators
|
145
|
+
@all_seps = false
|
146
|
+
|
147
|
+
# We keep this array of player stats for performance reasons. It's sorted by score
|
148
|
+
# and always synced with the registry player stats hash. This way we can do fast
|
149
|
+
# rank lookups, without extra sorting.
|
150
|
+
@rank_table = @registry.to_a.sort { |a,b| b[1].score<=>a[1].score }
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
#######################################################################
|
156
|
+
# CLASS QuizPlugin
|
157
|
+
#######################################################################
|
158
|
+
class QuizPlugin < Plugin
|
159
|
+
Config.register Config::BooleanValue.new('quiz.dotted_nicks',
|
160
|
+
:default => true,
|
161
|
+
:desc => "When true, nicks in the top X scores will be camouflaged to prevent IRC hilighting")
|
162
|
+
|
163
|
+
Config.register Config::ArrayValue.new('quiz.sources',
|
164
|
+
:default => ['quiz.rbot'],
|
165
|
+
:desc => "List of files and URLs that will be used to retrieve quiz questions")
|
166
|
+
|
167
|
+
def initialize()
|
168
|
+
super
|
169
|
+
|
170
|
+
@questions = Array.new
|
171
|
+
@quizzes = Hash.new
|
172
|
+
@waiting = Hash.new
|
173
|
+
@ask_mutex = Mutex.new
|
174
|
+
end
|
175
|
+
|
176
|
+
# Function that returns whether a char is a "separator", used for hints
|
177
|
+
#
|
178
|
+
def is_sep( ch )
|
179
|
+
return ch !~ /^\w$/u
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
# Fetches questions from the data sources, which can be either local files
|
184
|
+
# (in quiz/) or web pages.
|
185
|
+
#
|
186
|
+
def fetch_data( m )
|
187
|
+
# Read the winning messages file
|
188
|
+
@win_messages = Array.new
|
189
|
+
if File.exists? "#{@bot.botclass}/quiz/win_messages"
|
190
|
+
IO.foreach("#{@bot.botclass}/quiz/win_messages") { |line| @win_messages << line.chomp }
|
191
|
+
else
|
192
|
+
warning( "win_messages file not found!" )
|
193
|
+
# Fill the array with a least one message or code accessing it would fail
|
194
|
+
@win_messages << "<who> guessed right! The answer was <answer>"
|
195
|
+
end
|
196
|
+
|
197
|
+
m.reply "Fetching questions ..."
|
198
|
+
|
199
|
+
# TODO Per-channel sources
|
200
|
+
|
201
|
+
data = ""
|
202
|
+
@bot.config['quiz.sources'].each { |p|
|
203
|
+
if p =~ /^https?:\/\//
|
204
|
+
# Wiki data
|
205
|
+
begin
|
206
|
+
serverdata = @bot.httputil.get(p) # "http://amarok.kde.org/amarokwiki/index.php/Rbot_Quiz"
|
207
|
+
serverdata = serverdata.split( "QUIZ DATA START\n" )[1]
|
208
|
+
serverdata = serverdata.split( "\nQUIZ DATA END" )[0]
|
209
|
+
serverdata = serverdata.gsub( / /, " " ).gsub( /&/, "&" ).gsub( /"/, "\"" )
|
210
|
+
data << "\n\n" << serverdata
|
211
|
+
rescue
|
212
|
+
m.reply "Failed to download questions from #{p}, ignoring sources"
|
213
|
+
end
|
214
|
+
else
|
215
|
+
path = "#{@bot.botclass}/quiz/#{p}"
|
216
|
+
debug "Fetching from #{path}"
|
217
|
+
|
218
|
+
# Local data
|
219
|
+
begin
|
220
|
+
datafile = File.new( path, File::RDONLY )
|
221
|
+
data << "\n\n" << datafile.read
|
222
|
+
rescue
|
223
|
+
m.reply "Failed to read from local database file #{p}, skipping."
|
224
|
+
end
|
225
|
+
end
|
226
|
+
}
|
227
|
+
|
228
|
+
@questions.clear
|
229
|
+
|
230
|
+
# Fuse together and remove comments, then split
|
231
|
+
entries = data.strip.gsub( /^#.*$/, "" ).split( /(?:^|\n+)Question: / )
|
232
|
+
|
233
|
+
entries.each do |e|
|
234
|
+
p = e.split( "\n" )
|
235
|
+
# We'll need at least two lines of data
|
236
|
+
unless p.size < 2
|
237
|
+
# Check if question isn't empty
|
238
|
+
if p[0].length > 0
|
239
|
+
while p[1].match( /^Answer: (.*)$/ ) == nil and p.size > 2
|
240
|
+
# Delete all lines between the question and the answer
|
241
|
+
p.delete_at(1)
|
242
|
+
end
|
243
|
+
p[1] = p[1].gsub( /Answer: /, "" ).strip
|
244
|
+
# If the answer was found
|
245
|
+
if p[1].length > 0
|
246
|
+
# Add the data to the array
|
247
|
+
b = QuizBundle.new( p[0], p[1] )
|
248
|
+
@questions << b
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
m.reply "done, #{@questions.length} questions loaded."
|
255
|
+
end
|
256
|
+
|
257
|
+
|
258
|
+
# Returns new Quiz instance for channel, or existing one
|
259
|
+
#
|
260
|
+
def create_quiz( channel )
|
261
|
+
unless @quizzes.has_key?( channel )
|
262
|
+
@quizzes[channel] = Quiz.new( channel, @registry )
|
263
|
+
end
|
264
|
+
|
265
|
+
if @quizzes[channel].has_errors
|
266
|
+
return nil
|
267
|
+
else
|
268
|
+
return @quizzes[channel]
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
|
273
|
+
def say_score( m, nick )
|
274
|
+
chan = m.channel
|
275
|
+
q = create_quiz( chan )
|
276
|
+
if q.nil?
|
277
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
278
|
+
return
|
279
|
+
end
|
280
|
+
|
281
|
+
if q.registry.has_key?( nick )
|
282
|
+
score = q.registry[nick].score
|
283
|
+
jokers = q.registry[nick].jokers
|
284
|
+
|
285
|
+
rank = 0
|
286
|
+
q.rank_table.each_index { |rank| break if nick.downcase == q.rank_table[rank][0].downcase }
|
287
|
+
rank += 1
|
288
|
+
|
289
|
+
m.reply "#{nick}'s score is: #{score} Rank: #{rank} Jokers: #{jokers}"
|
290
|
+
else
|
291
|
+
m.reply "#{nick} does not have a score yet. Lamer."
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
|
296
|
+
def help( plugin, topic="" )
|
297
|
+
if topic == "admin"
|
298
|
+
"Quiz game aministration commands (requires authentication): 'quiz autoask <on/off>' => enable/disable autoask mode. 'quiz autoask delay <secs>' => delay next quiz by <secs> seconds when in autoask mode. 'quiz transfer <source> <dest> [score] [jokers]' => transfer [score] points and [jokers] jokers from <source> to <dest> (default is entire score and all jokers). 'quiz setscore <player> <score>' => set <player>'s score to <score>. 'quiz setjokers <player> <jokers>' => set <player>'s number of jokers to <jokers>. 'quiz deleteplayer <player>' => delete one player from the rank table (only works when score and jokers are set to 0). 'quiz cleanup' => remove players with no points and no jokers."
|
299
|
+
else
|
300
|
+
urls = @bot.config['quiz.sources'].select { |p| p =~ /^https?:\/\// }
|
301
|
+
"A multiplayer trivia quiz. 'quiz' => ask a question. 'quiz hint' => get a hint. 'quiz solve' => solve this question. 'quiz skip' => skip to next question. 'quiz joker' => draw a joker to win this round. 'quiz score [player]' => show score for [player] (default is yourself). 'quiz top5' => show top 5 players. 'quiz top <number>' => show top <number> players (max 50). 'quiz stats' => show some statistics. 'quiz fetch' => refetch questions from databases. 'quiz refresh' => refresh the question pool for this channel." + (urls.empty? ? "" : "\nYou can add new questions at #{urls.join(', ')}")
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
|
306
|
+
# Updates the per-channel rank table, which is kept for performance reasons.
|
307
|
+
# This table contains all players sorted by rank.
|
308
|
+
#
|
309
|
+
def calculate_ranks( m, q, nick )
|
310
|
+
if q.registry.has_key?( nick )
|
311
|
+
stats = q.registry[nick]
|
312
|
+
|
313
|
+
# Find player in table
|
314
|
+
found_player = false
|
315
|
+
i = 0
|
316
|
+
q.rank_table.each_index do |i|
|
317
|
+
if nick.downcase == q.rank_table[i][0].downcase
|
318
|
+
found_player = true
|
319
|
+
break
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
# Remove player from old position
|
324
|
+
if found_player
|
325
|
+
old_rank = i
|
326
|
+
q.rank_table.delete_at( i )
|
327
|
+
else
|
328
|
+
old_rank = nil
|
329
|
+
end
|
330
|
+
|
331
|
+
# Insert player at new position
|
332
|
+
inserted = false
|
333
|
+
q.rank_table.each_index do |i|
|
334
|
+
if stats.score > q.rank_table[i][1].score
|
335
|
+
q.rank_table[i,0] = [[nick, stats]]
|
336
|
+
inserted = true
|
337
|
+
break
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
# If less than all other players' scores, append to table
|
342
|
+
unless inserted
|
343
|
+
i += 1 unless q.rank_table.empty?
|
344
|
+
q.rank_table << [nick, stats]
|
345
|
+
end
|
346
|
+
|
347
|
+
# Print congratulations/condolences if the player's rank has changed
|
348
|
+
unless old_rank.nil?
|
349
|
+
if i < old_rank
|
350
|
+
m.reply "#{nick} ascends to rank #{i + 1}. Congratulations :)"
|
351
|
+
elsif i > old_rank
|
352
|
+
m.reply "#{nick} slides down to rank #{i + 1}. So Sorry! NOT. :p"
|
353
|
+
end
|
354
|
+
end
|
355
|
+
else
|
356
|
+
q.rank_table << [[nick, PlayerStats.new( 1 )]]
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
|
361
|
+
# Reimplemented from Plugin
|
362
|
+
#
|
363
|
+
def message(m)
|
364
|
+
chan = m.channel
|
365
|
+
return unless @quizzes.has_key?( chan )
|
366
|
+
q = @quizzes[chan]
|
367
|
+
|
368
|
+
return if q.question == nil
|
369
|
+
|
370
|
+
message = m.message.downcase.strip
|
371
|
+
|
372
|
+
nick = m.sourcenick.to_s
|
373
|
+
|
374
|
+
# Support multiple alternate answers and cores
|
375
|
+
answer = q.answers.find { |ans| ans.valid?(message) }
|
376
|
+
if answer
|
377
|
+
# List canonical answer which the hint was based on, to avoid confusion
|
378
|
+
# FIXME display this more friendly
|
379
|
+
answer.info = " (hints were for alternate answer #{q.canonical_answer.core})" if answer != q.canonical_answer and q.hinted
|
380
|
+
|
381
|
+
points = 1
|
382
|
+
if q.first_try
|
383
|
+
points += 1
|
384
|
+
reply = "WHOPEEE! #{nick} got it on the first try! That's worth an extra point. Answer was: #{answer}"
|
385
|
+
elsif q.rank_table.length >= 1 and nick.downcase == q.rank_table[0][0].downcase
|
386
|
+
reply = "THE QUIZ CHAMPION defends his throne! Seems like #{nick} is invicible! Answer was: #{answer}"
|
387
|
+
elsif q.rank_table.length >= 2 and nick.downcase == q.rank_table[1][0].downcase
|
388
|
+
reply = "THE SECOND CHAMPION is on the way up! Hurry up #{nick}, you only need #{q.rank_table[0][1].score - q.rank_table[1][1].score - 1} points to beat the king! Answer was: #{answer}"
|
389
|
+
elsif q.rank_table.length >= 3 and nick.downcase == q.rank_table[2][0].downcase
|
390
|
+
reply = "THE THIRD CHAMPION strikes again! Give it all #{nick}, with #{q.rank_table[1][1].score - q.rank_table[2][1].score - 1} more points you'll reach the 2nd place! Answer was: #{answer}"
|
391
|
+
else
|
392
|
+
reply = @win_messages[rand( @win_messages.length )].dup
|
393
|
+
reply.gsub!( "<who>", nick )
|
394
|
+
reply.gsub!( "<answer>", answer )
|
395
|
+
end
|
396
|
+
|
397
|
+
m.reply reply
|
398
|
+
|
399
|
+
player = nil
|
400
|
+
if q.registry.has_key?(nick)
|
401
|
+
player = q.registry[nick]
|
402
|
+
else
|
403
|
+
player = PlayerStats.new( 0, 0, 0 )
|
404
|
+
end
|
405
|
+
|
406
|
+
player.score = player.score + points
|
407
|
+
|
408
|
+
# Reward player with a joker every X points
|
409
|
+
if player.score % 15 == 0 and player.jokers < Max_Jokers
|
410
|
+
player.jokers += 1
|
411
|
+
m.reply "#{nick} gains a new joker. Rejoice :)"
|
412
|
+
end
|
413
|
+
|
414
|
+
q.registry[nick] = player
|
415
|
+
calculate_ranks( m, q, nick)
|
416
|
+
|
417
|
+
q.question = nil
|
418
|
+
if q.registry_conf["autoask"]
|
419
|
+
delay = q.registry_conf["autoask_delay"]
|
420
|
+
if delay > 0
|
421
|
+
m.reply "#{Bold}#{Color}03Next question in #{Bold}#{delay}#{Bold} seconds"
|
422
|
+
timer = @bot.timer.add_once(delay) {
|
423
|
+
@ask_mutex.synchronize do
|
424
|
+
@waiting.delete(chan)
|
425
|
+
end
|
426
|
+
cmd_quiz( m, nil)
|
427
|
+
}
|
428
|
+
@waiting[chan] = timer
|
429
|
+
else
|
430
|
+
cmd_quiz( m, nil )
|
431
|
+
end
|
432
|
+
end
|
433
|
+
else
|
434
|
+
# First try is used, and it wasn't the answer.
|
435
|
+
q.first_try = false
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
|
440
|
+
# Stretches an IRC nick with dots, simply to make the client not trigger a hilight,
|
441
|
+
# which is annoying for those not watching. Example: markey -> m.a.r.k.e.y
|
442
|
+
#
|
443
|
+
def unhilight_nick( nick )
|
444
|
+
return nick unless @bot.config['quiz.dotted_nicks']
|
445
|
+
return nick.split(//).join(".")
|
446
|
+
end
|
447
|
+
|
448
|
+
|
449
|
+
#######################################################################
|
450
|
+
# Command handling
|
451
|
+
#######################################################################
|
452
|
+
def cmd_quiz( m, params )
|
453
|
+
fetch_data( m ) if @questions.empty?
|
454
|
+
chan = m.channel
|
455
|
+
|
456
|
+
@ask_mutex.synchronize do
|
457
|
+
if @waiting.has_key?(chan)
|
458
|
+
m.reply "Next quiz question will be automatically asked soon, have patience"
|
459
|
+
return
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
q = create_quiz( chan )
|
464
|
+
if q.nil?
|
465
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
466
|
+
return
|
467
|
+
end
|
468
|
+
|
469
|
+
if q.question
|
470
|
+
m.reply "#{Bold}#{Color}03Current question: #{Color}#{Bold}#{q.question}"
|
471
|
+
m.reply "Hint: #{q.hint}" if q.hinted
|
472
|
+
return
|
473
|
+
end
|
474
|
+
|
475
|
+
# Fill per-channel questions buffer
|
476
|
+
if q.questions.empty?
|
477
|
+
q.questions = @questions.sort_by { rand }
|
478
|
+
end
|
479
|
+
|
480
|
+
# pick a question and delete it (delete_at returns the deleted item)
|
481
|
+
picked = q.questions.delete_at( rand(q.questions.length) )
|
482
|
+
|
483
|
+
q.question = picked.question
|
484
|
+
q.answers = picked.answer.split(/\s+\|\|\s+/).map { |ans| QuizAnswer.new(ans) }
|
485
|
+
|
486
|
+
# Check if any core answer is numerical and tell the players so, if that's the case
|
487
|
+
# The rather obscure statement is needed because to_i and to_f returns 99(.0) for "99 red balloons", and 0 for "balloon"
|
488
|
+
#
|
489
|
+
# The "canonical answer" is also determined here, defined to be the first found numerical answer, or
|
490
|
+
# the first core.
|
491
|
+
numeric = q.answers.find { |ans| ans.numeric? }
|
492
|
+
if numeric
|
493
|
+
q.question += "#{Color}07 (Numerical answer)#{Color}"
|
494
|
+
q.canonical_answer = numeric
|
495
|
+
else
|
496
|
+
q.canonical_answer = q.answers.first
|
497
|
+
end
|
498
|
+
|
499
|
+
q.first_try = true
|
500
|
+
|
501
|
+
# FIXME 2.0 UTF-8
|
502
|
+
q.hint = []
|
503
|
+
q.answer_array.clear
|
504
|
+
q.canonical_answer.core.scan(/./u) { |ch|
|
505
|
+
if is_sep(ch)
|
506
|
+
q.hint << ch
|
507
|
+
else
|
508
|
+
q.hint << "^"
|
509
|
+
end
|
510
|
+
q.answer_array << ch
|
511
|
+
}
|
512
|
+
q.all_seps = false
|
513
|
+
# It's possible that an answer is entirely done by separators,
|
514
|
+
# in which case we'll hide everything
|
515
|
+
if q.answer_array == q.hint
|
516
|
+
q.hint.map! { |ch|
|
517
|
+
"^"
|
518
|
+
}
|
519
|
+
q.all_seps = true
|
520
|
+
end
|
521
|
+
q.hinted = false
|
522
|
+
|
523
|
+
# Generate array of unique random range
|
524
|
+
q.hintrange = (0..q.hint.length-1).sort_by{ rand }
|
525
|
+
|
526
|
+
m.reply "#{Bold}#{Color}03Question: #{Color}#{Bold}" + q.question
|
527
|
+
end
|
528
|
+
|
529
|
+
|
530
|
+
def cmd_solve( m, params )
|
531
|
+
chan = m.channel
|
532
|
+
|
533
|
+
return unless @quizzes.has_key?( chan )
|
534
|
+
q = @quizzes[chan]
|
535
|
+
|
536
|
+
m.reply "The correct answer was: #{q.canonical_answer}"
|
537
|
+
|
538
|
+
q.question = nil
|
539
|
+
|
540
|
+
cmd_quiz( m, nil ) if q.registry_conf["autoask"]
|
541
|
+
end
|
542
|
+
|
543
|
+
|
544
|
+
def cmd_hint( m, params )
|
545
|
+
chan = m.channel
|
546
|
+
nick = m.sourcenick.to_s
|
547
|
+
|
548
|
+
return unless @quizzes.has_key?(chan)
|
549
|
+
q = @quizzes[chan]
|
550
|
+
|
551
|
+
if q.question == nil
|
552
|
+
m.reply "#{nick}: Get a question first!"
|
553
|
+
else
|
554
|
+
num_chars = case q.hintrange.length # Number of characters to reveal
|
555
|
+
when 25..1000 then 7
|
556
|
+
when 20..1000 then 6
|
557
|
+
when 16..1000 then 5
|
558
|
+
when 12..1000 then 4
|
559
|
+
when 8..1000 then 3
|
560
|
+
when 5..1000 then 2
|
561
|
+
when 1..1000 then 1
|
562
|
+
end
|
563
|
+
|
564
|
+
# FIXME 2.0 UTF-8
|
565
|
+
num_chars.times do
|
566
|
+
begin
|
567
|
+
index = q.hintrange.pop
|
568
|
+
# New hint char until the char isn't a "separator" (space etc.)
|
569
|
+
end while is_sep(q.answer_array[index]) and not q.all_seps
|
570
|
+
q.hint[index] = q.answer_array[index]
|
571
|
+
end
|
572
|
+
m.reply "Hint: #{q.hint}"
|
573
|
+
q.hinted = true
|
574
|
+
|
575
|
+
# FIXME 2.0 UTF-8
|
576
|
+
if q.hint == q.answer_array
|
577
|
+
m.reply "#{Bold}#{Color}04BUST!#{Color}#{Bold} This round is over. #{Color}04Minus one point for #{nick}#{Color}."
|
578
|
+
|
579
|
+
stats = nil
|
580
|
+
if q.registry.has_key?( nick )
|
581
|
+
stats = q.registry[nick]
|
582
|
+
else
|
583
|
+
stats = PlayerStats.new( 0, 0, 0 )
|
584
|
+
end
|
585
|
+
|
586
|
+
stats["score"] = stats.score - 1
|
587
|
+
q.registry[nick] = stats
|
588
|
+
|
589
|
+
calculate_ranks( m, q, nick)
|
590
|
+
|
591
|
+
q.question = nil
|
592
|
+
cmd_quiz( m, nil ) if q.registry_conf["autoask"]
|
593
|
+
end
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
|
598
|
+
def cmd_skip( m, params )
|
599
|
+
chan = m.channel
|
600
|
+
return unless @quizzes.has_key?(chan)
|
601
|
+
q = @quizzes[chan]
|
602
|
+
|
603
|
+
q.question = nil
|
604
|
+
cmd_quiz( m, params )
|
605
|
+
end
|
606
|
+
|
607
|
+
|
608
|
+
def cmd_joker( m, params )
|
609
|
+
chan = m.channel
|
610
|
+
nick = m.sourcenick.to_s
|
611
|
+
q = create_quiz(chan)
|
612
|
+
if q.nil?
|
613
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
614
|
+
return
|
615
|
+
end
|
616
|
+
|
617
|
+
if q.question == nil
|
618
|
+
m.reply "#{nick}: There is no open question."
|
619
|
+
return
|
620
|
+
end
|
621
|
+
|
622
|
+
if q.registry[nick].jokers > 0
|
623
|
+
player = q.registry[nick]
|
624
|
+
player.jokers -= 1
|
625
|
+
player.score += 1
|
626
|
+
q.registry[nick] = player
|
627
|
+
|
628
|
+
calculate_ranks( m, q, nick )
|
629
|
+
|
630
|
+
if player.jokers != 1
|
631
|
+
jokers = "jokers"
|
632
|
+
else
|
633
|
+
jokers = "joker"
|
634
|
+
end
|
635
|
+
m.reply "#{Bold}#{Color}12JOKER!#{Color}#{Bold} #{nick} draws a joker and wins this round. You have #{player.jokers} #{jokers} left."
|
636
|
+
m.reply "The answer was: #{q.canonical_answer}."
|
637
|
+
|
638
|
+
q.question = nil
|
639
|
+
cmd_quiz( m, nil ) if q.registry_conf["autoask"]
|
640
|
+
else
|
641
|
+
m.reply "#{nick}: You don't have any jokers left ;("
|
642
|
+
end
|
643
|
+
end
|
644
|
+
|
645
|
+
|
646
|
+
def cmd_fetch( m, params )
|
647
|
+
fetch_data( m )
|
648
|
+
end
|
649
|
+
|
650
|
+
|
651
|
+
def cmd_refresh( m, params )
|
652
|
+
q = create_quiz(m.channel)
|
653
|
+
q.questions.clear
|
654
|
+
fetch_data(m)
|
655
|
+
cmd_quiz( m, params )
|
656
|
+
end
|
657
|
+
|
658
|
+
|
659
|
+
def cmd_top5( m, params )
|
660
|
+
chan = m.channel
|
661
|
+
q = create_quiz( chan )
|
662
|
+
if q.nil?
|
663
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
664
|
+
return
|
665
|
+
end
|
666
|
+
|
667
|
+
if q.rank_table.empty?
|
668
|
+
m.reply "There are no scores known yet!"
|
669
|
+
return
|
670
|
+
end
|
671
|
+
|
672
|
+
m.reply "* Top 5 Players for #{chan}:"
|
673
|
+
|
674
|
+
[5, q.rank_table.length].min.times do |i|
|
675
|
+
player = q.rank_table[i]
|
676
|
+
nick = player[0]
|
677
|
+
score = player[1].score
|
678
|
+
m.reply " #{i + 1}. #{unhilight_nick( nick )} (#{score})"
|
679
|
+
end
|
680
|
+
end
|
681
|
+
|
682
|
+
|
683
|
+
def cmd_top_number( m, params )
|
684
|
+
num = params[:number].to_i
|
685
|
+
return if num < 1 or num > 50
|
686
|
+
chan = m.channel
|
687
|
+
q = create_quiz( chan )
|
688
|
+
if q.nil?
|
689
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
690
|
+
return
|
691
|
+
end
|
692
|
+
|
693
|
+
if q.rank_table.empty?
|
694
|
+
m.reply "There are no scores known yet!"
|
695
|
+
return
|
696
|
+
end
|
697
|
+
|
698
|
+
ar = []
|
699
|
+
m.reply "* Top #{num} Players for #{chan}:"
|
700
|
+
n = [ num, q.rank_table.length ].min
|
701
|
+
n.times do |i|
|
702
|
+
player = q.rank_table[i]
|
703
|
+
nick = player[0]
|
704
|
+
score = player[1].score
|
705
|
+
ar << "#{i + 1}. #{unhilight_nick( nick )} (#{score})"
|
706
|
+
end
|
707
|
+
m.reply ar.join(" | "), :split_at => /\s+\|\s+/
|
708
|
+
end
|
709
|
+
|
710
|
+
|
711
|
+
def cmd_stats( m, params )
|
712
|
+
fetch_data( m ) if @questions.empty?
|
713
|
+
|
714
|
+
m.reply "* Total Number of Questions:"
|
715
|
+
m.reply " #{@questions.length}"
|
716
|
+
end
|
717
|
+
|
718
|
+
|
719
|
+
def cmd_score( m, params )
|
720
|
+
nick = m.sourcenick.to_s
|
721
|
+
say_score( m, nick )
|
722
|
+
end
|
723
|
+
|
724
|
+
|
725
|
+
def cmd_score_player( m, params )
|
726
|
+
say_score( m, params[:player] )
|
727
|
+
end
|
728
|
+
|
729
|
+
|
730
|
+
def cmd_autoask( m, params )
|
731
|
+
chan = m.channel
|
732
|
+
q = create_quiz( chan )
|
733
|
+
if q.nil?
|
734
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
735
|
+
return
|
736
|
+
end
|
737
|
+
|
738
|
+
case params[:enable].downcase
|
739
|
+
when "on", "true"
|
740
|
+
q.registry_conf["autoask"] = true
|
741
|
+
m.reply "Enabled autoask mode."
|
742
|
+
cmd_quiz( m, nil ) if q.question == nil
|
743
|
+
when "off", "false"
|
744
|
+
q.registry_conf["autoask"] = false
|
745
|
+
m.reply "Disabled autoask mode."
|
746
|
+
else
|
747
|
+
m.reply "Invalid autoask parameter. Use 'on' or 'off'."
|
748
|
+
end
|
749
|
+
end
|
750
|
+
|
751
|
+
def cmd_autoask_delay( m, params )
|
752
|
+
chan = m.channel
|
753
|
+
q = create_quiz( chan )
|
754
|
+
if q.nil?
|
755
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
756
|
+
return
|
757
|
+
end
|
758
|
+
|
759
|
+
delay = params[:time].to_i
|
760
|
+
q.registry_conf["autoask_delay"] = delay
|
761
|
+
m.reply "Autoask delay now #{q.registry_conf['autoask_delay']} seconds"
|
762
|
+
end
|
763
|
+
|
764
|
+
|
765
|
+
def cmd_transfer( m, params )
|
766
|
+
chan = m.channel
|
767
|
+
q = create_quiz( chan )
|
768
|
+
if q.nil?
|
769
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
770
|
+
return
|
771
|
+
end
|
772
|
+
|
773
|
+
debug q.rank_table.inspect
|
774
|
+
|
775
|
+
source = params[:source]
|
776
|
+
dest = params[:dest]
|
777
|
+
transscore = params[:score].to_i
|
778
|
+
transjokers = params[:jokers].to_i
|
779
|
+
debug "Transferring #{transscore} points and #{transjokers} jokers from #{source} to #{dest}"
|
780
|
+
|
781
|
+
if q.registry.has_key?(source)
|
782
|
+
sourceplayer = q.registry[source]
|
783
|
+
score = sourceplayer.score
|
784
|
+
if transscore == -1
|
785
|
+
transscore = score
|
786
|
+
end
|
787
|
+
if score < transscore
|
788
|
+
m.reply "#{source} only has #{score} points!"
|
789
|
+
return
|
790
|
+
end
|
791
|
+
jokers = sourceplayer.jokers
|
792
|
+
if transjokers == -1
|
793
|
+
transjokers = jokers
|
794
|
+
end
|
795
|
+
if jokers < transjokers
|
796
|
+
m.reply "#{source} only has #{jokers} jokers!!"
|
797
|
+
return
|
798
|
+
end
|
799
|
+
if q.registry.has_key?(dest)
|
800
|
+
destplayer = q.registry[dest]
|
801
|
+
else
|
802
|
+
destplayer = PlayerStats.new(0,0,0)
|
803
|
+
end
|
804
|
+
|
805
|
+
if sourceplayer.object_id == destplayer.object_id
|
806
|
+
m.reply "Source and destination are the same, I'm not going to touch them"
|
807
|
+
return
|
808
|
+
end
|
809
|
+
|
810
|
+
sourceplayer.score -= transscore
|
811
|
+
destplayer.score += transscore
|
812
|
+
sourceplayer.jokers -= transjokers
|
813
|
+
destplayer.jokers += transjokers
|
814
|
+
|
815
|
+
q.registry[source] = sourceplayer
|
816
|
+
calculate_ranks(m, q, source)
|
817
|
+
|
818
|
+
q.registry[dest] = destplayer
|
819
|
+
calculate_ranks(m, q, dest)
|
820
|
+
|
821
|
+
m.reply "Transferred #{transscore} points and #{transjokers} jokers from #{source} to #{dest}"
|
822
|
+
else
|
823
|
+
m.reply "#{source} doesn't have any points!"
|
824
|
+
end
|
825
|
+
end
|
826
|
+
|
827
|
+
|
828
|
+
def cmd_del_player( m, params )
|
829
|
+
chan = m.channel
|
830
|
+
q = create_quiz( chan )
|
831
|
+
if q.nil?
|
832
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
833
|
+
return
|
834
|
+
end
|
835
|
+
|
836
|
+
debug q.rank_table.inspect
|
837
|
+
|
838
|
+
nick = params[:nick]
|
839
|
+
if q.registry.has_key?(nick)
|
840
|
+
player = q.registry[nick]
|
841
|
+
score = player.score
|
842
|
+
if score != 0
|
843
|
+
m.reply "Can't delete player #{nick} with score #{score}."
|
844
|
+
return
|
845
|
+
end
|
846
|
+
jokers = player.jokers
|
847
|
+
if jokers != 0
|
848
|
+
m.reply "Can't delete player #{nick} with #{jokers} jokers."
|
849
|
+
return
|
850
|
+
end
|
851
|
+
q.registry.delete(nick)
|
852
|
+
|
853
|
+
player_rank = nil
|
854
|
+
q.rank_table.each_index { |rank|
|
855
|
+
if nick.downcase == q.rank_table[rank][0].downcase
|
856
|
+
player_rank = rank
|
857
|
+
break
|
858
|
+
end
|
859
|
+
}
|
860
|
+
q.rank_table.delete_at(player_rank)
|
861
|
+
|
862
|
+
m.reply "Player #{nick} deleted."
|
863
|
+
else
|
864
|
+
m.reply "Player #{nick} isn't even in the database."
|
865
|
+
end
|
866
|
+
end
|
867
|
+
|
868
|
+
|
869
|
+
def cmd_set_score(m, params)
|
870
|
+
chan = m.channel
|
871
|
+
q = create_quiz( chan )
|
872
|
+
if q.nil?
|
873
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
874
|
+
return
|
875
|
+
end
|
876
|
+
debug q.rank_table.inspect
|
877
|
+
|
878
|
+
nick = params[:nick]
|
879
|
+
val = params[:score].to_i
|
880
|
+
if q.registry.has_key?(nick)
|
881
|
+
player = q.registry[nick]
|
882
|
+
player.score = val
|
883
|
+
else
|
884
|
+
player = PlayerStats.new( val, 0, 0)
|
885
|
+
end
|
886
|
+
q.registry[nick] = player
|
887
|
+
calculate_ranks(m, q, nick)
|
888
|
+
m.reply "Score for player #{nick} set to #{val}."
|
889
|
+
end
|
890
|
+
|
891
|
+
|
892
|
+
def cmd_set_jokers(m, params)
|
893
|
+
chan = m.channel
|
894
|
+
q = create_quiz( chan )
|
895
|
+
if q.nil?
|
896
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
897
|
+
return
|
898
|
+
end
|
899
|
+
debug q.rank_table.inspect
|
900
|
+
|
901
|
+
nick = params[:nick]
|
902
|
+
val = [params[:jokers].to_i, Max_Jokers].min
|
903
|
+
if q.registry.has_key?(nick)
|
904
|
+
player = q.registry[nick]
|
905
|
+
player.jokers = val
|
906
|
+
else
|
907
|
+
player = PlayerStats.new( 0, val, 0)
|
908
|
+
end
|
909
|
+
q.registry[nick] = player
|
910
|
+
m.reply "Jokers for player #{nick} set to #{val}."
|
911
|
+
end
|
912
|
+
|
913
|
+
|
914
|
+
def cmd_cleanup(m, params)
|
915
|
+
chan = m.channel
|
916
|
+
q = create_quiz( chan )
|
917
|
+
if q.nil?
|
918
|
+
m.reply "Sorry, the quiz database for #{chan} seems to be corrupt"
|
919
|
+
return
|
920
|
+
end
|
921
|
+
|
922
|
+
null_players = []
|
923
|
+
q.registry.each { |nick, player|
|
924
|
+
null_players << nick if player.jokers == 0 and player.score == 0
|
925
|
+
}
|
926
|
+
debug "Cleaning up by removing #{null_players * ', '}"
|
927
|
+
null_players.each { |nick|
|
928
|
+
cmd_del_player(m, :nick => nick)
|
929
|
+
}
|
930
|
+
|
931
|
+
end
|
932
|
+
|
933
|
+
end
|
934
|
+
|
935
|
+
|
936
|
+
|
937
|
+
plugin = QuizPlugin.new
|
938
|
+
plugin.default_auth( 'edit', false )
|
939
|
+
|
940
|
+
# Normal commands
|
941
|
+
plugin.map 'quiz', :action => 'cmd_quiz'
|
942
|
+
plugin.map 'quiz solve', :action => 'cmd_solve'
|
943
|
+
plugin.map 'quiz hint', :action => 'cmd_hint'
|
944
|
+
plugin.map 'quiz skip', :action => 'cmd_skip'
|
945
|
+
plugin.map 'quiz joker', :action => 'cmd_joker'
|
946
|
+
plugin.map 'quiz score', :action => 'cmd_score'
|
947
|
+
plugin.map 'quiz score :player', :action => 'cmd_score_player'
|
948
|
+
plugin.map 'quiz fetch', :action => 'cmd_fetch'
|
949
|
+
plugin.map 'quiz refresh', :action => 'cmd_refresh'
|
950
|
+
plugin.map 'quiz top5', :action => 'cmd_top5'
|
951
|
+
plugin.map 'quiz top :number', :action => 'cmd_top_number'
|
952
|
+
plugin.map 'quiz stats', :action => 'cmd_stats'
|
953
|
+
|
954
|
+
# Admin commands
|
955
|
+
plugin.map 'quiz autoask :enable', :action => 'cmd_autoask', :auth_path => 'edit'
|
956
|
+
plugin.map 'quiz autoask delay :time', :action => 'cmd_autoask_delay', :auth_path => 'edit', :requirements => {:time => /\d+/}
|
957
|
+
plugin.map 'quiz transfer :source :dest :score :jokers', :action => 'cmd_transfer', :auth_path => 'edit', :defaults => {:score => '-1', :jokers => '-1'}
|
958
|
+
plugin.map 'quiz deleteplayer :nick', :action => 'cmd_del_player', :auth_path => 'edit'
|
959
|
+
plugin.map 'quiz setscore :nick :score', :action => 'cmd_set_score', :auth_path => 'edit'
|
960
|
+
plugin.map 'quiz setjokers :nick :jokers', :action => 'cmd_set_jokers', :auth_path => 'edit'
|
961
|
+
plugin.map 'quiz cleanup', :action => 'cmd_cleanup', :auth_path => 'edit'
|