rbot 0.9.10 → 0.9.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (706) hide show
  1. data/AUTHORS +22 -4
  2. data/COPYING +5 -18
  3. data/ChangeLog +396 -0
  4. data/README +23 -25
  5. data/REQUIREMENTS +58 -12
  6. data/Rakefile +215 -0
  7. data/bin/rbot +47 -25
  8. data/bin/rbot-remote +76 -0
  9. data/data/rbot/languages/french.lang +5 -5
  10. data/data/rbot/languages/german.lang +4 -4
  11. data/data/rbot/languages/italian.lang +53 -0
  12. data/data/rbot/languages/japanese.lang +43 -0
  13. data/data/rbot/languages/russian.lang +60 -60
  14. data/data/rbot/languages/traditional_chinese.lang +75 -0
  15. data/data/rbot/plugins/alias.rb +192 -0
  16. data/data/rbot/plugins/autoop.rb +74 -37
  17. data/data/rbot/plugins/autorejoin.rb +15 -5
  18. data/data/rbot/plugins/bans.rb +454 -150
  19. data/data/rbot/plugins/bash.rb +173 -31
  20. data/data/rbot/plugins/botsnack.rb +37 -0
  21. data/data/rbot/plugins/cal.rb +11 -2
  22. data/data/rbot/plugins/chanserv.rb +132 -0
  23. data/data/rbot/plugins/chucknorris.rb +2 -2
  24. data/data/rbot/plugins/chucknorris.yml.gz +0 -0
  25. data/data/rbot/plugins/debugger.rb +136 -0
  26. data/data/rbot/plugins/deepthoughts.rb +89 -95
  27. data/data/rbot/plugins/delicious.rb +109 -0
  28. data/data/rbot/plugins/dice.rb +77 -25
  29. data/data/rbot/plugins/dict.rb +243 -0
  30. data/data/rbot/plugins/dictclient.rb +211 -0
  31. data/data/rbot/plugins/digg.rb +2 -2
  32. data/data/rbot/plugins/excuse.rb +4 -4
  33. data/data/rbot/plugins/factoids.rb +506 -0
  34. data/data/rbot/plugins/figlet.rb +127 -18
  35. data/data/rbot/plugins/fish.rb +93 -33
  36. data/data/rbot/plugins/forecast.rb +40 -27
  37. data/data/rbot/plugins/fortune.rb +86 -11
  38. data/data/rbot/plugins/freshmeat.rb +46 -12
  39. data/data/rbot/plugins/games/azgame.rb +565 -0
  40. data/data/rbot/plugins/games/quiz.rb +961 -0
  41. data/data/rbot/plugins/games/roshambo.rb +62 -0
  42. data/data/rbot/plugins/{roulette.rb → games/roulette.rb} +58 -8
  43. data/data/rbot/plugins/games/shiritori.rb +485 -0
  44. data/data/rbot/plugins/games/uno.rb +1205 -0
  45. data/data/rbot/plugins/games/wheelfortune.rb +615 -0
  46. data/data/rbot/plugins/grouphug.rb +76 -22
  47. data/data/rbot/plugins/hl2.rb +97 -0
  48. data/data/rbot/plugins/host.rb +10 -1
  49. data/data/rbot/plugins/httpd.rb.disabled +1 -0
  50. data/data/rbot/plugins/imdb.rb +511 -47
  51. data/data/rbot/plugins/insult.rb +32 -37
  52. data/data/rbot/plugins/iplookup.rb +224 -224
  53. data/data/rbot/plugins/karma.rb +45 -21
  54. data/data/rbot/plugins/keywords.rb +258 -160
  55. data/data/rbot/plugins/lart.rb +126 -95
  56. data/data/rbot/plugins/lastfm.rb +421 -12
  57. data/data/rbot/plugins/linkbot.rb +75 -0
  58. data/data/rbot/plugins/markov.rb +103 -46
  59. data/data/rbot/plugins/math.rb +6 -5
  60. data/data/rbot/plugins/modes.rb +114 -0
  61. data/data/rbot/plugins/nickrecover.rb +97 -0
  62. data/data/rbot/plugins/nickserv.rb +111 -48
  63. data/data/rbot/plugins/nslookup.rb +15 -19
  64. data/data/rbot/plugins/plugin.header +11 -0
  65. data/data/rbot/plugins/quakeauth.rb +74 -11
  66. data/data/rbot/plugins/quotes.rb +189 -233
  67. data/data/rbot/plugins/reaction.rb +415 -0
  68. data/data/rbot/plugins/remind.rb +11 -15
  69. data/data/rbot/plugins/remotectl.rb +29 -0
  70. data/data/rbot/plugins/ri.rb +74 -0
  71. data/data/rbot/plugins/rot13.rb +16 -1
  72. data/data/rbot/plugins/rss.rb +1219 -585
  73. data/data/rbot/plugins/salut.rb +226 -0
  74. data/data/rbot/plugins/script.rb +184 -0
  75. data/data/rbot/plugins/search.rb +233 -0
  76. data/data/rbot/plugins/seen.rb +44 -40
  77. data/data/rbot/plugins/shortenurls.rb +93 -0
  78. data/data/rbot/plugins/slashdot.rb +49 -11
  79. data/data/rbot/plugins/spell.rb +37 -27
  80. data/data/rbot/plugins/theyfightcrime.rb +36 -39
  81. data/data/rbot/plugins/threat.rb +25 -22
  82. data/data/rbot/plugins/time.rb +135 -0
  83. data/data/rbot/plugins/topic.rb +107 -50
  84. data/data/rbot/plugins/translator.rb +360 -0
  85. data/data/rbot/plugins/tube.rb +28 -40
  86. data/data/rbot/plugins/twitter.rb +187 -0
  87. data/data/rbot/plugins/urban.rb +62 -53
  88. data/data/rbot/plugins/url.rb +193 -409
  89. data/data/rbot/plugins/usermodes.rb +26 -0
  90. data/data/rbot/plugins/wall.rb +60 -0
  91. data/data/rbot/plugins/weather.rb +254 -598
  92. data/data/rbot/plugins/wow.rb +41 -37
  93. data/data/rbot/plugins/wserver.rb +17 -25
  94. data/data/rbot/plugins/youtube.rb +237 -0
  95. data/data/rbot/templates/lart/{larts → larts-english} +0 -0
  96. data/data/rbot/templates/lart/larts-italian +25 -0
  97. data/data/rbot/templates/lart/larts-japanese +10 -0
  98. data/data/rbot/templates/lart/{praises → praises-english} +0 -0
  99. data/data/rbot/templates/lart/praises-italian +4 -0
  100. data/data/rbot/templates/lart/praises-japanese +3 -0
  101. data/data/rbot/templates/quiz/win_messages +11 -0
  102. data/data/rbot/templates/salut/salut-english +40 -0
  103. data/data/rbot/templates/salut/salut-french +29 -0
  104. data/data/rbot/templates/salut/salut-italian +51 -0
  105. data/data/rbot/templates/salut/salut-japanese +31 -0
  106. data/lib/rbot/botuser.rb +940 -0
  107. data/lib/rbot/config-compat.rb +23 -0
  108. data/lib/rbot/config.rb +211 -276
  109. data/lib/rbot/core/auth.rb +1063 -0
  110. data/lib/rbot/core/basics.rb +214 -0
  111. data/lib/rbot/core/config.rb +330 -0
  112. data/lib/rbot/core/filters_ui.rb +64 -0
  113. data/lib/rbot/core/irclog.rb +292 -0
  114. data/lib/rbot/core/remote.rb +401 -0
  115. data/lib/rbot/core/unicode.rb +91 -0
  116. data/lib/rbot/core/userdata.rb +200 -0
  117. data/lib/rbot/core/utils/extends.rb +444 -0
  118. data/lib/rbot/core/utils/filters.rb +154 -0
  119. data/lib/rbot/core/utils/httputil.rb +689 -0
  120. data/lib/rbot/core/utils/utils.rb +717 -0
  121. data/lib/rbot/dbhash.rb +30 -9
  122. data/lib/rbot/irc.rb +1966 -0
  123. data/lib/rbot/ircbot.rb +816 -675
  124. data/lib/rbot/ircsocket.rb +246 -232
  125. data/lib/rbot/language.rb +86 -8
  126. data/lib/rbot/load-gettext.rb +154 -0
  127. data/lib/rbot/maskdb.rb +162 -0
  128. data/lib/rbot/message.rb +392 -65
  129. data/lib/rbot/messagemapper.rb +438 -94
  130. data/lib/rbot/pkgconfig.rb +6 -0
  131. data/lib/rbot/plugins.rb +713 -172
  132. data/lib/rbot/post-config.rb +1 -0
  133. data/lib/rbot/rbotconfig.rb +31 -12
  134. data/lib/rbot/registry.rb +79 -48
  135. data/lib/rbot/rfc2812.rb +927 -519
  136. data/lib/rbot/timer.rb +232 -167
  137. data/po/en_US/rbot-alias.po +82 -0
  138. data/po/en_US/rbot-autoop.po +0 -0
  139. data/po/en_US/rbot-autorejoin.po +0 -0
  140. data/po/en_US/rbot-azgame.po +200 -0
  141. data/po/en_US/rbot-bans.po +0 -0
  142. data/po/en_US/rbot-bash.po +0 -0
  143. data/po/en_US/rbot-botsnack.po +0 -0
  144. data/po/en_US/rbot-cal.po +3 -0
  145. data/po/en_US/rbot-chanserv.po +0 -0
  146. data/po/en_US/rbot-chucknorris.po +0 -0
  147. data/po/en_US/rbot-debugger.po +0 -0
  148. data/po/en_US/rbot-deepthoughts.po +0 -0
  149. data/po/en_US/rbot-delicious.po +0 -0
  150. data/po/en_US/rbot-dice.po +0 -0
  151. data/po/en_US/rbot-dict.po +0 -0
  152. data/po/en_US/rbot-dictclient.po +124 -0
  153. data/po/en_US/rbot-digg.po +0 -0
  154. data/po/en_US/rbot-eightball.po +0 -0
  155. data/po/en_US/rbot-excuse.po +0 -0
  156. data/po/en_US/rbot-factoids.po +107 -0
  157. data/po/en_US/rbot-figlet.po +36 -0
  158. data/po/en_US/rbot-fish.po +0 -0
  159. data/po/en_US/rbot-forecast.po +0 -0
  160. data/po/en_US/rbot-fortune.po +0 -0
  161. data/po/en_US/rbot-freshmeat.po +0 -0
  162. data/po/en_US/rbot-grouphug.po +18 -0
  163. data/po/en_US/rbot-hl2.po +0 -0
  164. data/po/en_US/rbot-host.po +3 -0
  165. data/po/en_US/rbot-imdb.po +0 -0
  166. data/po/en_US/rbot-insult.po +0 -0
  167. data/po/en_US/rbot-iplookup.po +0 -0
  168. data/po/en_US/rbot-karma.po +0 -0
  169. data/po/en_US/rbot-keywords.po +24 -0
  170. data/po/en_US/rbot-lart.po +0 -0
  171. data/po/en_US/rbot-lastfm.po +172 -0
  172. data/po/en_US/rbot-linkbot.po +0 -0
  173. data/po/en_US/rbot-markov.po +20 -0
  174. data/po/en_US/rbot-math.po +0 -0
  175. data/po/en_US/rbot-modes.po +0 -0
  176. data/po/en_US/rbot-nickrecover.po +40 -0
  177. data/po/en_US/rbot-nickserv.po +104 -0
  178. data/po/en_US/rbot-nslookup.po +0 -0
  179. data/po/en_US/rbot-quakeauth.po +0 -0
  180. data/po/en_US/rbot-quiz.po +0 -0
  181. data/po/en_US/rbot-quotes.po +108 -0
  182. data/po/en_US/rbot-reaction.po +0 -0
  183. data/po/en_US/rbot-remind.po +0 -0
  184. data/po/en_US/rbot-remotectl.po +0 -0
  185. data/po/en_US/rbot-ri.po +0 -0
  186. data/po/en_US/rbot-roshambo.po +0 -0
  187. data/po/en_US/rbot-rot13.po +0 -0
  188. data/po/en_US/rbot-roulette.po +0 -0
  189. data/po/en_US/rbot-rss.po +20 -0
  190. data/po/en_US/rbot-salut.po +0 -0
  191. data/po/en_US/rbot-script.po +0 -0
  192. data/po/en_US/rbot-search.po +0 -0
  193. data/po/en_US/rbot-seen.po +0 -0
  194. data/po/en_US/rbot-shiritori.po +113 -0
  195. data/po/en_US/rbot-shortenurls.po +0 -0
  196. data/po/en_US/rbot-slashdot.po +0 -0
  197. data/po/en_US/rbot-spell.po +54 -0
  198. data/po/en_US/rbot-theyfightcrime.po +0 -0
  199. data/po/en_US/rbot-threat.po +0 -0
  200. data/po/en_US/rbot-time.po +0 -0
  201. data/po/en_US/rbot-topic.po +0 -0
  202. data/po/en_US/rbot-translator.po +77 -0
  203. data/po/en_US/rbot-tube.po +0 -0
  204. data/po/en_US/rbot-twitter.po +24 -0
  205. data/po/en_US/rbot-uno.po +512 -0
  206. data/po/en_US/rbot-urban.po +0 -0
  207. data/po/en_US/rbot-url.po +0 -0
  208. data/po/en_US/rbot-usermodes.po +0 -0
  209. data/po/en_US/rbot-wall.po +33 -0
  210. data/po/en_US/rbot-weather.po +0 -0
  211. data/po/en_US/rbot-wheelfortune.po +205 -0
  212. data/po/en_US/rbot-wow.po +0 -0
  213. data/po/en_US/rbot-wserver.po +0 -0
  214. data/po/en_US/rbot-youtube.po +58 -0
  215. data/po/en_US/rbot.po +1097 -0
  216. data/po/fr/rbot-alias.po +97 -0
  217. data/po/fr/rbot-autoop.po +0 -0
  218. data/po/fr/rbot-autorejoin.po +0 -0
  219. data/po/fr/rbot-azgame.po +204 -0
  220. data/po/fr/rbot-bans.po +0 -0
  221. data/po/fr/rbot-bash.po +0 -0
  222. data/po/fr/rbot-botsnack.po +0 -0
  223. data/po/fr/rbot-cal.po +3 -0
  224. data/po/fr/rbot-chanserv.po +0 -0
  225. data/po/fr/rbot-chucknorris.po +0 -0
  226. data/po/fr/rbot-debugger.po +0 -0
  227. data/po/fr/rbot-deepthoughts.po +0 -0
  228. data/po/fr/rbot-delicious.po +0 -0
  229. data/po/fr/rbot-dice.po +0 -0
  230. data/po/fr/rbot-dict.po +0 -0
  231. data/po/fr/rbot-dictclient.po +134 -0
  232. data/po/fr/rbot-digg.po +0 -0
  233. data/po/fr/rbot-eightball.po +0 -0
  234. data/po/fr/rbot-excuse.po +0 -0
  235. data/po/fr/rbot-factoids.po +111 -0
  236. data/po/fr/rbot-figlet.po +37 -0
  237. data/po/fr/rbot-fish.po +0 -0
  238. data/po/fr/rbot-forecast.po +0 -0
  239. data/po/fr/rbot-fortune.po +0 -0
  240. data/po/fr/rbot-freshmeat.po +0 -0
  241. data/po/fr/rbot-grouphug.po +18 -0
  242. data/po/fr/rbot-hl2.po +0 -0
  243. data/po/fr/rbot-host.po +3 -0
  244. data/po/fr/rbot-imdb.po +0 -0
  245. data/po/fr/rbot-insult.po +0 -0
  246. data/po/fr/rbot-iplookup.po +0 -0
  247. data/po/fr/rbot-karma.po +0 -0
  248. data/po/fr/rbot-keywords.po +24 -0
  249. data/po/fr/rbot-lart.po +0 -0
  250. data/po/fr/rbot-lastfm.po +172 -0
  251. data/po/fr/rbot-linkbot.po +0 -0
  252. data/po/fr/rbot-markov.po +20 -0
  253. data/po/fr/rbot-math.po +0 -0
  254. data/po/fr/rbot-modes.po +0 -0
  255. data/po/fr/rbot-nickrecover.po +36 -0
  256. data/po/fr/rbot-nickserv.po +116 -0
  257. data/po/fr/rbot-nslookup.po +0 -0
  258. data/po/fr/rbot-quakeauth.po +0 -0
  259. data/po/fr/rbot-quiz.po +0 -0
  260. data/po/fr/rbot-quotes.po +138 -0
  261. data/po/fr/rbot-reaction.po +0 -0
  262. data/po/fr/rbot-remind.po +0 -0
  263. data/po/fr/rbot-remotectl.po +0 -0
  264. data/po/fr/rbot-ri.po +0 -0
  265. data/po/fr/rbot-roshambo.po +0 -0
  266. data/po/fr/rbot-rot13.po +0 -0
  267. data/po/fr/rbot-roulette.po +0 -0
  268. data/po/fr/rbot-rss.po +20 -0
  269. data/po/fr/rbot-salut.po +0 -0
  270. data/po/fr/rbot-script.po +0 -0
  271. data/po/fr/rbot-search.po +0 -0
  272. data/po/fr/rbot-seen.po +0 -0
  273. data/po/fr/rbot-shiritori.po +119 -0
  274. data/po/fr/rbot-shortenurls.po +0 -0
  275. data/po/fr/rbot-slashdot.po +0 -0
  276. data/po/fr/rbot-spell.po +56 -0
  277. data/po/fr/rbot-theyfightcrime.po +0 -0
  278. data/po/fr/rbot-threat.po +0 -0
  279. data/po/fr/rbot-time.po +0 -0
  280. data/po/fr/rbot-topic.po +0 -0
  281. data/po/fr/rbot-translator.po +90 -0
  282. data/po/fr/rbot-tube.po +0 -0
  283. data/po/fr/rbot-twitter.po +24 -0
  284. data/po/fr/rbot-uno.po +521 -0
  285. data/po/fr/rbot-urban.po +0 -0
  286. data/po/fr/rbot-url.po +0 -0
  287. data/po/fr/rbot-usermodes.po +0 -0
  288. data/po/fr/rbot-wall.po +33 -0
  289. data/po/fr/rbot-weather.po +0 -0
  290. data/po/fr/rbot-wheelfortune.po +255 -0
  291. data/po/fr/rbot-wow.po +0 -0
  292. data/po/fr/rbot-wserver.po +0 -0
  293. data/po/fr/rbot-youtube.po +64 -0
  294. data/po/fr/rbot.po +1133 -0
  295. data/po/it/rbot-alias.po +82 -0
  296. data/po/it/rbot-autoop.po +0 -0
  297. data/po/it/rbot-autorejoin.po +0 -0
  298. data/po/it/rbot-azgame.po +186 -0
  299. data/po/it/rbot-bans.po +0 -0
  300. data/po/it/rbot-bash.po +0 -0
  301. data/po/it/rbot-botsnack.po +0 -0
  302. data/po/it/rbot-cal.po +3 -0
  303. data/po/it/rbot-chanserv.po +0 -0
  304. data/po/it/rbot-chucknorris.po +0 -0
  305. data/po/it/rbot-debugger.po +0 -0
  306. data/po/it/rbot-deepthoughts.po +0 -0
  307. data/po/it/rbot-delicious.po +0 -0
  308. data/po/it/rbot-dice.po +0 -0
  309. data/po/it/rbot-dict.po +0 -0
  310. data/po/it/rbot-dictclient.po +111 -0
  311. data/po/it/rbot-digg.po +0 -0
  312. data/po/it/rbot-eightball.po +0 -0
  313. data/po/it/rbot-excuse.po +0 -0
  314. data/po/it/rbot-factoids.po +110 -0
  315. data/po/it/rbot-figlet.po +36 -0
  316. data/po/it/rbot-fish.po +0 -0
  317. data/po/it/rbot-forecast.po +0 -0
  318. data/po/it/rbot-fortune.po +0 -0
  319. data/po/it/rbot-freshmeat.po +0 -0
  320. data/po/it/rbot-grouphug.po +18 -0
  321. data/po/it/rbot-hl2.po +0 -0
  322. data/po/it/rbot-host.po +3 -0
  323. data/po/it/rbot-imdb.po +0 -0
  324. data/po/it/rbot-insult.po +0 -0
  325. data/po/it/rbot-iplookup.po +0 -0
  326. data/po/it/rbot-karma.po +0 -0
  327. data/po/it/rbot-keywords.po +24 -0
  328. data/po/it/rbot-lart.po +0 -0
  329. data/po/it/rbot-lastfm.po +172 -0
  330. data/po/it/rbot-linkbot.po +0 -0
  331. data/po/it/rbot-markov.po +20 -0
  332. data/po/it/rbot-math.po +0 -0
  333. data/po/it/rbot-modes.po +0 -0
  334. data/po/it/rbot-nickrecover.po +36 -0
  335. data/po/it/rbot-nickserv.po +104 -0
  336. data/po/it/rbot-nslookup.po +0 -0
  337. data/po/it/rbot-quakeauth.po +0 -0
  338. data/po/it/rbot-quiz.po +0 -0
  339. data/po/it/rbot-quotes.po +108 -0
  340. data/po/it/rbot-reaction.po +0 -0
  341. data/po/it/rbot-remind.po +0 -0
  342. data/po/it/rbot-remotectl.po +0 -0
  343. data/po/it/rbot-ri.po +0 -0
  344. data/po/it/rbot-roshambo.po +0 -0
  345. data/po/it/rbot-rot13.po +0 -0
  346. data/po/it/rbot-roulette.po +0 -0
  347. data/po/it/rbot-rss.po +20 -0
  348. data/po/it/rbot-salut.po +0 -0
  349. data/po/it/rbot-script.po +0 -0
  350. data/po/it/rbot-search.po +0 -0
  351. data/po/it/rbot-seen.po +0 -0
  352. data/po/it/rbot-shiritori.po +102 -0
  353. data/po/it/rbot-shortenurls.po +0 -0
  354. data/po/it/rbot-slashdot.po +0 -0
  355. data/po/it/rbot-spell.po +54 -0
  356. data/po/it/rbot-theyfightcrime.po +0 -0
  357. data/po/it/rbot-threat.po +0 -0
  358. data/po/it/rbot-time.po +0 -0
  359. data/po/it/rbot-topic.po +0 -0
  360. data/po/it/rbot-translator.po +77 -0
  361. data/po/it/rbot-tube.po +0 -0
  362. data/po/it/rbot-twitter.po +24 -0
  363. data/po/it/rbot-uno.po +564 -0
  364. data/po/it/rbot-urban.po +0 -0
  365. data/po/it/rbot-url.po +0 -0
  366. data/po/it/rbot-usermodes.po +0 -0
  367. data/po/it/rbot-wall.po +33 -0
  368. data/po/it/rbot-weather.po +0 -0
  369. data/po/it/rbot-wheelfortune.po +251 -0
  370. data/po/it/rbot-wow.po +0 -0
  371. data/po/it/rbot-wserver.po +0 -0
  372. data/po/it/rbot-youtube.po +64 -0
  373. data/po/it/rbot.po +1127 -0
  374. data/po/ja/rbot-alias.po +82 -0
  375. data/po/ja/rbot-autoop.po +0 -0
  376. data/po/ja/rbot-autorejoin.po +0 -0
  377. data/po/ja/rbot-azgame.po +194 -0
  378. data/po/ja/rbot-bans.po +0 -0
  379. data/po/ja/rbot-bash.po +0 -0
  380. data/po/ja/rbot-botsnack.po +0 -0
  381. data/po/ja/rbot-cal.po +3 -0
  382. data/po/ja/rbot-chanserv.po +0 -0
  383. data/po/ja/rbot-chucknorris.po +0 -0
  384. data/po/ja/rbot-debugger.po +0 -0
  385. data/po/ja/rbot-deepthoughts.po +0 -0
  386. data/po/ja/rbot-delicious.po +0 -0
  387. data/po/ja/rbot-dice.po +0 -0
  388. data/po/ja/rbot-dict.po +0 -0
  389. data/po/ja/rbot-dictclient.po +111 -0
  390. data/po/ja/rbot-digg.po +0 -0
  391. data/po/ja/rbot-eightball.po +0 -0
  392. data/po/ja/rbot-excuse.po +0 -0
  393. data/po/ja/rbot-factoids.po +107 -0
  394. data/po/ja/rbot-figlet.po +36 -0
  395. data/po/ja/rbot-fish.po +0 -0
  396. data/po/ja/rbot-forecast.po +0 -0
  397. data/po/ja/rbot-fortune.po +0 -0
  398. data/po/ja/rbot-freshmeat.po +0 -0
  399. data/po/ja/rbot-grouphug.po +18 -0
  400. data/po/ja/rbot-hl2.po +0 -0
  401. data/po/ja/rbot-host.po +3 -0
  402. data/po/ja/rbot-imdb.po +0 -0
  403. data/po/ja/rbot-insult.po +0 -0
  404. data/po/ja/rbot-iplookup.po +0 -0
  405. data/po/ja/rbot-karma.po +0 -0
  406. data/po/ja/rbot-keywords.po +24 -0
  407. data/po/ja/rbot-lart.po +0 -0
  408. data/po/ja/rbot-lastfm.po +172 -0
  409. data/po/ja/rbot-linkbot.po +0 -0
  410. data/po/ja/rbot-markov.po +20 -0
  411. data/po/ja/rbot-math.po +0 -0
  412. data/po/ja/rbot-modes.po +0 -0
  413. data/po/ja/rbot-nickrecover.po +36 -0
  414. data/po/ja/rbot-nickserv.po +104 -0
  415. data/po/ja/rbot-nslookup.po +0 -0
  416. data/po/ja/rbot-quakeauth.po +0 -0
  417. data/po/ja/rbot-quiz.po +0 -0
  418. data/po/ja/rbot-quotes.po +108 -0
  419. data/po/ja/rbot-reaction.po +0 -0
  420. data/po/ja/rbot-remind.po +0 -0
  421. data/po/ja/rbot-remotectl.po +0 -0
  422. data/po/ja/rbot-ri.po +0 -0
  423. data/po/ja/rbot-roshambo.po +0 -0
  424. data/po/ja/rbot-rot13.po +0 -0
  425. data/po/ja/rbot-roulette.po +0 -0
  426. data/po/ja/rbot-rss.po +20 -0
  427. data/po/ja/rbot-salut.po +0 -0
  428. data/po/ja/rbot-script.po +0 -0
  429. data/po/ja/rbot-search.po +0 -0
  430. data/po/ja/rbot-seen.po +0 -0
  431. data/po/ja/rbot-shiritori.po +115 -0
  432. data/po/ja/rbot-shortenurls.po +0 -0
  433. data/po/ja/rbot-slashdot.po +0 -0
  434. data/po/ja/rbot-spell.po +54 -0
  435. data/po/ja/rbot-theyfightcrime.po +0 -0
  436. data/po/ja/rbot-threat.po +0 -0
  437. data/po/ja/rbot-time.po +0 -0
  438. data/po/ja/rbot-topic.po +0 -0
  439. data/po/ja/rbot-translator.po +77 -0
  440. data/po/ja/rbot-tube.po +0 -0
  441. data/po/ja/rbot-twitter.po +24 -0
  442. data/po/ja/rbot-uno.po +512 -0
  443. data/po/ja/rbot-urban.po +0 -0
  444. data/po/ja/rbot-url.po +0 -0
  445. data/po/ja/rbot-usermodes.po +0 -0
  446. data/po/ja/rbot-wall.po +33 -0
  447. data/po/ja/rbot-weather.po +0 -0
  448. data/po/ja/rbot-wheelfortune.po +205 -0
  449. data/po/ja/rbot-wow.po +0 -0
  450. data/po/ja/rbot-wserver.po +0 -0
  451. data/po/ja/rbot-youtube.po +58 -0
  452. data/po/ja/rbot.po +999 -0
  453. data/po/rbot-alias.pot +83 -0
  454. data/po/rbot-autoop.pot +0 -0
  455. data/po/rbot-autorejoin.pot +0 -0
  456. data/po/rbot-azgame.pot +187 -0
  457. data/po/rbot-bans.pot +0 -0
  458. data/po/rbot-bash.pot +0 -0
  459. data/po/rbot-botsnack.pot +0 -0
  460. data/po/rbot-cal.pot +21 -0
  461. data/po/rbot-chanserv.pot +0 -0
  462. data/po/rbot-chucknorris.pot +0 -0
  463. data/po/rbot-debugger.pot +0 -0
  464. data/po/rbot-deepthoughts.pot +0 -0
  465. data/po/rbot-delicious.pot +0 -0
  466. data/po/rbot-dice.pot +0 -0
  467. data/po/rbot-dict.pot +0 -0
  468. data/po/rbot-dictclient.pot +112 -0
  469. data/po/rbot-digg.pot +0 -0
  470. data/po/rbot-eightball.pot +0 -0
  471. data/po/rbot-excuse.pot +0 -0
  472. data/po/rbot-factoids.pot +108 -0
  473. data/po/rbot-figlet.pot +37 -0
  474. data/po/rbot-fish.pot +0 -0
  475. data/po/rbot-forecast.pot +0 -0
  476. data/po/rbot-fortune.pot +0 -0
  477. data/po/rbot-freshmeat.pot +0 -0
  478. data/po/rbot-grouphug.pot +36 -0
  479. data/po/rbot-hl2.pot +0 -0
  480. data/po/rbot-host.pot +21 -0
  481. data/po/rbot-imdb.pot +0 -0
  482. data/po/rbot-insult.pot +0 -0
  483. data/po/rbot-iplookup.pot +0 -0
  484. data/po/rbot-karma.pot +0 -0
  485. data/po/rbot-keywords.pot +25 -0
  486. data/po/rbot-lart.pot +0 -0
  487. data/po/rbot-lastfm.pot +190 -0
  488. data/po/rbot-linkbot.pot +0 -0
  489. data/po/rbot-markov.pot +21 -0
  490. data/po/rbot-math.pot +0 -0
  491. data/po/rbot-modes.pot +0 -0
  492. data/po/rbot-nickrecover.pot +37 -0
  493. data/po/rbot-nickserv.pot +105 -0
  494. data/po/rbot-nslookup.pot +0 -0
  495. data/po/rbot-quakeauth.pot +0 -0
  496. data/po/rbot-quiz.pot +0 -0
  497. data/po/rbot-quotes.pot +109 -0
  498. data/po/rbot-reaction.pot +0 -0
  499. data/po/rbot-remind.pot +0 -0
  500. data/po/rbot-remotectl.pot +0 -0
  501. data/po/rbot-ri.pot +0 -0
  502. data/po/rbot-roshambo.pot +0 -0
  503. data/po/rbot-rot13.pot +0 -0
  504. data/po/rbot-roulette.pot +0 -0
  505. data/po/rbot-rss.pot +21 -0
  506. data/po/rbot-salut.pot +0 -0
  507. data/po/rbot-script.pot +0 -0
  508. data/po/rbot-search.pot +0 -0
  509. data/po/rbot-seen.pot +0 -0
  510. data/po/rbot-shiritori.pot +103 -0
  511. data/po/rbot-shortenurls.pot +0 -0
  512. data/po/rbot-slashdot.pot +0 -0
  513. data/po/rbot-spell.pot +55 -0
  514. data/po/rbot-theyfightcrime.pot +0 -0
  515. data/po/rbot-threat.pot +0 -0
  516. data/po/rbot-time.pot +0 -0
  517. data/po/rbot-topic.pot +0 -0
  518. data/po/rbot-translator.pot +78 -0
  519. data/po/rbot-tube.pot +0 -0
  520. data/po/rbot-twitter.pot +25 -0
  521. data/po/rbot-uno.pot +513 -0
  522. data/po/rbot-urban.pot +0 -0
  523. data/po/rbot-url.pot +0 -0
  524. data/po/rbot-usermodes.pot +0 -0
  525. data/po/rbot-wall.pot +33 -0
  526. data/po/rbot-weather.pot +0 -0
  527. data/po/rbot-wheelfortune.pot +206 -0
  528. data/po/rbot-wow.pot +0 -0
  529. data/po/rbot-wserver.pot +0 -0
  530. data/po/rbot-youtube.pot +59 -0
  531. data/po/rbot.pot +1004 -0
  532. data/po/zh_CN/rbot-alias.po +82 -0
  533. data/po/zh_CN/rbot-autoop.po +0 -0
  534. data/po/zh_CN/rbot-autorejoin.po +0 -0
  535. data/po/zh_CN/rbot-azgame.po +186 -0
  536. data/po/zh_CN/rbot-bans.po +0 -0
  537. data/po/zh_CN/rbot-bash.po +0 -0
  538. data/po/zh_CN/rbot-botsnack.po +0 -0
  539. data/po/zh_CN/rbot-cal.po +3 -0
  540. data/po/zh_CN/rbot-chanserv.po +0 -0
  541. data/po/zh_CN/rbot-chucknorris.po +0 -0
  542. data/po/zh_CN/rbot-debugger.po +0 -0
  543. data/po/zh_CN/rbot-deepthoughts.po +0 -0
  544. data/po/zh_CN/rbot-delicious.po +0 -0
  545. data/po/zh_CN/rbot-dice.po +0 -0
  546. data/po/zh_CN/rbot-dict.po +0 -0
  547. data/po/zh_CN/rbot-dictclient.po +111 -0
  548. data/po/zh_CN/rbot-digg.po +0 -0
  549. data/po/zh_CN/rbot-eightball.po +0 -0
  550. data/po/zh_CN/rbot-excuse.po +0 -0
  551. data/po/zh_CN/rbot-factoids.po +107 -0
  552. data/po/zh_CN/rbot-figlet.po +36 -0
  553. data/po/zh_CN/rbot-fish.po +0 -0
  554. data/po/zh_CN/rbot-forecast.po +0 -0
  555. data/po/zh_CN/rbot-fortune.po +0 -0
  556. data/po/zh_CN/rbot-freshmeat.po +0 -0
  557. data/po/zh_CN/rbot-grouphug.po +18 -0
  558. data/po/zh_CN/rbot-hl2.po +0 -0
  559. data/po/zh_CN/rbot-host.po +3 -0
  560. data/po/zh_CN/rbot-imdb.po +0 -0
  561. data/po/zh_CN/rbot-insult.po +0 -0
  562. data/po/zh_CN/rbot-iplookup.po +0 -0
  563. data/po/zh_CN/rbot-karma.po +0 -0
  564. data/po/zh_CN/rbot-keywords.po +24 -0
  565. data/po/zh_CN/rbot-lart.po +0 -0
  566. data/po/zh_CN/rbot-lastfm.po +172 -0
  567. data/po/zh_CN/rbot-linkbot.po +0 -0
  568. data/po/zh_CN/rbot-markov.po +20 -0
  569. data/po/zh_CN/rbot-math.po +0 -0
  570. data/po/zh_CN/rbot-modes.po +0 -0
  571. data/po/zh_CN/rbot-nickrecover.po +36 -0
  572. data/po/zh_CN/rbot-nickserv.po +104 -0
  573. data/po/zh_CN/rbot-nslookup.po +0 -0
  574. data/po/zh_CN/rbot-quakeauth.po +0 -0
  575. data/po/zh_CN/rbot-quiz.po +0 -0
  576. data/po/zh_CN/rbot-quotes.po +108 -0
  577. data/po/zh_CN/rbot-reaction.po +0 -0
  578. data/po/zh_CN/rbot-remind.po +0 -0
  579. data/po/zh_CN/rbot-remotectl.po +0 -0
  580. data/po/zh_CN/rbot-ri.po +0 -0
  581. data/po/zh_CN/rbot-roshambo.po +0 -0
  582. data/po/zh_CN/rbot-rot13.po +0 -0
  583. data/po/zh_CN/rbot-roulette.po +0 -0
  584. data/po/zh_CN/rbot-rss.po +20 -0
  585. data/po/zh_CN/rbot-salut.po +0 -0
  586. data/po/zh_CN/rbot-script.po +0 -0
  587. data/po/zh_CN/rbot-search.po +0 -0
  588. data/po/zh_CN/rbot-seen.po +0 -0
  589. data/po/zh_CN/rbot-shiritori.po +102 -0
  590. data/po/zh_CN/rbot-shortenurls.po +0 -0
  591. data/po/zh_CN/rbot-slashdot.po +0 -0
  592. data/po/zh_CN/rbot-spell.po +54 -0
  593. data/po/zh_CN/rbot-theyfightcrime.po +0 -0
  594. data/po/zh_CN/rbot-threat.po +0 -0
  595. data/po/zh_CN/rbot-time.po +0 -0
  596. data/po/zh_CN/rbot-topic.po +0 -0
  597. data/po/zh_CN/rbot-translator.po +77 -0
  598. data/po/zh_CN/rbot-tube.po +0 -0
  599. data/po/zh_CN/rbot-twitter.po +24 -0
  600. data/po/zh_CN/rbot-uno.po +512 -0
  601. data/po/zh_CN/rbot-urban.po +0 -0
  602. data/po/zh_CN/rbot-url.po +0 -0
  603. data/po/zh_CN/rbot-usermodes.po +0 -0
  604. data/po/zh_CN/rbot-wall.po +33 -0
  605. data/po/zh_CN/rbot-weather.po +0 -0
  606. data/po/zh_CN/rbot-wheelfortune.po +205 -0
  607. data/po/zh_CN/rbot-wow.po +0 -0
  608. data/po/zh_CN/rbot-wserver.po +0 -0
  609. data/po/zh_CN/rbot-youtube.po +58 -0
  610. data/po/zh_CN/rbot.po +1006 -0
  611. data/po/zh_TW/rbot-alias.po +82 -0
  612. data/po/zh_TW/rbot-autoop.po +0 -0
  613. data/po/zh_TW/rbot-autorejoin.po +0 -0
  614. data/po/zh_TW/rbot-azgame.po +186 -0
  615. data/po/zh_TW/rbot-bans.po +0 -0
  616. data/po/zh_TW/rbot-bash.po +0 -0
  617. data/po/zh_TW/rbot-botsnack.po +0 -0
  618. data/po/zh_TW/rbot-cal.po +3 -0
  619. data/po/zh_TW/rbot-chanserv.po +0 -0
  620. data/po/zh_TW/rbot-chucknorris.po +0 -0
  621. data/po/zh_TW/rbot-debugger.po +0 -0
  622. data/po/zh_TW/rbot-deepthoughts.po +0 -0
  623. data/po/zh_TW/rbot-delicious.po +0 -0
  624. data/po/zh_TW/rbot-dice.po +0 -0
  625. data/po/zh_TW/rbot-dict.po +0 -0
  626. data/po/zh_TW/rbot-dictclient.po +111 -0
  627. data/po/zh_TW/rbot-digg.po +0 -0
  628. data/po/zh_TW/rbot-eightball.po +0 -0
  629. data/po/zh_TW/rbot-excuse.po +0 -0
  630. data/po/zh_TW/rbot-factoids.po +107 -0
  631. data/po/zh_TW/rbot-figlet.po +36 -0
  632. data/po/zh_TW/rbot-fish.po +0 -0
  633. data/po/zh_TW/rbot-forecast.po +0 -0
  634. data/po/zh_TW/rbot-fortune.po +0 -0
  635. data/po/zh_TW/rbot-freshmeat.po +0 -0
  636. data/po/zh_TW/rbot-grouphug.po +18 -0
  637. data/po/zh_TW/rbot-hl2.po +0 -0
  638. data/po/zh_TW/rbot-host.po +3 -0
  639. data/po/zh_TW/rbot-imdb.po +0 -0
  640. data/po/zh_TW/rbot-insult.po +0 -0
  641. data/po/zh_TW/rbot-iplookup.po +0 -0
  642. data/po/zh_TW/rbot-karma.po +0 -0
  643. data/po/zh_TW/rbot-keywords.po +24 -0
  644. data/po/zh_TW/rbot-lart.po +0 -0
  645. data/po/zh_TW/rbot-lastfm.po +172 -0
  646. data/po/zh_TW/rbot-linkbot.po +0 -0
  647. data/po/zh_TW/rbot-markov.po +20 -0
  648. data/po/zh_TW/rbot-math.po +0 -0
  649. data/po/zh_TW/rbot-modes.po +0 -0
  650. data/po/zh_TW/rbot-nickrecover.po +36 -0
  651. data/po/zh_TW/rbot-nickserv.po +104 -0
  652. data/po/zh_TW/rbot-nslookup.po +0 -0
  653. data/po/zh_TW/rbot-quakeauth.po +0 -0
  654. data/po/zh_TW/rbot-quiz.po +0 -0
  655. data/po/zh_TW/rbot-quotes.po +108 -0
  656. data/po/zh_TW/rbot-reaction.po +0 -0
  657. data/po/zh_TW/rbot-remind.po +0 -0
  658. data/po/zh_TW/rbot-remotectl.po +0 -0
  659. data/po/zh_TW/rbot-ri.po +0 -0
  660. data/po/zh_TW/rbot-roshambo.po +0 -0
  661. data/po/zh_TW/rbot-rot13.po +0 -0
  662. data/po/zh_TW/rbot-roulette.po +0 -0
  663. data/po/zh_TW/rbot-rss.po +20 -0
  664. data/po/zh_TW/rbot-salut.po +0 -0
  665. data/po/zh_TW/rbot-script.po +0 -0
  666. data/po/zh_TW/rbot-search.po +0 -0
  667. data/po/zh_TW/rbot-seen.po +0 -0
  668. data/po/zh_TW/rbot-shiritori.po +102 -0
  669. data/po/zh_TW/rbot-shortenurls.po +0 -0
  670. data/po/zh_TW/rbot-slashdot.po +0 -0
  671. data/po/zh_TW/rbot-spell.po +54 -0
  672. data/po/zh_TW/rbot-theyfightcrime.po +0 -0
  673. data/po/zh_TW/rbot-threat.po +0 -0
  674. data/po/zh_TW/rbot-time.po +0 -0
  675. data/po/zh_TW/rbot-topic.po +0 -0
  676. data/po/zh_TW/rbot-translator.po +77 -0
  677. data/po/zh_TW/rbot-tube.po +0 -0
  678. data/po/zh_TW/rbot-twitter.po +24 -0
  679. data/po/zh_TW/rbot-uno.po +512 -0
  680. data/po/zh_TW/rbot-urban.po +0 -0
  681. data/po/zh_TW/rbot-url.po +0 -0
  682. data/po/zh_TW/rbot-usermodes.po +0 -0
  683. data/po/zh_TW/rbot-wall.po +33 -0
  684. data/po/zh_TW/rbot-weather.po +0 -0
  685. data/po/zh_TW/rbot-wheelfortune.po +205 -0
  686. data/po/zh_TW/rbot-wow.po +0 -0
  687. data/po/zh_TW/rbot-wserver.po +0 -0
  688. data/po/zh_TW/rbot-youtube.po +58 -0
  689. data/po/zh_TW/rbot.po +1034 -0
  690. data/setup.rb +800 -574
  691. metadata +723 -108
  692. data/data/rbot/contrib/plugins/figlet.rb +0 -20
  693. data/data/rbot/contrib/plugins/ri.rb +0 -83
  694. data/data/rbot/plugins/demauro.rb +0 -95
  695. data/data/rbot/plugins/google.rb +0 -53
  696. data/data/rbot/plugins/opme.rb +0 -19
  697. data/data/rbot/plugins/roshambo.rb +0 -54
  698. data/data/rbot/plugins/rubyurl.rb +0 -39
  699. data/data/rbot/plugins/tinyurl.rb +0 -39
  700. data/data/rbot/plugins/xmlrpc.rb.disabled +0 -52
  701. data/data/rbot/templates/levels.rbot +0 -32
  702. data/data/rbot/templates/users.rbot +0 -1
  703. data/lib/rbot/auth.rb +0 -314
  704. data/lib/rbot/channel.rb +0 -54
  705. data/lib/rbot/httputil.rb +0 -309
  706. data/lib/rbot/utils.rb +0 -83
