butler 1.8.3 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/CHANGELOG.txt +293 -37
  2. data/README.txt +10 -0
  3. data/Rakefile +24 -13
  4. data/bin/botcontrol +6 -5
  5. data/data/butler/dialogs/create.rb +21 -6
  6. data/data/butler/dialogs/create_config.rb +5 -2
  7. data/data/butler/dialogs/en/create.yaml +6 -3
  8. data/data/butler/dialogs/en/create_config.yaml +1 -0
  9. data/data/butler/dialogs/en/quickcreate.yaml +1 -1
  10. data/data/butler/dialogs/en/sync.yaml +7 -0
  11. data/data/butler/dialogs/en/username.yaml +2 -0
  12. data/data/butler/dialogs/quickcreate.rb +6 -2
  13. data/data/butler/dialogs/sync.rb +83 -0
  14. data/data/butler/dialogs/username.rb +1 -0
  15. data/data/butler/plugins/core/ping.rb +22 -0
  16. data/data/butler/plugins/core/remote.rb +38 -0
  17. data/data/butler/plugins/dev/eval.rb +6 -4
  18. data/data/butler/plugins/dev/onhandlers.rb +93 -0
  19. data/data/butler/plugins/dev/rawlog.rb +109 -45
  20. data/data/butler/plugins/games/countdown.rb +23 -14
  21. data/data/butler/plugins/games/eightball.rb +21 -13
  22. data/data/butler/plugins/games/roll.rb +12 -12
  23. data/data/butler/plugins/irc/join.rb +2 -2
  24. data/data/butler/plugins/irc/notice.rb +10 -10
  25. data/data/butler/plugins/irc/part.rb +12 -12
  26. data/data/butler/plugins/irc/privmsg.rb +10 -10
  27. data/data/butler/plugins/irc/quit.rb +12 -12
  28. data/data/butler/plugins/operator/devoice.rb +1 -1
  29. data/data/butler/plugins/public/help.rb +10 -4
  30. data/data/butler/plugins/{util → service}/calculator.rb +0 -0
  31. data/data/butler/plugins/service/define.rb +16 -13
  32. data/data/butler/plugins/service/log.rb +85 -0
  33. data/data/butler/plugins/service/seen.rb +64 -0
  34. data/data/butler/plugins/service/svn.rb +6 -5
  35. data/data/butler/plugins/util/load.rb +3 -1
  36. data/data/butler/services/org.rubyforge.butler/calculator/1/service.rb +96 -0
  37. data/data/butler/services/org.rubyforge.butler/log/1/service.rb +148 -68
  38. data/lib/access/admin.rb +5 -0
  39. data/lib/blank.rb +32 -0
  40. data/lib/butler.rb +4 -4
  41. data/lib/butler/bot.rb +118 -33
  42. data/lib/butler/control.rb +5 -4
  43. data/lib/butler/debuglog.rb +12 -4
  44. data/lib/butler/dialog.rb +1 -1
  45. data/lib/butler/initialvalues.rb +1 -1
  46. data/lib/butler/irc/client.rb +31 -12
  47. data/lib/butler/irc/message.rb +32 -13
  48. data/lib/butler/irc/parser.rb +67 -30
  49. data/lib/butler/irc/parser/{commands.rb → command.rb} +0 -38
  50. data/lib/butler/irc/parser/generic.rb +9 -12
  51. data/lib/butler/irc/parser/rfc2812.rb +40 -2
  52. data/lib/butler/irc/socket.rb +66 -41
  53. data/lib/butler/irc/string.rb +1 -5
  54. data/lib/butler/plugin.rb +56 -23
  55. data/lib/butler/plugin/configproxy.rb +1 -0
  56. data/lib/butler/plugin/more.rb +2 -2
  57. data/lib/butler/plugins.rb +7 -1
  58. data/lib/butler/remote/connection.rb +113 -0
  59. data/lib/butler/remote/message.rb +157 -0
  60. data/lib/butler/remote/server.rb +85 -0
  61. data/lib/butler/remote/user.rb +46 -0
  62. data/lib/butler/service.rb +2 -1
  63. data/lib/butler/services.rb +2 -2
  64. data/lib/butler/version.rb +2 -2
  65. data/lib/configuration.rb +13 -16
  66. data/lib/ostructfixed.rb +0 -6
  67. data/lib/ruby/array/random.rb +2 -1
  68. data/lib/scriptfile.rb +63 -14
  69. data/lib/timingoutresource.rb +54 -0
  70. data/test/test_scriptfile.rb +51 -0
  71. metadata +63 -61
  72. data/data/butler/dialogs/en/sync_plugins.yaml +0 -3
  73. data/data/butler/dialogs/sync_plugins.rb +0 -30
  74. data/data/butler/services/org.rubyforge.butler/calculator/1/calculator.rb +0 -68
  75. data/lib/log/splitter.rb +0 -30
  76. data/test/test_access/privilege/banners.statistics.yaml +0 -3
  77. data/test/test_access/privilege/banners.yaml +0 -3
  78. data/test/test_access/privilege/news.create.yaml +0 -3
  79. data/test/test_access/privilege/news.delete.yaml +0 -3
  80. data/test/test_access/privilege/news.edit.yaml +0 -3
  81. data/test/test_access/privilege/news.read.yaml +0 -3
  82. data/test/test_access/privilege/news.yaml +0 -3
  83. data/test/test_access/privilege/paid_content.yaml +0 -3
  84. data/test/test_access/privilege/statistics.ftp.yaml +0 -3
  85. data/test/test_access/privilege/statistics.web.yaml +0 -3
  86. data/test/test_access/privilege/statistics.yaml +0 -3
  87. data/test/test_access/role/chiefeditor.yaml +0 -7
  88. data/test/test_access/role/editor.yaml +0 -9
  89. data/test/test_access/user/test.yaml +0 -12
