butler 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. data/CHANGELOG +4 -0
  2. data/GPL.txt +340 -0
  3. data/LICENSE.txt +52 -0
  4. data/README +37 -0
  5. data/Rakefile +334 -0
  6. data/bin/botcontrol +230 -0
  7. data/data/butler/config_template.yaml +4 -0
  8. data/data/butler/dialogs/backup.rb +19 -0
  9. data/data/butler/dialogs/botcontrol.rb +4 -0
  10. data/data/butler/dialogs/config.rb +1 -0
  11. data/data/butler/dialogs/create.rb +53 -0
  12. data/data/butler/dialogs/delete.rb +3 -0
  13. data/data/butler/dialogs/en/backup.yaml +6 -0
  14. data/data/butler/dialogs/en/botcontrol.yaml +5 -0
  15. data/data/butler/dialogs/en/create.yaml +11 -0
  16. data/data/butler/dialogs/en/delete.yaml +2 -0
  17. data/data/butler/dialogs/en/help.yaml +17 -0
  18. data/data/butler/dialogs/en/info.yaml +13 -0
  19. data/data/butler/dialogs/en/list.yaml +4 -0
  20. data/data/butler/dialogs/en/notyetimplemented.yaml +2 -0
  21. data/data/butler/dialogs/en/rename.yaml +3 -0
  22. data/data/butler/dialogs/en/start.yaml +3 -0
  23. data/data/butler/dialogs/en/sync_plugins.yaml +3 -0
  24. data/data/butler/dialogs/en/uninstall.yaml +5 -0
  25. data/data/butler/dialogs/en/unknown_command.yaml +2 -0
  26. data/data/butler/dialogs/help.rb +11 -0
  27. data/data/butler/dialogs/info.rb +27 -0
  28. data/data/butler/dialogs/interactive.rb +1 -0
  29. data/data/butler/dialogs/list.rb +10 -0
  30. data/data/butler/dialogs/notyetimplemented.rb +1 -0
  31. data/data/butler/dialogs/rename.rb +4 -0
  32. data/data/butler/dialogs/selectbot.rb +2 -0
  33. data/data/butler/dialogs/start.rb +5 -0
  34. data/data/butler/dialogs/sync_plugins.rb +30 -0
  35. data/data/butler/dialogs/uninstall.rb +17 -0
  36. data/data/butler/dialogs/unknown_command.rb +1 -0
  37. data/data/butler/plugins/core/logout.rb +41 -0
  38. data/data/butler/plugins/core/plugins.rb +134 -0
  39. data/data/butler/plugins/core/privilege.rb +103 -0
  40. data/data/butler/plugins/core/user.rb +166 -0
  41. data/data/butler/plugins/dev/eval.rb +64 -0
  42. data/data/butler/plugins/dev/nometa.rb +14 -0
  43. data/data/butler/plugins/dev/onhandlers.rb +93 -0
  44. data/data/butler/plugins/dev/raw.rb +36 -0
  45. data/data/butler/plugins/dev/rawlog.rb +77 -0
  46. data/data/butler/plugins/games/eightball.rb +54 -0
  47. data/data/butler/plugins/games/mastermind.rb +174 -0
  48. data/data/butler/plugins/irc/action.rb +36 -0
  49. data/data/butler/plugins/irc/join.rb +38 -0
  50. data/data/butler/plugins/irc/notice.rb +36 -0
  51. data/data/butler/plugins/irc/part.rb +38 -0
  52. data/data/butler/plugins/irc/privmsg.rb +36 -0
  53. data/data/butler/plugins/irc/quit.rb +36 -0
  54. data/data/butler/plugins/operator/deop.rb +41 -0
  55. data/data/butler/plugins/operator/devoice.rb +41 -0
  56. data/data/butler/plugins/operator/limit.rb +47 -0
  57. data/data/butler/plugins/operator/op.rb +41 -0
  58. data/data/butler/plugins/operator/voice.rb +41 -0
  59. data/data/butler/plugins/public/help.rb +69 -0
  60. data/data/butler/plugins/public/login.rb +72 -0
  61. data/data/butler/plugins/public/usage.rb +49 -0
  62. data/data/butler/plugins/service/clones.rb +56 -0
  63. data/data/butler/plugins/service/define.rb +47 -0
  64. data/data/butler/plugins/service/log.rb +183 -0
  65. data/data/butler/plugins/service/svn.rb +91 -0
  66. data/data/butler/plugins/util/cycle.rb +98 -0
  67. data/data/butler/plugins/util/load.rb +41 -0
  68. data/data/butler/plugins/util/pong.rb +29 -0
  69. data/data/butler/strings/random/acknowledge.en.yaml +5 -0
  70. data/data/butler/strings/random/gratitude.en.yaml +3 -0
  71. data/data/butler/strings/random/hello.en.yaml +4 -0
  72. data/data/butler/strings/random/ignorance.en.yaml +7 -0
  73. data/data/butler/strings/random/ignorance_about.en.yaml +3 -0
  74. data/data/butler/strings/random/insult.en.yaml +3 -0
  75. data/data/butler/strings/random/rejection.en.yaml +12 -0
  76. data/data/man/botcontrol.1 +17 -0
  77. data/lib/access.rb +187 -0
  78. data/lib/access/admin.rb +16 -0
  79. data/lib/access/privilege.rb +122 -0
  80. data/lib/access/role.rb +102 -0
  81. data/lib/access/savable.rb +18 -0
  82. data/lib/access/user.rb +180 -0
  83. data/lib/access/yamlbase.rb +126 -0
  84. data/lib/butler.rb +188 -0
  85. data/lib/butler/bot.rb +247 -0
  86. data/lib/butler/control.rb +93 -0
  87. data/lib/butler/dialog.rb +64 -0
  88. data/lib/butler/initialvalues.rb +40 -0
  89. data/lib/butler/irc/channel.rb +135 -0
  90. data/lib/butler/irc/channels.rb +96 -0
  91. data/lib/butler/irc/client.rb +351 -0
  92. data/lib/butler/irc/hostmask.rb +53 -0
  93. data/lib/butler/irc/message.rb +184 -0
  94. data/lib/butler/irc/parser.rb +125 -0
  95. data/lib/butler/irc/parser/commands.rb +83 -0
  96. data/lib/butler/irc/parser/generic.rb +343 -0
  97. data/lib/butler/irc/socket.rb +378 -0
  98. data/lib/butler/irc/string.rb +186 -0
  99. data/lib/butler/irc/topic.rb +15 -0
  100. data/lib/butler/irc/user.rb +265 -0
  101. data/lib/butler/irc/users.rb +112 -0
  102. data/lib/butler/plugin.rb +249 -0
  103. data/lib/butler/plugin/configproxy.rb +35 -0
  104. data/lib/butler/plugin/mapper.rb +85 -0
  105. data/lib/butler/plugin/matcher.rb +55 -0
  106. data/lib/butler/plugin/onhandlers.rb +70 -0
  107. data/lib/butler/plugin/trigger.rb +58 -0
  108. data/lib/butler/plugins.rb +147 -0
  109. data/lib/butler/version.rb +17 -0
  110. data/lib/cloptions.rb +217 -0
  111. data/lib/cloptions/adapters.rb +24 -0
  112. data/lib/cloptions/switch.rb +132 -0
  113. data/lib/configuration.rb +223 -0
  114. data/lib/dialogline.rb +296 -0
  115. data/lib/dialogline/localizations.rb +24 -0
  116. data/lib/durations.rb +57 -0
  117. data/lib/event.rb +295 -0
  118. data/lib/event/at.rb +64 -0
  119. data/lib/event/every.rb +56 -0
  120. data/lib/event/timed.rb +112 -0
  121. data/lib/installer.rb +75 -0
  122. data/lib/iterator.rb +34 -0
  123. data/lib/log.rb +68 -0
  124. data/lib/log/comfort.rb +85 -0
  125. data/lib/log/converter.rb +23 -0
  126. data/lib/log/entry.rb +152 -0
  127. data/lib/log/fakeio.rb +55 -0
  128. data/lib/log/file.rb +54 -0
  129. data/lib/log/filereader.rb +81 -0
  130. data/lib/log/forward.rb +49 -0
  131. data/lib/log/methods.rb +39 -0
  132. data/lib/log/nolog.rb +18 -0
  133. data/lib/log/splitter.rb +26 -0
  134. data/lib/ostructfixed.rb +26 -0
  135. data/lib/ruby/array/columnize.rb +38 -0
  136. data/lib/ruby/dir/mktree.rb +28 -0
  137. data/lib/ruby/enumerable/join.rb +13 -0
  138. data/lib/ruby/exception/detailed.rb +24 -0
  139. data/lib/ruby/file/append.rb +11 -0
  140. data/lib/ruby/file/write.rb +11 -0
  141. data/lib/ruby/hash/zip.rb +15 -0
  142. data/lib/ruby/kernel/bench.rb +15 -0
  143. data/lib/ruby/kernel/daemonize.rb +42 -0
  144. data/lib/ruby/kernel/non_verbose.rb +17 -0
  145. data/lib/ruby/kernel/safe_fork.rb +18 -0
  146. data/lib/ruby/range/stepped.rb +11 -0
  147. data/lib/ruby/string/arguments.rb +72 -0
  148. data/lib/ruby/string/chunks.rb +15 -0
  149. data/lib/ruby/string/post_arguments.rb +44 -0
  150. data/lib/ruby/string/unescaped.rb +17 -0
  151. data/lib/scheduler.rb +164 -0
  152. data/lib/scriptfile.rb +101 -0
  153. data/lib/templater.rb +86 -0
  154. data/test/cloptions.rb +134 -0
  155. data/test/cv.rb +28 -0
  156. data/test/irc/client.rb +85 -0
  157. data/test/irc/client_login.txt +53 -0
  158. data/test/irc/client_subscribe.txt +8 -0
  159. data/test/irc/message.rb +30 -0
  160. data/test/irc/messages.txt +64 -0
  161. data/test/irc/parser.rb +13 -0
  162. data/test/irc/profile_parser.rb +12 -0
  163. data/test/irc/users.rb +28 -0
  164. metadata +256 -0