@@ -25,7 +25,6 @@ class KarmaPlugin < Plugin
25
25
  end
26
26
  File.delete("#{@bot.botclass}/karma.rbot")
27
27
  end
28
-
29
28
  end
30
29
 
31
30
  def stats(m, params)
@@ -49,37 +48,62 @@ class KarmaPlugin < Plugin
49
48
  m.reply "#{thing} has neutral karma"
50
49
  end
51
50
  end
52
-
51
+
52
+ def setkarma(m, params)
53
+ thing = (params[:key] || m.sourcenick).to_s
54
+ @registry[thing] = params[:val].to_i
55
+ karma(m, params)
56
+ end
53
57
 
54
58
  def help(plugin, topic="")
55
59
  "karma module: Listens to everyone's chat. <thing>++/<thing>-- => increase/decrease karma for <thing>, karma for <thing>? => show karma for <thing>, karmastats => show stats. Karma is a community rating system - only in-channel messages can affect karma and you cannot adjust your own."
56
60
  end
57
- def listen(m)
58
- return unless m.kind_of?(PrivMessage) && m.public?
59
- # in channel message, the kind we are interested in
60
- if(m.message =~ /(\+\+|--)/)
61
- string = m.message.sub(/\W(--|\+\+)(\(.*?\)|[^(++)(\-\-)\s]+)/, "\2\1")
62
- seen = Hash.new
63
- while(string.sub!(/(\(.*?\)|[^(++)(\-\-)\s]+)(\+\+|--)/, ""))
64
- key = $1
65
- change = $2
66
- next if seen[key]
67
- seen[key] = true
68
61
 