@@ -6,12 +6,19 @@
6
6
 
7
7
 
8
8
 
9
- def on_countdown
10
- return answer(usage) if @message.arguments.length < 2
11
- answer = Answers[rand(Answers.length)]
12
- @butler.irc.action(_(:shake), message.channel ? message.channel : message.from)
13
- sleep(1.5)
14
- answer(answer)
9
+ def on_countdown(params)
10
+ params.from ||= 3
11
+ params.to ||= 0
12
+ params.final ||= _(:go)
13
+ if params.from > params.to then
14
+ params.from.downto(params.to+1) { |i|
15
+ answer(:count, :value => i)
16
+ sleep(1)
17
+ }
18
+ answer(params.final)
19
+ else
20
+ answer(:illegal)
21
+ end
15
22
  end
16
23
 
17
24
  __END__
@@ -25,16 +32,18 @@ __END__
25
32
  :version: "1.0.0"
26
33
  :author: "Stefan Rusterholz"
27
34
  :strings:
28
- :xmap:
29
- :on_countdown
30
- :en:
31
- - countdown :from
32
- - countdown from :from :to
33
- - countdown from :from to :to
34
- - countdown from :from
35
+ :count:
36
+ en: '<%= value %>...'
37
+ :illegal:
38
+ en: 'Illegal countdown, from must be bigger than to'
39
+ :go:
40
+ en: 'Go!'
41
+ :map:
42
+ :on_countdown:
43
+ en: countdown [from :from@+Integer] [to :to@+Integer] [saying +final]
35
44
  :usage:
36
45
  en: |
37
- ![b]countdown![o]
46
+ ![b]countdown![o] [from] :from [to :to]
38
47
  :help:
39
48
  en:
40
49
  "": |
@@ -6,8 +6,6 @@
6
6
 
7
7
 
8
8
 
9
- trigger "8ball"
10
-
11
9
  Answers = [:yes, :no, :notgood, :signs_yes, :signs_no, :why_ask, :unclear]
12
10
 
13
11
  def on_trigger
@@ -20,35 +18,45 @@ end
20
18
 
21
19
  __END__
22
20
  ---
23
- :revision:
24
- :plugin: 1
25
- :summary:
26
- en: Ask butler a question and get an answer from the magic eightball.
27
21
  :about:
28
22
  :mail: "apeiros@gmx.net"
29
23
  :version: "1.0.0"
30
24
  :author: "Stefan Rusterholz"
25
+ :help:
26
+ en:
27
+ "": |
28
+ Ask butler a question and get an answer from the magic eightball.
29
+ :revision:
30
+ :plugin: 1
31
31
  :strings:
32
32
  :shake:
33
33
  en: 'Shakes the magic 8-ball...'
34
+ de: 'Schüttelt den magischen 8-ball...'
34
35
  :yes:
35
36
  en: 'Yes.'