@@ -0,0 +1,230 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #--
4
+ # Copyright 2007 by Stefan Rusterholz.
5
+ # All rights reserved.
6
+ # See LICENSE.txt for permissions.
7
+ #++
8
+
9
+
10
+
11
+ begin
12
+ require 'rubygems'
13
+ rescue LoadError => e; end
14
+ begin
15
+ require 'butler'
16
+ require 'butler/bot'
17
+ require 'butler/control'
18
+ require 'cloptions'
19
+ require 'dialogline'
20
+ require 'fileutils'
21
+ require 'installer'
22
+ require 'log/entry'
23
+ require 'log/filereader'
24
+ require 'ostructfixed'
25
+ require 'rbconfig'
26
+ require 'time'
27
+ require 'yaml'
28
+
29
+ require 'pp' # FIXME
30
+ rescue LoadError => e
31
+ puts "\e[31m\e[43mWarning, can't run botcontrol\e[0m\nYour installation is incomplete. Your ruby"+
32
+ "installation is missing the file #{e.message.sub(/.*? -- /, '')}."
33
+ puts "Backtrace:", *e.backtrace
34
+ exit
35
+ end
36
+
37
+ begin
38
+ botcontrol = Butler::Control.new
39
+ rescue Errno::EACCES
40
+ puts "Can't create initial configuration, you should run #{$0} with sudo."
41
+ exit
42
+ end
43
+ begin
44
+ botcontrol.configure_user unless botcontrol.configured?
45
+ rescue Errno::EACCES
46
+ puts "Can't configure for '#{botcontrol.user}', you should run #{$0} with sudo."
47
+ exit
48
+ end
49
+ Butler.path = botcontrol.butler_path
50
+
51
+
52
+ options = {}
53
+ options["backup"] = CLOptions.new("[botname] [backupname] [directory]")
54
+ options["config"] = CLOptions.new("[botname]")
55
+ options["create"] = CLOptions.new("[botname]")
56
+ options["delete"] = CLOptions.new("[botname]")
57
+ options["help"] = CLOptions.new("[command]")
58
+ options["info"] = CLOptions.new("[user]")
59
+ options["log"] = CLOptions.new("[botname]") {
60
+ o '-e', '--end-date', 'END_DATE', :end_date, "List only entries before END_DATE"
61
+ o '-f', '--find', 'TEXT', :find, "List only entries that contain TEXT"
62
+ o '-F', '--no-find', 'TEXT', :no_find, "List only entries that don't contain TEXT"
63
+ o '-g', '--grep', 'PATTERN', :grep, "List only entries that match PATTERN"
64
+ o '-G', '--no-grep', 'PATTERN', :no_grep, "List only entries that don't match PATTERN"
65
+ o '-H', '--head', 'COUNT', :head, "List the first COUNT entries"
66
+ o '-h', '--help', nil, :help, "Display this help"
67
+ o '-l', '--level', 'LEVEL, ...', :level, "List only entries of LEVEL"
68
+ o '-L', '--not-level', 'LEVEL, ...', :no_level, "List only entries not of LEVEL"
69
+ # o '-o', '--out', 'FORMAT', :format, "Print entries using FORMAT"
70
+ # o '-p', '--page', 'NUMBER', :page, "Show NUMBER entries per page"
71
+ o '-s', '--start-date', 'START_DATE', :start_date, "List only entries after START_DATE"
72
+ o '-T', '--tail', 'COUNT', :tail, "List the last COUNT entries"
73
+ }
74
+ options["list"] = CLOptions.new("[user]")
75
+ options["rename"] = CLOptions.new("[botname] [newname]")
76
+ options["start"] = CLOptions.new("[botname]") {
77
+ o '-c', '--channels', 'CHANNEL, ...', :channels, "Join CHANNELS instead of configured"
78
+ o '-h', '--help', "Display this help"
79
+ o '-i', '--interactive', "Don't deamonize, lets the bot run interactively in shell."
80
+ o '-n', '--nick', 'NICK', :nick, "Use NICK instead of configured"
81
+ o '-p', '--port', 'PORT', :port, "Connect at PORT instead of configured"
82
+ o '-r', '--remote', 'PORT', :remote_port, "Start remote control server and bind to PORT"
83
+ o '-s', '--server', 'SERVER', :server, "Connect to SERVER instead of the configured."
84
+ o '-w', '--warnings', "Will enable warnings on stderr."
85
+ }
86
+ options["stop"] = CLOptions.new("[botname]")
87
+ options["sync_plugins"] = CLOptions.new("[botname] [user]")
88
+ options.each { |name, opt| opt.application_name "#{File.basename($0)} #{name}" }
89
+
90
+
91
+ if %w(-v --version).include?(ARGV[0]) then
92
+ puts Butler::VERSION::STRING
93
+ elsif ARGV[0] then
94
+ command = ARGV.shift.downcase
95
+ opt = options[command].parse if options[command]
96
+ case command
97
+ when "backup"
98
+ botcontrol.discuss("backup", false,
99
+ :bot => opt.argv.botname,
100
+ :name => opt.argv.backupname,
101
+ :dir => opt.argv.directory,
102
+ :default_name => opt.argv.botname ? "#{opt.argv.botname}.bak" : nil,
103
+ :default_dir => user_config.backups
104
+ )
105
+
106
+ when "config"
107
+ botcontrol.discuss("config", false,
108
+ :botname => opt.argv.botname
109
+ )
110
+
111
+ when "create"
112
+ botcontrol.discuss("create", false, :name => opt.argv.botname)
113
+
114
+ when "delete"
115
+ botcontrol.discuss("delete", false, :name => opt.argv.botname)
116
+
117
+ when "help"
118
+ botcontrol.discuss("help", false,
119
+ :command => opt.argv.command,
120
+ :options => options
121
+ )
122
+
123
+ when "info"
124
+ botcontrol.discuss("info", false, :user => opt.argv.user)
125
+
126
+ when "log"
127
+ if opt[:help] then
128
+ puts opt.options.help
129
+ exit
130
+ end
131
+
132
+ botname = opt.argv.botname
133
+ p filename = Butler::Bot.new(nil, botname).path.log+'/error.log'
134
+ logfile = Log::FileReader.new(filename)
135
+ filters = []
136
+
137
+ if opt[:grep] then
138
+ regexp = Regexp.new(opt[:grep])
139
+ filters << "matching #{regexp.inspect}"
140
+ logfile.add_filter(:grep, regexp)
141
+ end
142
+ if opt[:no_grep] then
143
+ regexp = Regexp.new(opt[:no_grep])
144
+ filters << "not matching #{regexp.inspect}"
145
+ logfile.add_filter(:no_grep, regexp)
146
+ end
147
+ if opt[:find] then
148
+ filters << "containing #{opt[:find].inspect}"
149
+ logfile.add_filter(:find, opt[:find])
150
+ end
151
+ if opt[:no_find] then
152
+ filters << "not containing #{opt[:no_find].inspect}"
153
+ logfile.add_filter(:no_find, opt[:no_find])
154
+ end
155
+ if opt[:start_date] then
156
+ start_date = Time.parse(opt[:start_date])
157
+ filters << "after #{start_date.strftime('%F %T')}"
158
+ logfile.add_filter(:start_date, start_date)
159
+ end
160
+ if opt[:end_date] then
161
+ end_date = Time.parse(opt[:end_date])
162
+ filters << "before #{end_date.strftime('%F %T')}"
163
+ logfile.add_filter(:end_date, end_date)
164
+ end
165
+ if opt[:level] then
166
+ level = opt[:level]
167
+ filters << "of level #{level[0..-2].join(', ')}#{' or ' if level.size > 1}#{level.last}"
168
+ logfile.add_filter(:one_of_levels, level.map { |l| l.to_sym })
169
+ end
170
+ if opt[:no_level] then
171
+ level = opt[:no_level]
172
+ filters << "not of level #{level[0..-2].join(', ')}#{' or ' if level.size > 1}#{level.last}"
173
+ logfile.add_filter(:none_of_levels, level.map { |l| l.to_sym })
174
+ end
175
+
176
+ abbrname = filename.count('/') > 3 ? '...'+filename[%r{(?:/[^/]+){3}$}] : filename
177
+ if opt[:head] then
178
+ print "First #{opt[:head]} entries in #{abbrname} "
179
+ elsif opt[:tail] then
180
+ print "Last #{opt[:tail]} entries in #{abbrname} "
181
+ else
182
+ print "Entries in #{filename} "
183
+ end
184
+
185
+ puts("#{filters[0..-2].join(', ')}#{' and ' if filters.size > 1}#{filters.last}")
186
+ if opt[:head] then
187
+ logfile.head(Integer(opt[:head])) { |entry| puts entry }
188
+ elsif opt[:tail] then
189
+ logfile.tail(Integer(opt[:tail])) { |entry| puts entry }
190
+ else
191
+ logfile.each { |entry| puts entry }
192
+ end
193
+
194
+ when "list"
195
+ botcontrol.discuss("list", false, :user => opt.argv.user)
196
+
197
+ when "rename"
198
+ botcontrol.discuss("rename", false,
199
+ :botname => opt.argv.botname,
200
+ :newname => opt.argv.newname
201
+ )
202
+
203
+ when "setup"
204
+ # prompt to delete old config and create a new one
205
+
206
+ when "start"
207
+ botname = botcontrol.discuss(:start, false, :botname => opt.argv.botname)[:botname]
208
+ options = {:daemonize => !opt["-i"]}
209
+ Butler.start(nil, botname, options)
210
+
211
+ when "stop"
212
+ botname = opt.argv.botname || botcontrol.discuss(:selectbot, false)[:botname]
213
+ Butler.stop(nil, botname)
214
+
215
+ when "sync_plugins"
216
+ botcontrol.discuss("sync_plugins", false,
217
+ :user => opt.argv.user,
218
+ :path => botcontrol.user_config(opt.argv.user),
219
+ :botname => opt.argv.botname
220
+ )
221
+
222
+ when "uninstall"
223
+ botcontrol.discuss("uninstall", false, :path => path, :config => config)
224
+
225
+ else
226
+ botcontrol.discuss("unknown_command", false, :command => command)
227
+ end
228
+ else
229
+ botcontrol.discuss("interactive")
230
+ end
@@ -0,0 +1,4 @@
1
+ ---
2
+ :language: en
3
+ :users: {}
4
+ :revision: 1
@@ -0,0 +1,19 @@
1
+ store(:bot, variables.bot)
2
+ store(:name, variables.name)
3
+ store(:dir, variables.dir)
4
+ success = false
5
+ until success
6
+ response(:option, :bot, Butler.list) unless variables.bot
7
+ response(:ask, :name, variables.default_name || "#{result[:bot]}.bak") unless variables.name
8
+ response(:ask, :dir, variables.default_dir) unless variables.dir
9
+
10
+ begin
11
+ Butler.backup(result[:bot], result[:name], result[:dir])
12
+ rescue => e
13
+ p e
14
+ success = !prompt(:failure)
15
+ else
16
+ say(:success)
17
+ success = true
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ say(:configuring, :name => variables.user)
2
+ response(:option, :config, variables.installer.user_config_suggestions)
3
+ response(:option, :bots, variables.installer.user_data_suggestions.map { |sug| sug+"/bots" })
4
+ response(:option, :run, variables.installer.user_pid_suggestions)
@@ -0,0 +1 @@
1
+ response(:context, "notyetimplemented", :feature => "Configure")
@@ -0,0 +1,53 @@
1
+ exit if ENV["SUDO_USER"] && !prompt(:sudo_user, false)
2
+ name = variables.name
3
+ while Butler.exists?(nil, name)
4
+ if prompt(:delete_existing, false)
5
+ Butler.delete(nil, name)
6
+ else
7
+ name = ask(:name, "butler", String, :matching => /\A[A-Za-z0-9_]+\z/)
8
+ end
9
+ end
10
+ Butler.create(nil, name)
11
+ bot = Butler.new(nil, name)
12
+
13
+ #if prompt(:quicksetup, true) then
14
+ bot.config["connections.main.server"] = server=ask(:server, "irc.freenode.org", String, :min => 3)
15
+ bot.config["connections.main.port"] = 6667
16
+ bot.config["connections.main.host"] = nil
17
+ bot.config["connections.main.reconnect_delay"] = 60
18
+ bot.config["connections.main.reconnect_tries"] = -1
19
+ bot.config["connections.main.charset"] = 'utf-8'
20
+ bot.config["connections.main.language"] = lang=ask(:language, "en", String, :matching => /\A#[A-Za-z0-9_-]{2,40}\z/)
21
+ bot.config["connections.main.nick"] = name
22
+ bot.config["connections.main.alternative"] = name[0,7]+"_"
23
+ bot.config["connections.main.user"] = name
24
+ bot.config["connections.main.real"] = name+" (Butler IRC bot)"
25
+ bot.config["connections.main.password"] = ask(:nickpass, nil, String)
26
+ bot.config["connections.main.identify"] = :auto
27
+ bot.config["connections.main.channels"] = channels=ask(:channels, (server == "irc.freenode.org" ? ["#butler"] : nil), Array, String, :matching => /\A#[^\0\s,]+\z/)
28
+ channels.each { |channel|
29
+ prefix = "channels.#{server.config_key}.#{channel.config_key}"
30
+ bot.config["#{prefix}.password"] = nil
31
+ bot.config["#{prefix}.language"] = lang
32
+ bot.config["#{prefix}.charset"] = 'utf-8'
33
+ }
34
+ user = ask(:user, nil, String, :min => 3)
35
+ pass = ask(:pass, nil, String, :min => 3)
36
+ bot.access.user.create(user, pass, nil, true, :active => true)
37
+ user = bot.access.user.create("default_user", nil, nil, false, :active => true)
38
+ user.privileges.add(%w[plugin/public])
39
+
40
+
41
+ #else
42
+ # "irc.server", ask(:server, "irc.freenode.org", String, :min => 3))
43
+ # "irc.port", ask(:port, 6667, Integer, :between => [0, 65535]))
44
+ # "login.nick", ask(:nick, name, String, :matching => /\A#[A-Za-z0-9_-]{2,40}\z/))
45
+ # "login.user", ask(:user, name, String, :matching => /\A#[A-Za-z0-9_-]{2,40}\z/))
46
+ # "login.real", ask(:real, "#{name} (Butler IRC bot)", String, :matching => /\A#[A-Za-z0-9_-]{2,40}\z/))
47
+ # "language", ask(:language, "en", String, :matching => /\A#[A-Za-z0-9_-]{2,40}\z/))
48
+ # Butler.configure(name, "login.channels", ask(:channels, nil, Array, String, :matching => /\A#[^\0\s,]+\z/))
49
+ #end
50
+ puts
51
+ say(:how_to_start)
52
+
53
+ #Object#methods has an undocumented parameter
@@ -0,0 +1,3 @@
1
+ name = variables.name || ask(:name, "butler", String, :matching => /\A[A-Za-z0-9_]+\z/)
2
+ Butler.delete(nil, name)
3
+ say(:deleted, :name => name)
@@ -0,0 +1,6 @@
1
+ ---
2
+ :bot: "Please select the bot to backup"
3
+ :name: "Name of the backup"
4
+ :dir: "Write the backup to directory"
5
+ :success: "Backup created."
6
+ :failure: "Failed to create a backup."
@@ -0,0 +1,5 @@
1
+ ---
2
+ :configuring: "Setting up configuration for <%= name %>."
3
+ :config: "Please choose where config is stored"
4
+ :bots: "Please choose where bots are stored"
5
+ :run: "Please choose where to put pid-files"
@@ -0,0 +1,11 @@
1
+ ---
2
+ :name: "Please choose a name for the bot (alphanumeric characters only)"
3
+ :delete_existing: "A bot named <%= name %> already exists, do you wish to delete it"
4
+ :quicksetup: "Do you wish to do a quick configuration (you can use '<%= $0 %> config <%= name %>' any time)"
5
+ :server: "Servername to connect to"
6
+ :language: "The main language"
7
+ :channels: "Comma separated list of channels to join on login"
8
+ :user: "Please choose a username for the bot-admin"
9
+ :pass: "The password for the bot-admin"
10
+ :nickpass: "The password for the nick (empty if not registered)"
11
+ :how_to_start: "You can now start your bot using '<%= $0 %> start <%= name %>'"
@@ -0,0 +1,2 @@
1
+ ---
2
+ :deleted: "Deleted '<%= name %>'."
@@ -0,0 +1,17 @@
1
+ ---
2
+ :help: |-
3
+ This is the tool to administrate your irc-bots.
4
+ The the following commands are available:
5
+ -create: create a new bot
6
+ -start: start an existing bot
7
+ -stop: stop a running bot
8
+ -rename: rename an existing bot
9
+ -config: configure an existing bot
10
+ -delete: delete an existing bot
11
+ -list: list all existing bots
12
+ -backup: make a backup of an existing bot
13
+ -help: you're looking at it"
14
+ :tutorial: The tutorial is on http://butler.rubyforge.org/tutorial
15
+ :plugins: You can download plugins from http://rubyforge.org/frs/?group_id=1349
16
+ :manual: The manual is on http://butler.rubyforge.org/manual
17
+ :home: Butlers home is on http://butler.rubyforge.org/
@@ -0,0 +1,13 @@
1
+ ---
2
+ :no_such_user: "There is no user named <%= name %> registered."
3
+ :paths: |
4
+ Version: <%= Butler::VERSION::STRING %>
5
+ Botcontrol: <%= botcontrol %>
6
+ Configuration: <%= config_path %>
7
+ :users_heading: "Users:"
8
+ :user: |
9
+ <%= name %>:
10
+ bots: <%= bots %>
11
+ pidfiles: <%= run %>
12
+ config: <%= config %>
13
+ language: <%= language %>
@@ -0,0 +1,4 @@
1
+ ---
2
+ :nobots: "No bots available."
3
+ :bots: "Available bots (<%= bot_count %>):"
4
+ :abot: " -<%= bot %>"
@@ -0,0 +1,2 @@
1
+ ---
2
+ :notyetimplemented: "<%= feature %> is not yet implemented."
@@ -0,0 +1,3 @@
1
+ ---
2
+ :new_name: "The new name of the bot"
3
+ :renamed: "Renamed '<%= old_name %>' to '<%= new_name %>'."
@@ -0,0 +1,3 @@
1
+ ---
2
+ :discourage: "Running butler as root is STRONGLY discouraged.\nButler will start in 10s."
3
+ :starting: "Starting <%= name %>"
@@ -0,0 +1,3 @@
1
+ ---
2
+ :updating: "Updating plugins for '<%= name %>'"
3
+ :override_newer: "Override newer plugin <%= name %> (Yours <%= a.strftime('%F %T') %>, Copying <%= b.strftime('%F %T') %>"
@@ -0,0 +1,5 @@
1
+ ---
2
+ :uninstalling_botcontrol: "Uninstalling botcontrol..."
3
+ :uninstall_user: "Do you want to delete <%= name %>'s bots and settings?"
4
+ :must_run_as_sudo: "You must run this with sudo."
5
+ :run_gem_uninstall: "Run now 'sudo gem uninstall butler' to uninstall all remaining bits."
@@ -0,0 +1,2 @@
1
+ ---
2
+ :unknown: "Unknown command '<%= command %>'."
@@ -0,0 +1,11 @@
1
+ if variables.command then
2
+ case variables.command
3
+ when "tutorial": say(:tutorial)
4
+ when "documentation": say(:documentation)
5
+ when "plugins": say(:plugins)
6
+ else
7
+ variables.options[variables.command].help
8
+ end
9
+ else
10
+ say(:help)
11
+ end
@@ -0,0 +1,27 @@
1
+ if variables.user && botcontrol.configured?(variables.user) then
2
+ user_config = botcontrol.user_config(variables.user)
3
+ say(:user,
4
+ :name => variables.user,
5
+ :bots => user_config[:bots],
6
+ :run => user_config[:run],
7
+ :language => user_config[:language]
8
+ )
9
+ elsif variables.user
10
+ say(:no_such_user, :name => variables.user)
11
+ else
12
+ say(:paths,
13
+ :botcontrol => File.expand_path($0),
14
+ :config_path => variables.botcontrol.path[:config]
15
+ )
16
+ say(:users_heading)
17
+ variables.botcontrol.config[:users].sort.each { |user, conf|
18
+ user_config = variables.botcontrol.user_config(user)
19
+ say(:user,
20
+ :name => user,
21
+ :bots => user_config[:bots],
22
+ :run => user_config[:run],
23
+ :config => conf,
24
+ :language => user_config[:language]
25
+ )
26
+ }
27
+ end