69
- key.sub!(/^\((.*)\)$/, "\1")
70
- key.gsub!(/\s+/, " ")
71
- next unless(key.length > 0)
72
- next if(key == m.sourcenick)
73
- if(change == "++")
74
- @registry[key] += 1
75
- elsif(change == "--")
76
- @registry[key] -= 1
62
+ def message(m)
63
+ return unless m.public? && m.message.match(/\+\+|--/)
64
+ arg = nil
65
+ op = nil
66
+ ac = Hash.new
67
+ m.message.split.each_with_index do |tok, i|
68
+ tok.sub!(/[:,]$/, '') if i == 0
69
+ catch :me_if_you_can do
70
+ if m.channel.users[tok].nil?
71
+ if (tok =~ /^(?:--)(.*[^-].*)$/) || (tok =~ /^(.*[^-].*)(?:--)$/)
72
+ op, arg = '--', $1
73
+ next
74
+ elsif (tok =~ /^(?:\+\+)(.*[^+].*)$/)||(tok =~ /^(.*[^+].*)(?:\+\+)$/)
75
+ op, arg = '++', $1
76
+ next
77
+ end
78
+ end
79
+
80
+ if (tok =~ /^--+$/) || (tok =~ /^\+\++$/)
81
+ op = tok.slice(0, 2)
82
+ else
83
+ arg = tok
77
84
  end