37
+ de: 'Ja.'
36
38
  :no:
37
- en: 'no.'
39
+ en: 'No.'
40
+ de: 'Nein.'
38
41
  :notgood:
39
42
  en: 'Outlook is not so good.'
43
+ de: 'Die Aussichten stehen schlecht.'
40
44
  :signs_yes:
41
45
  en: 'All signs point to yes.'
42
- :signs no:
46
+ de: 'Alle Zeichen deuten auf ja.'
47
+ :signs_no:
43
48
  en: 'All signs point to no.'
49
+ de: 'Alle Zeichen deuten auf nein.'
44
50
  :why_ask:
45
- en: 'Why the hell are you asking me?'
51
+ en: 'Why the hell are you asking ![b]me![o]?'
52
+ de: 'Warum zur Hölle fragst du ![b]mich![o] das?'
46
53
  :unclear:
47
54
  en: 'The answer is unclear.'
55
+ de: 'Die Antwort ist unklar.'
56
+ :summary:
57
+ en: Ask butler a question and get an answer from the magic eightball.
58
+ :trigger:
59
+ en: 8ball
48
60
  :usage:
49
61
  en: |
50
62
  ![b]8ball![o] *![c(blue)]question![o]
51
- :help:
52
- en:
53
- "": |
54
- Ask butler a question and get an answer from the magic eightball.
@@ -6,8 +6,6 @@
6
6
 
7
7
 
8
8
 
9
- trigger "roll"
10
-
11
9
  def on_trigger
12
10
  answer(:roll, :result => roll(@message.post_arguments[1]))
13
11
  end
@@ -33,20 +31,10 @@ end
33
31
 
34
32
  __END__
35
33
  ---
36
- :revision:
37
- :plugin: 1
38
- :summary:
39
- en: Roll dices.
40
34
  :about:
41
35
  :mail: "apeiros@gmx.net"
42
36
  :version: "1.0.0"
43
37
  :author: "Stefan Rusterholz"
44
- :strings:
45
- :roll:
46
- en: "You rolled: <%= result.join(', ') %>"
47
- :usage:
48
- en: |
49
- ![b]roll![o] *![c(blue)]dice serie![o]
50
38
  :help:
51
39
  en:
52
40
  "": |
@@ -57,3 +45,15 @@ __END__
57
45
  3d10 rolls 3 dices with 10 sides and shows the sum.
58
46
  "chances": |
59
47
  Chances are esentially 100 sided dices.
48
+ :revision:
49
+ :plugin: 1
50
+ :strings:
51
+ :roll:
52
+ en: "You rolled: <%= result.join(', ') %>"
53
+ :summary:
54
+ en: Roll dices.
55
+ :trigger:
56
+ en: roll
57
+ :usage:
58
+ en: |
59
+ ![b]roll![o] *![c(blue)]dice serie![o]
@@ -6,8 +6,6 @@
6
6
 
7
7
 
8
8
 
9
- trigger "join"
10
-
11
9
  def on_trigger
12
10
  return answer(usage) unless @message.arguments[1]
13
11
  answer(:joining, :name => @message.arguments[1])
@@ -27,6 +25,8 @@ __END__
27
25
  :strings:
28
26
  :joining:
29
27
  en: Joining channel <%= name %>.
28
+ :trigger:
29
+ en: join
30
30
  :usage:
31
31
  en: |
32
32
  ![b]join![o] ![c(green)]channel![o]
@@ -6,8 +6,6 @@
6
6
 
7
7
 
8
8
 
9
- trigger "notice"
10
-
11
9
  def on_trigger
12
10
  return answer(usage) if @message.arguments.length < 3
13
11
  @butler.irc.notice(@message.post_arguments[2], @message.arguments[1])
@@ -16,21 +14,23 @@ end
16
14
 
17
15
  __END__
18
16
  ---
19
- :revision:
20
- :plugin: 1
21
- :summary:
22
- en: Let butler send a notice to a user or channel
23
17
  :about:
24
18
  :mail: "apeiros@gmx.net"
25
19
  :version: "1.0.0"
26
20
  :author: "Stefan Rusterholz"
21
+ :help:
22
+ "":
23
+ en: |
24
+ Let butler send a notice to a user or channel.
25
+ :revision:
26
+ :plugin: 1
27
27
  :strings:
28
28
  :sent:
29
29
  en: Sent the message
