butler 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +4 -0
- data/GPL.txt +340 -0
- data/LICENSE.txt +52 -0
- data/README +37 -0
- data/Rakefile +334 -0
- data/bin/botcontrol +230 -0
- data/data/butler/config_template.yaml +4 -0
- data/data/butler/dialogs/backup.rb +19 -0
- data/data/butler/dialogs/botcontrol.rb +4 -0
- data/data/butler/dialogs/config.rb +1 -0
- data/data/butler/dialogs/create.rb +53 -0
- data/data/butler/dialogs/delete.rb +3 -0
- data/data/butler/dialogs/en/backup.yaml +6 -0
- data/data/butler/dialogs/en/botcontrol.yaml +5 -0
- data/data/butler/dialogs/en/create.yaml +11 -0
- data/data/butler/dialogs/en/delete.yaml +2 -0
- data/data/butler/dialogs/en/help.yaml +17 -0
- data/data/butler/dialogs/en/info.yaml +13 -0
- data/data/butler/dialogs/en/list.yaml +4 -0
- data/data/butler/dialogs/en/notyetimplemented.yaml +2 -0
- data/data/butler/dialogs/en/rename.yaml +3 -0
- data/data/butler/dialogs/en/start.yaml +3 -0
- data/data/butler/dialogs/en/sync_plugins.yaml +3 -0
- data/data/butler/dialogs/en/uninstall.yaml +5 -0
- data/data/butler/dialogs/en/unknown_command.yaml +2 -0
- data/data/butler/dialogs/help.rb +11 -0
- data/data/butler/dialogs/info.rb +27 -0
- data/data/butler/dialogs/interactive.rb +1 -0
- data/data/butler/dialogs/list.rb +10 -0
- data/data/butler/dialogs/notyetimplemented.rb +1 -0
- data/data/butler/dialogs/rename.rb +4 -0
- data/data/butler/dialogs/selectbot.rb +2 -0
- data/data/butler/dialogs/start.rb +5 -0
- data/data/butler/dialogs/sync_plugins.rb +30 -0
- data/data/butler/dialogs/uninstall.rb +17 -0
- data/data/butler/dialogs/unknown_command.rb +1 -0
- data/data/butler/plugins/core/logout.rb +41 -0
- data/data/butler/plugins/core/plugins.rb +134 -0
- data/data/butler/plugins/core/privilege.rb +103 -0
- data/data/butler/plugins/core/user.rb +166 -0
- data/data/butler/plugins/dev/eval.rb +64 -0
- data/data/butler/plugins/dev/nometa.rb +14 -0
- data/data/butler/plugins/dev/onhandlers.rb +93 -0
- data/data/butler/plugins/dev/raw.rb +36 -0
- data/data/butler/plugins/dev/rawlog.rb +77 -0
- data/data/butler/plugins/games/eightball.rb +54 -0
- data/data/butler/plugins/games/mastermind.rb +174 -0
- data/data/butler/plugins/irc/action.rb +36 -0
- data/data/butler/plugins/irc/join.rb +38 -0
- data/data/butler/plugins/irc/notice.rb +36 -0
- data/data/butler/plugins/irc/part.rb +38 -0
- data/data/butler/plugins/irc/privmsg.rb +36 -0
- data/data/butler/plugins/irc/quit.rb +36 -0
- data/data/butler/plugins/operator/deop.rb +41 -0
- data/data/butler/plugins/operator/devoice.rb +41 -0
- data/data/butler/plugins/operator/limit.rb +47 -0
- data/data/butler/plugins/operator/op.rb +41 -0
- data/data/butler/plugins/operator/voice.rb +41 -0
- data/data/butler/plugins/public/help.rb +69 -0
- data/data/butler/plugins/public/login.rb +72 -0
- data/data/butler/plugins/public/usage.rb +49 -0
- data/data/butler/plugins/service/clones.rb +56 -0
- data/data/butler/plugins/service/define.rb +47 -0
- data/data/butler/plugins/service/log.rb +183 -0
- data/data/butler/plugins/service/svn.rb +91 -0
- data/data/butler/plugins/util/cycle.rb +98 -0
- data/data/butler/plugins/util/load.rb +41 -0
- data/data/butler/plugins/util/pong.rb +29 -0
- data/data/butler/strings/random/acknowledge.en.yaml +5 -0
- data/data/butler/strings/random/gratitude.en.yaml +3 -0
- data/data/butler/strings/random/hello.en.yaml +4 -0
- data/data/butler/strings/random/ignorance.en.yaml +7 -0
- data/data/butler/strings/random/ignorance_about.en.yaml +3 -0
- data/data/butler/strings/random/insult.en.yaml +3 -0
- data/data/butler/strings/random/rejection.en.yaml +12 -0
- data/data/man/botcontrol.1 +17 -0
- data/lib/access.rb +187 -0
- data/lib/access/admin.rb +16 -0
- data/lib/access/privilege.rb +122 -0
- data/lib/access/role.rb +102 -0
- data/lib/access/savable.rb +18 -0
- data/lib/access/user.rb +180 -0
- data/lib/access/yamlbase.rb +126 -0
- data/lib/butler.rb +188 -0
- data/lib/butler/bot.rb +247 -0
- data/lib/butler/control.rb +93 -0
- data/lib/butler/dialog.rb +64 -0
- data/lib/butler/initialvalues.rb +40 -0
- data/lib/butler/irc/channel.rb +135 -0
- data/lib/butler/irc/channels.rb +96 -0
- data/lib/butler/irc/client.rb +351 -0
- data/lib/butler/irc/hostmask.rb +53 -0
- data/lib/butler/irc/message.rb +184 -0
- data/lib/butler/irc/parser.rb +125 -0
- data/lib/butler/irc/parser/commands.rb +83 -0
- data/lib/butler/irc/parser/generic.rb +343 -0
- data/lib/butler/irc/socket.rb +378 -0
- data/lib/butler/irc/string.rb +186 -0
- data/lib/butler/irc/topic.rb +15 -0
- data/lib/butler/irc/user.rb +265 -0
- data/lib/butler/irc/users.rb +112 -0
- data/lib/butler/plugin.rb +249 -0
- data/lib/butler/plugin/configproxy.rb +35 -0
- data/lib/butler/plugin/mapper.rb +85 -0
- data/lib/butler/plugin/matcher.rb +55 -0
- data/lib/butler/plugin/onhandlers.rb +70 -0
- data/lib/butler/plugin/trigger.rb +58 -0
- data/lib/butler/plugins.rb +147 -0
- data/lib/butler/version.rb +17 -0
- data/lib/cloptions.rb +217 -0
- data/lib/cloptions/adapters.rb +24 -0
- data/lib/cloptions/switch.rb +132 -0
- data/lib/configuration.rb +223 -0
- data/lib/dialogline.rb +296 -0
- data/lib/dialogline/localizations.rb +24 -0
- data/lib/durations.rb +57 -0
- data/lib/event.rb +295 -0
- data/lib/event/at.rb +64 -0
- data/lib/event/every.rb +56 -0
- data/lib/event/timed.rb +112 -0
- data/lib/installer.rb +75 -0
- data/lib/iterator.rb +34 -0
- data/lib/log.rb +68 -0
- data/lib/log/comfort.rb +85 -0
- data/lib/log/converter.rb +23 -0
- data/lib/log/entry.rb +152 -0
- data/lib/log/fakeio.rb +55 -0
- data/lib/log/file.rb +54 -0
- data/lib/log/filereader.rb +81 -0
- data/lib/log/forward.rb +49 -0
- data/lib/log/methods.rb +39 -0
- data/lib/log/nolog.rb +18 -0
- data/lib/log/splitter.rb +26 -0
- data/lib/ostructfixed.rb +26 -0
- data/lib/ruby/array/columnize.rb +38 -0
- data/lib/ruby/dir/mktree.rb +28 -0
- data/lib/ruby/enumerable/join.rb +13 -0
- data/lib/ruby/exception/detailed.rb +24 -0
- data/lib/ruby/file/append.rb +11 -0
- data/lib/ruby/file/write.rb +11 -0
- data/lib/ruby/hash/zip.rb +15 -0
- data/lib/ruby/kernel/bench.rb +15 -0
- data/lib/ruby/kernel/daemonize.rb +42 -0
- data/lib/ruby/kernel/non_verbose.rb +17 -0
- data/lib/ruby/kernel/safe_fork.rb +18 -0
- data/lib/ruby/range/stepped.rb +11 -0
- data/lib/ruby/string/arguments.rb +72 -0
- data/lib/ruby/string/chunks.rb +15 -0
- data/lib/ruby/string/post_arguments.rb +44 -0
- data/lib/ruby/string/unescaped.rb +17 -0
- data/lib/scheduler.rb +164 -0
- data/lib/scriptfile.rb +101 -0
- data/lib/templater.rb +86 -0
- data/test/cloptions.rb +134 -0
- data/test/cv.rb +28 -0
- data/test/irc/client.rb +85 -0
- data/test/irc/client_login.txt +53 -0
- data/test/irc/client_subscribe.txt +8 -0
- data/test/irc/message.rb +30 -0
- data/test/irc/messages.txt +64 -0
- data/test/irc/parser.rb +13 -0
- data/test/irc/profile_parser.rb +12 -0
- data/test/irc/users.rb +28 -0
- metadata +256 -0
data/bin/botcontrol
ADDED
|
@@ -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,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,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,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,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,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
|