85
+ end # catch
86
+
87
+ if op && arg
88
+ ac[arg] ||= 0
89
+ ac[arg] += (op == '--' ? -1 : 1)
90
+ op = arg = nil
78
91
  end
79
92
  end
93
+
94
+ ac.each do |k, v|
95
+ next if v == 0
96
+ @registry[k] += (v > 0 ? 1 : -1)
97
+ m.reply @bot.lang.get("thanks") if k == @bot.nick && v > 0
98
+ end
80
99
  end
81
100
  end
101
+
82
102
  plugin = KarmaPlugin.new
103
+
104
+ plugin.default_auth( 'edit', false )
105
+
83
106
  plugin.map 'karmastats', :action => 'stats'
84
107
  plugin.map 'karma :key', :defaults => {:key => false}
108
+ plugin.map 'setkarma :key :val', :defaults => {:key => false}, :requirements => {:val => /^-?\d+$/}, :auth_path => 'edit::set!'
85
109
  plugin.map 'karma for :key'
@@ -9,10 +9,10 @@ class Keyword
9
9
 
10
10
  # type of keyword (e.g. "is" or "are")
11
11
  attr_reader :type
12
-
12
+
13
13
  # type:: type of keyword (e.g "is" or "are")
14
14
  # values:: array of values
15
- #
15
+ #
16
16
  # create a keyword of type +type+ with values +values+