30
+ :summary:
31
+ en: Let butler send a notice to a user or channel
32
+ :trigger:
33
+ en: notice
30
34
  :usage:
31
35
  en: |
32
36
  ![b]notice![o] (![c(green)]nick![o] | ![c(green)]channel![o])
33
- :help:
34
- "":
35
- en: |
36
- Let butler send a notice to a user or channel.
@@ -6,8 +6,6 @@
6
6
 
7
7
 
8
8
 
9
- trigger "part"
10
-
11
9
  def on_trigger
12
10
  return answer(usage) unless @message.arguments[1]
13
11
  answer(:parting, :name => @message.arguments[1])
@@ -16,23 +14,25 @@ end
16
14
 
17
15
  __END__
18
16
  ---
19
- :revision:
20
- :plugin: 1
21
- :summary:
22
- en: Let Butler part from channels
23
17
  :about:
24
18
  :mail: "apeiros@gmx.net"
25
19
  :version: "1.0.0"
26
20
  :author: "Stefan Rusterholz"
27
- :strings:
28
- :parting:
29
- en: Parting channel <%= name %>.
30
- :usage:
31
- en: |
32
- ![b]part![o] ![c(green)]channel![o]
33
21
  :help:
34
22
  en:
35
23
  "": |
36
24
  You can use 'join' to let butler part from channels.
37
25
  "related": |
38
26
  Related triggers: join.
27
+ :revision:
28
+ :plugin: 1
29
+ :strings:
30
+ :parting:
31
+ en: Parting channel <%= name %>.
32
+ :summary:
33
+ en: Let Butler part from channels
34
+ :trigger:
35
+ en: part
36
+ :usage:
37
+ en: |
38
+ ![b]part![o] ![c(green)]channel![o]
@@ -6,8 +6,6 @@
6
6
 
7
7
 
8
8
 
9
- trigger "privmsg"
10
-
11
9
  def on_trigger
12
10
  return answer(usage) if @message.arguments.length < 3
13
11
  @butler.irc.privmsg(@message.post_arguments[2], @message.arguments[1])
@@ -16,21 +14,23 @@ end
16
14
 
17
15
  __END__
18
16
  ---
19
- :revision:
20
- :plugin: 1
21
- :summary:
22
- en: Let butler send a private message to a user or channel
23
17
  :about:
24
18
  :mail: "apeiros@gmx.net"
25
19
  :version: "1.0.0"
26
20
  :author: "Stefan Rusterholz"
21
+ :help:
22
+ en:
23
+ "": |
24
+ Let butler send a private message to a user or channel.
25
+ :revision:
26
+ :plugin: 1
27
27
  :strings:
28
28
  :sent:
29
29
  en: Sent the message
30
+ :summary:
31
+ en: Let butler send a private message to a user or channel
32
+ :trigger:
33
+ en: privmsg
30
34
  :usage:
31
35
  en: |
32
36
  ![b]privmsg![o] (![c(green)]nick![o] | ![c(green)]channel![o])
33
- :help:
34
- en:
35
- "": |
36
- Let butler send a private message to a user or channel.
@@ -6,31 +6,31 @@
6
6
 
7
7
 
8
8
 
9
- trigger "quit"
10
-
11
9
  def on_trigger
12
10
  @butler.irc.quit(@message.post_arguments[1] || localize(:default_reason))
13
11
  end
14
12
 
15
13
  __END__
16
14
  ---
17
- :revision:
18
- :plugin: 1
19
- :summary:
20
- en: Lets Butler quit from IRC and disconnect from the server.
21
15
  :about:
22
16
  :mail: "apeiros@gmx.net"
23
17
  :version: "1.0.0"
24
18
  :author: "Stefan Rusterholz"
25
- :strings:
26
- :default_reason:
27
- en: I was terminated! Bye!
28
- :usage:
29
- en: |
30
- ![b]quit![o] [*![c(blue)]reason![o]]
31
19
  :help:
32
20
  en:
33
21
  "": |
34
22
  You can use 'quit' to let butler quit from irc and disconnect.
35
23
  "related": |
36
24
  Related triggers: reconnect.
25
+ :revision:
26
+ :plugin: 1
27
+ :strings:
28
+ :default_reason:
29
+ en: I was terminated! Bye!
30
+ :summary:
31
+ en: Lets Butler quit from IRC and disconnect from the server.
32
+ :trigger:
33
+ en: quit
34
+ :usage:
35
+ en: |
36
+ ![b]quit![o] [*![c(blue)]reason![o]]
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- def on_voice(params)
9
+ def on_devoice(params)
10
10
  channel = params.channel || message.channel
11
11
  nicks = params.user || [message.from.nick]
12
12
 
@@ -16,13 +16,17 @@ def on_trigger
16
16
  help = help[@message.language] || help["en"]
17
17
  if @message.arguments.last == "+" then
18
18
  topics = help.keys.sort[1..-1].map { |t| "'#{t}'" }.columnize(5)
19
- answer(:topics, :topics => topics)
19
+ unless topics.empty?
20
+ answer(:topics, :topics => topics)
21
+ else
22
+ answer(:notopics)
23
+ end
20
24
  else
21
25
  key = @message.arguments[2..-1].join(" ")
22
26
  if help = help[key] then
23
27
  answer(help.result(self))
24
28
  else
25
- answer(key.empty? ? :nohelp : :notopic, :topic => key)
29
+ answer(:nohelp) if key.empty?
26
30
  end
27
31
  end
28
32
  else
@@ -55,6 +59,8 @@ __END__
55
59
  en: "Plugin doesn't provide help for '<%= topic %>'."
56
60
  :nolang:
57
61
  en: "Plugin doesn't provide help for '<%= topic %>' in that language."
62
+ :notopics:
63
+ en: "Plugin doesn't provide any topics"
58
64
  :topics:
59
65
  en: |
60
66
  Topics for the plugin:
@@ -65,5 +71,5 @@ __END__
65
71
  en:
66
72
  "": |
67
73
  help gives help about itself or a command.
68
- If + is the last argument, it will list the available help topics.
69
- Use 'plugins list' to get a list of available commands.
74
+ Call 'help plugin +' to list the available help topics.
75
+ Use 'list plugins' to get a list of available plugins.
@@ -12,15 +12,16 @@ require 'cgi'
12
12
 
13
13
  Query = "http://www.google.com/search?client=butler&rls=%s&q=define:+%s&ie=UTF-8&oe=UTF-8"
14
14
 
15
- trigger "define"
16
-
17
15
  def on_trigger
18
16
  word = @message.post_arguments[1]
19
17
  doc = Hpricot(open(Query%[@message.language, CGI.escape(word)]))
20
- see_also = (doc/"//font[1]/p/a")[5..-1].map { |e| e.inner_text }
21
- found = (doc/"//ul/font/li").find { |e| (e/"//a").inner_text.include?("wikipedia.org") }
18
+ see_also = (doc/"//font[1]/p/a")
19
+ see_also = see_also && see_also[5..-1]
20
+ see_also = see_also && see_also.map { |e| e.inner_text }
21
+ found = (doc/"//ul/font/li")
22
+ found = found && found.find { |e| (e/"//a").inner_text.include?("wikipedia.org") }
22
23
  if found then
23
- more('![b]word![o]', found.inner_text.sub(%r{\w+\.wikipedia\.org/wiki/.*?$}, ''))
24
+ answer_with_lead("![b]#{word}![o]", found.inner_text.sub(%r{\w+\.wikipedia\.org/wiki/.*?$}, ''))
24
25
  else
25
26
  answer(:not_found, :search_string => word)
26
27
  end
@@ -28,20 +29,22 @@ end
28
29
 
29
30
  __END__
30
31
  ---
31
- :revision:
32
- :plugin: 1
33
- :configuration: 1
34
- :summary:
35
- en: "Use googles define: to find the definition of words."
36
32
  :about:
37
33
  :mail: "apeiros@gmx.net"
38
34
  :version: "1.0.0"
39
35
  :author: "Stefan Rusterholz"
40
- :usage:
41
- en: "![b]define![o] *search_string"
42
36
  :help:
43
37
  en:
44
38
  "": "Use googles define: to find the definition of words."
39
+ :revision:
40
+ :plugin: 2
41
+ :configuration: 1
45
42
  :strings:
46
43
  :not_found:
47
- en: No search result for '<%= search_string %>'.
44
+ en: No search result for '<%= search_string %>'.
45
+ :summary:
46
+ en: "Use googles define: to find the definition of words."
47
+ :trigger:
48
+ en: define
49
+ :usage:
50
+ en: "![b]define![o] *search_string"