17
17
  def initialize(type, values)
18
18
  @type = type.downcase
@@ -28,6 +28,19 @@ class Keyword
28
28
  end
29
29
  end
30
30
 
31
+ # return an array of all the possible values
32
+ def to_factoids(key)
33
+ ar = Array.new
34
+ @values.each { |val|
35
+ debug "key #{key}, value #{val}"
36
+ vals = val.split(" or ")
37
+ vals.each { |v|
38
+ ar << "%s %s %s" % [key, @type, v]
39
+ }
40
+ }
41
+ return ar
42
+ end
43
+
31
44
  # describe the keyword (show all values without interpolation)
32
45
  def desc
33
46
  @values.join(" | ")
@@ -71,7 +84,7 @@ class Keyword
71
84
  end
72
85
  end
73
86
 
74
- # keywords class.
87
+ # keywords class.
75
88
  #
76
89
  # Handles all that stuff like "bot: foo is bar", "bot: foo?"
77
90
  #
@@ -79,14 +92,20 @@ end
79
92
  # handle it, checks for a keyword command or lookup, otherwise the message
80
93
  # is delegated to plugins
81
94
  class Keywords < Plugin
82
- BotConfig.register BotConfigBooleanValue.new('keyword.listen',
95
+ Config.register Config::BooleanValue.new('keyword.listen',
83
96
  :default => false,
84
97
  :desc => "Should the bot listen to all chat and attempt to automatically detect keywords? (e.g. by spotting someone say 'foo is bar')")
85
- BotConfig.register BotConfigBooleanValue.new('keyword.address',
98
+ Config.register Config::BooleanValue.new('keyword.address',
86
99
  :default => true,
87
100
  :desc => "Should the bot require that keyword lookups are addressed to it? If not, the bot will attempt to lookup foo if someone says 'foo?' in channel")
88
-
89
- # create a new Keywords instance, associated to bot +bot+
101
+ Config.register Config::IntegerValue.new('keyword.search_results',
102
+ :default => 3,
103
+ :desc => "How many search results to display at a time")
104
+ Config.register Config::ArrayValue.new('keyword.ignore_words',
105
+ :default => ["how", "that", "these", "they", "this", "what", "when", "where", "who", "why", "you"],
106
+ :desc => "A list of words that the bot should passively ignore.")
107
+
108
+ # create a new KeywordPlugin instance, associated to bot +bot+
90
109
  def initialize
91
110
  super
92
111
 
@@ -95,7 +114,7 @@ class Keywords < Plugin
95
114
  upgrade_data
96
115
 
97
116
  scan
98
-
117
+
99
118
  # import old format keywords into DBHash
100
119
  if(File.exist?("#{@bot.botclass}/keywords.rbot"))
101
120
  log "auto importing old keywords.rbot"
@@ -113,13 +132,6 @@ class Keywords < Plugin
113
132
  File.rename("#{@bot.botclass}/keywords.rbot", "#{@bot.botclass}/keywords.rbot.old")
114
133
  end
115
134
  end
116
-
117
- # drop static keywords and reload them from files, picking up any new
118
- # keyword files that have been added
119
- def rescan
120
- @statickeywords = Hash.new
121
- scan
122
- end
123
135
 
124
136
  # load static keywords from files, picking up any new keyword files that
125
137
  # have been added
@@ -129,9 +141,9 @@ class Keywords < Plugin
129
141
  next unless f =~ /\.db$/
130
142
  log "upgrading keyword db #{f} (rbot 0.9.5 or prior) database format"
131
143
  newname = f.gsub(/\.db$/, ".kdb")
132
- old = BDB::Hash.open f, nil,
144
+ old = BDB::Hash.open f, nil,
133
145
  "r+", 0600
134
- new = BDB::CIBtree.open(newname, nil,
146
+ new = BDB::CIBtree.open(newname, nil,
135
147
  BDB::CREATE | BDB::EXCL,
136
148
  0600)
137
149
  old.each {|k,v|
@@ -141,7 +153,7 @@ class Keywords < Plugin
141
153
  new.close
142
154
  File.delete(f)
143
155
  }
144
-
156
+
145
157
  # then scan for current DBTree files, and load them
146
158
  Dir["#{@bot.botclass}/keywords/*"].each {|f|
147
159
  next unless f =~ /\.kdb$/
@@ -150,7 +162,7 @@ class Keywords < Plugin
150
162
  debug "keywords module: loading DBTree file #{f}, key #{key}"
151
163
  @statickeywords[key] = hsh
152
164
  }
153
-
165
+
154
166
  # then scan for non DB files, and convert/import them and delete
155
167
  Dir["#{@bot.botclass}/keywords/*"].each {|f|
156
168
  next if f =~ /\.kdb$/
@@ -182,7 +194,7 @@ class Keywords < Plugin
182
194
  def upgrade_data
183
195
  if File.exist?("#{@bot.botclass}/keywords.db")
184
196
  log "upgrading old keywords (rbot 0.9.5 or prior) database format"
185
- old = BDB::Hash.open "#{@bot.botclass}/keywords.db", nil,
197
+ old = BDB::Hash.open "#{@bot.botclass}/keywords.db", nil,
186
198
  "r+", 0600
187
199
  old.each {|k,v|
188
200
  @keywords[k] = v
@@ -191,10 +203,10 @@ class Keywords < Plugin
191
203
  @keywords.flush
192
204
  File.rename("#{@bot.botclass}/keywords.db", "#{@bot.botclass}/keywords.db.old")
193
205
  end
194
-
206
+
195
207
  if File.exist?("#{@bot.botclass}/keyword.db")
196
208
  log "upgrading old keywords (rbot 0.9.9 or prior) database format"
197
- old = BDB::CIBtree.open "#{@bot.botclass}/keyword.db", nil,
209
+ old = BDB::CIBtree.open "#{@bot.botclass}/keyword.db", nil,
198
210
  "r+", 0600
199
211
  old.each {|k,v|
200
212
  @keywords[k] = v
@@ -209,6 +221,7 @@ class Keywords < Plugin
209
221
  def save
210
222
  @keywords.flush
211
223
  end
224
+
212
225
  def oldsave
213
226
  File.open("#{@bot.botclass}/keywords.rbot", "w") do |file|
214
227
  @keywords.each do |key, value|
@@ -216,7 +229,7 @@ class Keywords < Plugin
216
229
  end
217
230
  end
218
231
  end
219
-
232
+
220
233
  # lookup keyword +key+, return it or nil
221
234
  def [](key)
222
235
  return nil if key.nil?
@@ -248,41 +261,52 @@ class Keywords < Plugin
248
261
  return false
249
262
  end
250
263
 
264
+ # is +word+ a passively ignored keyword?
265
+ def ignored_word?(word)
266
+ @bot.config["keyword.ignore_words"].include?(word)
267
+ end
268
+
251
269
  # m:: PrivMessage containing message info
252
270
  # key:: key being queried
253
- # dunno:: optional, if true, reply "dunno" if +key+ not found
254
- #
271
+ # quiet:: optional, if false, complain if +key+ is not found
272
+ #
255
273
  # handle a message asking about a keyword
256
- def keyword(m, key, dunno=true)
274
+ def keyword_lookup(m, key, quiet = false)
257
275
  return if key.nil?
258
- unless(kw = self[key])
259
- m.reply @bot.lang.get("dunno") if (dunno)
260
- return
261
- end
262
- response = kw.to_s
263
- response.gsub!(/<who>/, m.sourcenick)
264
- if(response =~ /^<reply>\s*(.*)/)
265
- m.reply "#$1"
266
- elsif(response =~ /^<action>\s*(.*)/)
267
- @bot.action m.replyto, "#$1"
268
- elsif(m.public? && response =~ /^<topic>\s*(.*)/)
269
- topic = $1
270
- @bot.topic m.target, topic
271
- else
272
- m.reply "#{key} #{kw.type} #{response}"
273
- end
276
+ unless(kw = self[key])
277
+ m.reply "sorry, I don't know about \"#{key}\"" unless quiet
278
+ return
279
+ end
280
+
281
+ response = kw.to_s
282
+ response.gsub!(/<who>/, m.sourcenick)
283
+
284
+ if(response =~ /^<reply>\s*(.*)/)
285
+ m.reply $1
286
+ elsif(response =~ /^<action>\s*(.*)/)
287
+ m.act $1
288
+ elsif(m.public? && response =~ /^<topic>\s*(.*)/)
289
+ @bot.topic m.target, $1
290
+ else
291
+ m.reply "#{key} #{kw.type} #{response}"
292
+ end
274
293
  end
275
294
 
276
-
295
+
277
296
  # handle a message which alters a keyword
278
- # like "foo is bar", or "no, foo is baz", or "foo is also qux"
279
- def keyword_command(sourcenick, target, lhs, mhs, rhs, quiet=false)
297
+ # like "foo is bar" or "foo is also qux"
298
+ def keyword_command(m, lhs, mhs, rhs, quiet = false)
280
299
  debug "got keyword command #{lhs}, #{mhs}, #{rhs}"
300
+ return if lhs.strip.empty?
301
+
281
302
  overwrite = false
282
303
  overwrite = true if(lhs.gsub!(/^no,\s*/, ""))
304
+ also = false
283
305
  also = true if(rhs.gsub!(/^also\s+/, ""))
306
+
284
307
  values = rhs.split(/\s+\|\s+/)
285
308
  lhs = Keyword.unescape lhs
309
+
286
310
  if(overwrite || also || !has_key?(lhs))
287
311
  if(also && has_key?(lhs))
288
312
  kw = self[lhs]
@@ -291,67 +315,65 @@ class Keywords < Plugin
291
315
  else
292
316
  @keywords[lhs] = Keyword.new(mhs, values).dump
293
317
  end
294
- @bot.okay target if !quiet
318
+ m.okay if !quiet
295
319
  elsif(has_key?(lhs))
296
320
  kw = self[lhs]
297
- @bot.say target, "but #{lhs} #{kw.type} #{kw.desc}" if kw && !quiet
321
+ m.reply "but #{lhs} #{kw.type} #{kw.desc}" if kw && !quiet
298
322
  end
299
323
  end
300
324
 
301
325
  # return help string for Keywords with option topic +topic+
302
- def help(plugin, topic="")
303
- case topic
304
- when "overview"
305
- return "set: <keyword> is <definition>, overide: no, <keyword> is <definition>, add to definition: <keyword> is also <definition>, random responses: <keyword> is <definition> | <definition> [| ...], plurals: <keyword> are <definition>, escaping: \\is, \\are, \\|, specials: <reply>, <action>, <who>"
306
- when "set"
307
- return "set => <keyword> is <definition>"
308
- when "plurals"
309
- return "plurals => <keywords> are <definition>"
310
- when "override"
311
- return "overide => no, <keyword> is <definition>"
312
- when "also"
313
- return "also => <keyword> is also <definition>"
314
- when "random"
315
- return "random responses => <keyword> is <definition> | <definition> [| ...]"
316
- when "get"
317
- return "asking for keywords => (with addressing) \"<keyword>?\", (without addressing) \"'<keyword>\""
318
- when "tell"
319
- return "tell <nick> about <keyword> => if <keyword> is known, tell <nick>, via /msg, its definition"
320
- when "forget"
321
- return "forget <keyword> => forget fact <keyword>"
322
- when "keywords"
323
- return "keywords => show current keyword counts"
324
- when "<reply>"
325
- return "<reply> => normal response is \"<keyword> is <definition>\", but if <definition> begins with <reply>, the response will be \"<definition>\""
326
- when "<action>"
327
- return "<action> => makes keyword respnse \"/me <definition>\""
328
- when "<who>"
329
- return "<who> => replaced with questioner in reply"
330
- when "<topic>"
331
- return "<topic> => respond by setting the topic to the rest of the definition"
332
- when "search"
333
- return "keywords search [--all] [--full] <regexp> => search keywords for <regexp>. If --all is set, search static keywords too, if --full is set, search definitions too."
326
+ def help(plugin, topic = '')
327
+ case plugin
328
+ when /keyword/
329
+ case topic
330
+ when 'lookup'
331
+ 'keyword [lookup] <keyword> => look up the definition for a keyword; writing "lookup" is optional'
332
+ when 'set'
333
+ 'keyword set <keyword> is/are <definition> => define a keyword, definition can contain "|" to separate multiple randomly chosen replies'
334
+ when 'forget'
335
+ 'keyword forget <keyword> => forget a keyword'
336
+ when 'tell'
337
+ 'keyword tell <nick> about <keyword> => tell somebody about a keyword'
338
+ when 'search'
339
+ 'keyword search [--all] [--full] <pattern> => search keywords for <pattern>, which can be a regular expression. If --all is set, search static keywords too, if --full is set, search definitions too.'
340
+ when 'listen'
341
+ 'when the config option "keyword.listen" is set to false, rbot will try to extract keyword definitions from regular channel messages'
342
+ when 'address'
343
+ 'when the config option "keyword.address" is set to true, rbot will try to answer channel questions of the form "<keyword>?"'
344
+ when '<reply>'
345
+ '<reply> => normal response is "<keyword> is <definition>", but if <definition> begins with <reply>, the response will be "<definition>"'
346
+ when '<action>'
347
+ '<action> => makes keyword respond with "/me <definition>"'
348
+ when '<who>'
349
+ '<who> => replaced with questioner in reply'
350
+ when '<topic>'
351
+ '<topic> => respond by setting the topic to the rest of the definition'
334
352
  else
335
- return "Keyword module (Fact learning and regurgitation) topics: overview, set, plurals, override, also, random, get, tell, forget, keywords, keywords search, <reply>, <action>, <who>, <topic>"
353
+ 'keyword module (fact learning and regurgitation) topics: lookup, set, forget, tell, search, listen, address, <reply>, <action>, <who>, <topic>'
354
+ end
355
+ when "forget"
356
+ 'forget <keyword> => forget a keyword'
357
+ when "tell"
358
+ 'tell <nick> about <keyword> => tell somebody about a keyword'
359
+ when "learn"
360
+ 'learn that <keyword> is/are <definition> => define a keyword, definition can contain "|" to separate multiple randomly chosen replies'
361
+ else
362
+ 'keyword module (fact learning and regurgitation) topics: lookup, set, forget, tell, search, listen, address, <reply>, <action>, <who>, <topic>'
336
363
  end
337
364
  end
338
365
 
339
366
  # handle a message asking the bot to tell someone about a keyword
340
- def keyword_tell(m, param)
341
- target = param[:target]
342
- key = nil
343
-
344
- # extract the keyword from the message, because unfortunately
345
- # the message mapper doesn't preserve whtiespace
346
- if m.message =~ /about\s+(.+)$/
347
- key = $1
348
- end
349
-
367
+ def keyword_tell(m, target, key)
350
368
  unless(kw = self[key])
351
369
  m.reply @bot.lang.get("dunno_about_X") % key
352
370
  return
353
371
  end
354
-
372
+ if target == @bot.nick
373
+ m.reply "very funny, trying to make me tell something to myself"
374
+ return
375
+ end
376
+
355
377
  response = kw.to_s
356
378
  response.gsub!(/<who>/, m.sourcenick)
357
379
  if(response =~ /^<reply>\s*(.*)/)
@@ -367,7 +389,7 @@ class Keywords < Plugin
367
389
  end
368
390
 
369
391
  # return the number of known keywords
370
- def keyword_stats(m, param)
392
+ def keyword_stats(m)
371
393
  length = 0
372
394
  @statickeywords.each {|k,v|
373
395
  length += v.length
@@ -376,95 +398,171 @@ class Keywords < Plugin
376
398
  end
377
399
 
378
400
  # search for keywords, optionally also the definition and the static keywords
379
- def keyword_search(m, param)
380
- str = param[:pattern]
381
- all = (param[:all] == '--all')
382
- full = (param[:full] == '--full')
383
-
401
+ def keyword_search(m, key, full = false, all = false, from = 1)
384
402
  begin
385
- re = Regexp.new(str, Regexp::IGNORECASE)
386
- if(@bot.auth.allow?("keyword", m.source, m.replyto))
387
- matches = Array.new
388
- @keywords.each {|k,v|
389
- kw = Keyword.restore(v)
390
- if re.match(k) || (full && re.match(kw.desc))
391
- matches << [k,kw]
392
- end
393
- }
394
- if all
395
- @statickeywords.each {|k,v|
396
- v.each {|kk,vv|
397
- kw = Keyword.restore(vv)
398
- if re.match(kk) || (full && re.match(kw.desc))
399
- matches << [kk,kw]
400
- end
401
- }
402
- }
403
+ if key =~ /^\/(.+)\/$/
404
+ re = Regexp.new($1, Regexp::IGNORECASE)
405
+ else
406
+ re = Regexp.new(Regexp.escape(key), Regexp::IGNORECASE)
407
+ end
408
+
409
+ matches = Array.new
410
+ @keywords.each {|k,v|
411
+ kw = Keyword.restore(v)
412
+ if re.match(k) || (full && re.match(kw.desc))
413
+ matches << [k,kw]
403
414
  end
404
- if matches.length == 1
405
- rkw = matches[0]
406
- m.reply "#{rkw[0]} #{rkw[1].type} #{rkw[1].desc}"
407
- elsif matches.length > 0
408
- i = 0
409
- matches.each {|rkw|
410
- m.reply "[#{i+1}/#{matches.length}] #{rkw[0]} #{rkw[1].type} #{rkw[1].desc}"
411
- i += 1
412
- break if i == 3
415
+ }
416
+ if all
417
+ @statickeywords.each {|k,v|
418
+ v.each {|kk,vv|
419
+ kw = Keyword.restore(vv)
420
+ if re.match(kk) || (full && re.match(kw.desc))
421
+ matches << [kk,kw]
422
+ end
413
423
  }
414
- else
415
- m.reply "no keywords match #{str}"
424
+ }
425
+ end
426
+
427
+ if matches.length == 1
428
+ rkw = matches[0]
429
+ m.reply "#{rkw[0]} #{rkw[1].type} #{rkw[1].desc}"
430
+ elsif matches.length > 0
431
+ if from > matches.length
432
+ m.reply "#{matches.length} found, can't tell you about #{from}"
433
+ return
416
434
  end
435
+ i = 1
436
+ matches.each {|rkw|
437
+ m.reply "[#{i}/#{matches.length}] #{rkw[0]} #{rkw[1].type} #{rkw[1].desc}" if i >= from
438
+ i += 1
439
+ break if i == from+@bot.config['keyword.search_results']
440
+ }
441
+ else
442
+ m.reply "no keywords match #{key}"
417
443
  end
418
444
  rescue RegexpError => e
419
- m.reply "no keywords match #{str}: #{e}"
445
+ m.reply "no keywords match #{key}: #{e}"
420
446
  rescue
421
447
  debug e.inspect
422
- m.reply "no keywords match #{str}: an error occurred"
448
+ m.reply "no keywords match #{key}: an error occurred"
423
449
  end
424
450
  end
425
451
 
426
452
  # forget one of the dynamic keywords
427
- def keyword_forget(m, param)
428
- key = param[:key]
429
- if(@keywords.has_key?(key))
430
- @keywords.delete(key)
431
- @bot.okay m.replyto
453
+ def keyword_forget(m, key)
454
+ if @keywords.delete(key)
455
+ m.okay
456
+ else
457
+ m.reply _("couldn't find keyword %{key}" % { :key => key })
458
+ end
459
+ end
460
+
461
+ # low-level keyword wipe command for when forget doesn't work
462
+ def keyword_wipe(m, key)
463
+ reg = @keywords.registry
464
+ reg.env.begin(reg) { |t, b|
465
+ b.delete_if { |k, v|
466
+ (k == key) && (m.reply "wiping keyword #{key} with stored value #{Marshal.restore(v)}")
467
+ }
468
+ t.commit
469
+ }
470
+ m.reply "done"
471
+ end
472
+
473
+ # export keywords to factoids file
474
+ def keyword_factoids_export
475
+ ar = Array.new
476
+
477
+ debug @keywords.keys
478
+
479
+ @keywords.each { |k, val|
480
+ next unless val
481
+ kw = Keyword.restore(val)
482
+ ar |= kw.to_factoids(k)
483
+ }
484
+
485
+ # TODO check factoids config
486
+ # also TODO: runtime export
487
+ dir = File.join(@bot.botclass,"factoids")
488
+ fname = File.join(dir,"keyword_factoids.rbot")
489
+
490
+ Dir.mkdir(dir) unless FileTest.directory?(dir)
491
+ Utils.safe_save(fname) do |file|
492
+ file.puts ar
432
493
  end
433
494
  end
434
495
 
435
496
  # privmsg handler
436
- def listen(m)
437
- return if m.replied?
438
- if(m.address?)
439
- if(!(m.message =~ /\\\?\s*$/) && m.message =~ /^(.*\S)\s*\?\s*$/)
440
- keyword m, $1 if(@bot.auth.allow?("keyword", m.source, m.replyto))
441
- elsif(m.message =~ /^(.*?)\s+(is|are)\s+(.*)$/)
442
- keyword_command(m.sourcenick, m.replyto, $1, $2, $3) if(@bot.auth.allow?("keycmd", m.source, m.replyto))
497
+ def privmsg(m)
498
+ case m.plugin
499
+ when "keyword"
500
+ case m.params
501
+ when /^export$/
502
+ begin
503
+ keyword_factoids_export
504
+ m.okay
505
+ rescue
506
+ m.reply _("failed to export keywords as factoids (%{err})" % {:err => $!})
507
+ end
508
+ when /^set\s+(.+?)\s+(is|are)\s+(.+)$/
509
+ keyword_command(m, $1, $2, $3) if @bot.auth.allow?('keycmd', m.source, m.replyto)
510
+ when /^forget\s+(.+)$/
511
+ keyword_forget(m, $1) if @bot.auth.allow?('keycmd', m.source, m.replyto)
512
+ when /^wipe\s(.+)$/ # note that only one space is stripped, allowing removal of space-prefixed keywords
513
+ keyword_wipe(m, $1) if @bot.auth.allow?('keycmd', m.source, m.replyto)
514
+ when /^lookup\s+(.+)$/
515
+ keyword_lookup(m, $1) if @bot.auth.allow?('keyword', m.source, m.replyto)
516
+ when /^stats\s*$/
517
+ keyword_stats(m) if @bot.auth.allow?('keyword', m.source, m.replyto)
518
+ when /^search\s+(.+)$/
519
+ key = $1
520
+ full = key.sub!('--full ', '')
521
+ all = key.sub!('--all ', '')
522
+ if key.sub!(/--from (\d+) /, '')
523
+ from = $1.to_i
524
+ else
525
+ from = 1
526
+ end
527
+ from = 1 unless from > 0
528
+ keyword_search(m, key, full, all, from) if @bot.auth.allow?('keyword', m.source, m.replyto)
529
+ when /^tell\s+(\S+)\s+about\s+(.+)$/
530
+ keyword_tell(m, $1, $2) if @bot.auth.allow?('keyword', m.source, m.replyto)
531
+ else
532
+ keyword_lookup(m, m.params) if @bot.auth.allow?('keyword', m.source, m.replyto)
443
533
  end
444
- else
445
- # in channel message, not to me
446
- # TODO option to do if(m.message =~ /^(.*)$/, ie try any line as a
447
- # keyword lookup.
448
- if(m.message =~ /^'(.*)$/ || (!@bot.config["keyword.address"] && m.message =~ /^(.*\S)\s*\?\s*$/))
449
- keyword m, $1, false if(@bot.auth.allow?("keyword", m.source))
450
- elsif(@bot.config["keyword.listen"] == true && (m.message =~ /^(.*?)\s+(is|are)\s+(.*)$/))
451
- # TODO MUCH more selective on what's allowed here
452
- keyword_command(m.sourcenick, m.replyto, $1, $2, $3, true) if(@bot.auth.allow?("keycmd", m.source))
534
+ when "forget"
535
+ keyword_forget(m, m.params) if @bot.auth.allow?('keycmd', m.source, m.replyto)
536
+ when "tell"
537
+ if m.params =~ /(\S+)\s+about\s+(.+)$/
538
+ keyword_tell(m, $1, $2) if @bot.auth.allow?('keyword', m.source, m.replyto)
539
+ else
540
+ m.reply "wrong 'tell' syntax"
541
+ end
542
+ when "learn"
543
+ if m.params =~ /^that\s+(.+?)\s+(is|are)\s+(.+)$/
544
+ keyword_command(m, $1, $2, $3) if @bot.auth.allow?('keycmd', m.source, m.replyto)
545
+ else
546
+ m.reply "wrong 'learn' syntax"
453
547
  end
454
548
  end
455
549
  end
550
+
551
+ def unreplied(m)
552
+ # TODO option to do if(m.message =~ /^(.*)$/, ie try any line as a
553
+ # keyword lookup.
554
+ if m.message =~ /^(.*\S)\s*\?\s*$/ and (m.address? or not @bot.config["keyword.address"])
555
+ keyword_lookup m, $1, true if !ignored_word?($1) && @bot.auth.allow?("keyword", m.source)
556
+ elsif @bot.config["keyword.listen"] && (m.message =~ /^(.*?)\s+(is|are)\s+(.*)$/)
557
+ # TODO MUCH more selective on what's allowed here
558
+ keyword_command m, $1, $2, $3, true if !ignored_word?($1) && @bot.auth.allow?("keycmd", m.source)
559
+ end
560
+ end
456
561
  end
457
562
 
458
563
  plugin = Keywords.new
564
+ plugin.register 'keyword'
565
+ plugin.register 'forget' rescue nil
566
+ plugin.register 'tell' rescue nil
567
+ plugin.register 'learn' rescue nil
459
568
 
460
- plugin.map 'keyword stats', :action => 'keyword_stats'
461
-
462
- plugin.map 'keyword search :all :full :pattern', :action => 'keyword_search',
463
- :defaults => {:all => '', :full => ''},
464
- :requirements => {:all => '--all', :full => '--full'}
465
-
466
- plugin.map 'keyword forget :key', :action => 'keyword_forget'
467
- plugin.map 'forget :key', :action => 'keyword_forget', :auth => 'keycmd'
468
-
469
- plugin.map 'keyword tell :target about *keyword', :action => 'keyword_tell'
470
- plugin.map 'tell :target about *keyword', :action => 'keyword_tell', :auth => 'keyword'