butler 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/CHANGELOG.txt +212 -0
  2. data/{README → README.txt} +0 -0
  3. data/Rakefile +16 -11
  4. data/bin/botcontrol +35 -14
  5. data/data/butler/dialogs/create.rb +29 -40
  6. data/data/butler/dialogs/create_config.rb +1 -1
  7. data/data/butler/dialogs/dir.rb +13 -0
  8. data/data/butler/dialogs/en/create.yaml +24 -10
  9. data/data/butler/dialogs/en/dir.yaml +5 -0
  10. data/data/butler/dialogs/en/help.yaml +28 -11
  11. data/data/butler/dialogs/en/quickcreate.yaml +14 -0
  12. data/data/butler/dialogs/help.rb +16 -4
  13. data/data/butler/dialogs/quickcreate.rb +49 -0
  14. data/data/butler/plugins/core/access.rb +211 -0
  15. data/data/butler/plugins/core/logout.rb +11 -11
  16. data/data/butler/plugins/core/plugins.rb +23 -41
  17. data/data/butler/plugins/dev/bleakhouse.rb +46 -0
  18. data/data/butler/plugins/games/roll.rb +1 -1
  19. data/data/butler/plugins/operator/deop.rb +15 -20
  20. data/data/butler/plugins/operator/devoice.rb +14 -20
  21. data/data/butler/plugins/operator/limit.rb +56 -21
  22. data/data/butler/plugins/operator/op.rb +15 -20
  23. data/data/butler/plugins/operator/voice.rb +15 -20
  24. data/data/butler/plugins/service/define.rb +3 -3
  25. data/data/butler/plugins/service/more.rb +40 -0
  26. data/data/butler/plugins/util/cycle.rb +1 -1
  27. data/data/butler/plugins/util/load.rb +5 -5
  28. data/data/butler/plugins/util/pong.rb +3 -2
  29. data/lib/access/privilege.rb +17 -0
  30. data/lib/access/role.rb +33 -2
  31. data/lib/access/savable.rb +6 -0
  32. data/lib/access/yamlbase.rb +1 -2
  33. data/lib/butler/bot.rb +40 -7
  34. data/lib/butler/debuglog.rb +17 -0
  35. data/lib/butler/dialog.rb +1 -1
  36. data/lib/butler/irc/{channels.rb → channellist.rb} +2 -2
  37. data/lib/butler/irc/client.rb +60 -79
  38. data/lib/butler/irc/client/filter.rb +12 -0
  39. data/lib/butler/irc/client/listener.rb +55 -0
  40. data/lib/butler/irc/client/listenerlist.rb +69 -0
  41. data/lib/butler/irc/hostmask.rb +31 -16
  42. data/lib/butler/irc/message.rb +3 -3
  43. data/lib/butler/irc/parser.rb +2 -2
  44. data/lib/butler/irc/parser/rfc2812.rb +2 -6
  45. data/lib/butler/irc/socket.rb +12 -6
  46. data/lib/butler/irc/string.rb +4 -0
  47. data/lib/butler/irc/user.rb +0 -6
  48. data/lib/butler/irc/{users.rb → userlist.rb} +2 -2
  49. data/lib/butler/irc/whois.rb +6 -0
  50. data/lib/butler/plugin.rb +48 -14
  51. data/lib/butler/plugin/configproxy.rb +20 -0
  52. data/lib/butler/plugin/mapper.rb +308 -24
  53. data/lib/butler/plugin/matcher.rb +3 -1
  54. data/lib/butler/plugin/more.rb +65 -0
  55. data/lib/butler/plugin/onhandlers.rb +4 -4
  56. data/lib/butler/plugin/trigger.rb +4 -2
  57. data/lib/butler/plugins.rb +1 -1
  58. data/lib/butler/session.rb +11 -0
  59. data/lib/butler/version.rb +1 -1
  60. data/lib/cloptions.rb +1 -1
  61. data/lib/diagnostics.rb +20 -0
  62. data/lib/dialogline.rb +1 -1
  63. data/lib/durations.rb +19 -6
  64. data/lib/event.rb +8 -5
  65. data/lib/installer.rb +10 -3
  66. data/lib/ostructfixed.rb +11 -0
  67. data/lib/ruby/kernel/daemonize.rb +1 -2
  68. data/test/butler/plugin/mapper.rb +46 -0
  69. metadata +28 -11
  70. data/CHANGELOG +0 -44
  71. data/data/butler/plugins/core/privilege.rb +0 -103
@@ -0,0 +1,212 @@
1
+ = Butler2
2
+
3
+ === 28th Nov, 2007
4
+ * Butler 1.8.2 (rev #436)
5
+ * bin/botcontrol:
6
+ * Added quickcreate
7
+ * Added 'dir' command
8
+ * Added -v/--verbose flag for start
9
+ * Added -d/--debug flag for start, sets $DEBUG
10
+ * Added fixes for bleakhouse support and problems with outdated ruby versions (fastthread)
11
+ * Fixed a message
12
+ * Fixed calling botcontrol without arguments
13
+ * Fixed wrong CLOptions declaration
14
+ * Removed -/--help flags in favor of the help command
15
+ * data/butler/dialogs:
16
+ * Added quickcreate
17
+ * Quickcreate now creates default_role
18
+ * Create is now thorough
19
+ * Added dialogs for 'dir' command
20
+ * Updated help
21
+ * data/butler/plugins:
22
+ * core/access.rb:
23
+ * Added, management of your users and privileges
24
+ * core/logout.rb:
25
+ * Refactored
26
+ * core/plugins.rb:
27
+ * Improved
28
+ * dev/bleakhouse.rb:
29
+ * Added
30
+ * games/roll.rb:
31
+ * Fixed rolling dice (dice had 0-(n-1) eyes instead of 1-n)
32
+ * operator/limit.rb:
33
+ * Now functional
34
+ * operator/*:
35
+ * Overhauled, using maps now
36
+ * service/define.rb:
37
+ * Uses 'more' now
38
+ * Small fix
39
+ * Adapted to new html of googles result page
40
+ * service/more.rb:
41
+ * Added, to provide access to "more" data in user sessions
42
+ * util/cycle.rb:
43
+ * Fixed a bug introduced by a newly added parameter to the on_part OnHandler
44
+ * util/load.rb:
45
+ * Uses metadata instead of trigger method
46
+ * Fixed a bug with OS X (used , instead of . for %CPU float)
47
+ * Changed output
48
+ * util/pong.rb:
49
+ * Uses metadata instead of trigger method
50
+ * lib:
51
+ * access/privilege.rb:
52
+ * Added #inspect to Privilege and Privileges
53
+ * access/roles.rb:
54
+ * Added #inspect to Role and Roles
55
+ * Added #description=, #description, #privileges and #roles to Role
56
+ * access/savable.rb:
57
+ * Added Savable#delete
58
+ * access/yamlbase.rb:
59
+ * Small fixes
60
+ * butler/bot.rb:
61
+ * Added debug/raw-logging of socket ops (read/write)
62
+ * Added #session to Butler::IRC::User
63
+ * Added a timeout for the on_quit event messages to plugins
64
+ * Added load path <bot>/lib
65
+ * Sends now on_login, on_disconnect and on_quit events
66
+ * Refactored for change from Users/Channels to UserList/ChannelList
67
+ * butler/debuglog.rb:
68
+ * Added
69
+ * butler/irc/client.rb:
70
+ * Improved documentation
71
+ * Fixed on_disconnect
72
+ * Fixed initialize (no longer ignores on_disconnect block)
73
+ * butler/irc/socket.rb:
74
+ * Better diagnostics when trying to write to an unconnected socket
75
+ * butler/irc/hostmask.rb:
76
+ * Fixed dummy state (is now functional)
77
+ * Improved documentation
78
+ * butler/irc/hostmask.rb:
79
+ * Added comment
80
+ * butler/irc/client.rb:
81
+ * Added license info
82
+ * Refactored Listeners
83
+ * butler/irc/client*:
84
+ * Moved from client.rb to own files, added ListenerList
85
+ * butler/irc/message.rb:
86
+ * Fixed documentation
87
+ * butler/irc/parser/rfc2812.rb:
88
+ * Fixed FIXMEs
89
+ * butler/irc/parser.rb:
90
+ * Refactored for change from Users/Channels to UserList/ChannelList
91
+ * butler/irc/socket.rb:
92
+ * Added #mode
93
+ * Deleted obsolete FIXME comment
94
+ * butler/irc/string.rb:
95
+ * Added String#same_nick?
96
+ * butler/irc/whois:
97
+ * Moved from client.rb to own file
98
+ * butler/plugin.rb:
99
+ * Added exceptions for invalid triggers/maps
100
+ * Fixed comments to reflect change from Users/Channels to UserList/ChannelList
101
+ * Initialize @mapping_type (avoid warning)
102
+ * #answer now uses More
103
+ * #answer_with_lead added
104
+ * Now prefixes answers with nicknames
105
+ * butler/plugin.rb:
106
+ * Added methods to intercept on_login, on_disconnect and on_quit events
107
+ * butler/plugin/configproxy.rb:
108
+ * Added #synchronize
109
+ * Improved documentation
110
+ * butler/plugin/mapper.rb:
111
+ * Complete rewrite
112
+ * butler/plugin/mapper.rb:
113
+ * Forgot to remove a debug output
114
+ * butler/plugin/mapper.rb:
115
+ * Fixed several bugs in the implementation
116
+ * butler/plugin/mapper.rb:
117
+ * Refactored
118
+ * butler/plugin/onhandlers.rb:
119
+ * Improved on_part
120
+ * Improved on_kick
121
+ * Improved on_kill
122
+ * Improved on_kline
123
+ * butler/plugin/mapper.rb:
124
+ * Included Comparable
125
+ * Added a constant for the priority
126
+ * Refactored for new priority rule (higher priority first)
127
+ * Respects that @mapping_type is already initialized
128
+ * Another set of fixes, also removed some debug outputs
129
+ * Fixed #inspect
130
+ * Fixed #<=>
131
+ * Fixed a bug in the regex generation code
132
+ * Deleted obsolete FIXME comment
133
+ * butler/plugin/matcher.rb:
134
+ * Included Comparable
135
+ * Refactored for new priority rule (higher priority first)
136
+ * butler/plugin/more.rb:
137
+ * Added
138
+ * butler/plugin/trigger.rb:
139
+ * Added a constant for the priority
140
+ * Fixed #<=>
141
+ * butler/plugins.rb:
142
+ * Plugins#identify now tests for complete filename, so 'oad' won't identify load.rb
143
+ * butler/session.rb:
144
+ * Added
145
+ * cloptions.rb:
146
+ * Fixed exception message
147
+ * diagnostics.rb:
148
+ * Added
149
+ * dialogline.rb:
150
+ * Deleted obsolete FIXME comments
151
+ * durations.rb:
152
+ * Added Kernel#second, #minute, #hour, #day, #week
153
+ * Removed Numeric#second, #minute, #hour, #day, #week
154
+ * installer.rb:
155
+ * Can now determine home paths on win using win32/etc gem
156
+ * ostructfixed.rb:
157
+ * Added OpenStruct#__hash__
158
+ * ruby/kernel/daemonize.rb:
159
+ * Removed fixmes and changed umode to 0066
160
+ * CHANGELOG, NEWS, README and TODO now all have .txt suffix
161
+ * website updated
162
+ * Renamed Butler::IRC::Channels to Butler::IRC::ChannelList
163
+ * Renamed Butler::IRC::Users to Butler::IRC::UserList
164
+ * Deleted obsolete channels.rb and users.rb (now in channellist.rb and userlist.rb)
165
+ * Rakefile
166
+ * Adapted for the new .txt suffixes
167
+ * Moved some requires that have dependencies to the tasks
168
+ * Added tests for lib/butler/plugin/mapper.rb
169
+ * core/privileges.rb replaced by the superior core/access.rb plugin
170
+
171
+ === 27th Oct, 2007
172
+ * Butler 1.8.1 (rev #328)
173
+ * botcontrol
174
+ * New flag -l (lowercased L) overrides config and connects locally.
175
+ * Setup now allows to set botcontrol up for another user
176
+ * Fixed permissions of directories created for a user
177
+ * Log now uses logger instead of log_device, changes due to that in:
178
+ * lib/butler.rb
179
+ * lib/butler/bot.rb
180
+ * lib/butler/irc/socket.rb
181
+ * lib/butler/plugin.rb
182
+ * lib/irc/client.rb
183
+ * lib/log/comfort.rb
184
+ * lib/butler/irc/client.rb:
185
+ * Adapted to new Commands requiring specification of command-sets
186
+ * Added #load_command_set
187
+ * lib/butler/irc/parser/rfc2812.rb: Added, moved rfc2812 commands to it.
188
+ * lib/butler/irc/parser/generic.rb:
189
+ * moved rfc2812 commands to rfc2812.rb
190
+ * Added 396 RPL_HIDDENHOST
191
+ * lib/butler/irc/parser/commands.rb:
192
+ * Now loads only command-sets as specified
193
+ * Added #load, to post-load command-sets
194
+ * Added logging
195
+ * Added a warning if matching of a message fails
196
+ * lib/butler/irc/user.rb: Added #force_update.
197
+ * lib/butler/irc/parser.rb:
198
+ * Fixed logging of ParseErrors (forgot to initialize_details)
199
+ * Adapted to new Commands requiring specification of command-sets
200
+ * lib/configuration.rb: Changed separator from . to / to increase consistence.
201
+ * lib/log.rb: More documentation.
202
+ * lib/log/comfort.rb: Added #log_origin
203
+ * lib/log/entry.rb: Supports origin now.
204
+ * lib/butler.rb: Fixed a bug (::start wouldn't pass on the options param)
205
+ * lib/irc/client.rb: Now uses options[:server] if available
206
+ * lib/ruby/exception/detailed.rb: Hardened against misuse.
207
+ * lib/butler/irc/client.rb: Fixed a bug (forgot to include Log::Comfort)
208
+ * Rakefile: Added :website_docs task.
209
+ * README: updated.
210
+
211
+ === 7th Oct, 2007
212
+ * Initial release of Butler2. Butler 1.8.x series is the alpha series of Butler2.
File without changes
data/Rakefile CHANGED
@@ -1,10 +1,13 @@
1
- $LOAD_PATH.unshift("lib")
1
+ $LOAD_PATH.unshift(File.expand_path("lib"))
2
2
 
3
3
  # This Rakefile makes use of some task taken from Hoe, a gem by Ryan Davis.
4
4
 
5
+ begin
6
+ require 'rubygems'
7
+ rescue LoadError
8
+ warn "No rubygems present"
9
+ end
5
10
  require 'ostructfixed'
6
- require 'rubyforge'
7
- require 'rubygems'
8
11
  require 'rbconfig'
9
12
  require 'rake'
10
13
  require 'rake/clean'
@@ -24,7 +27,7 @@ require File.join(File.dirname(__FILE__), 'lib', 'butler', 'version')
24
27
  RDOC_OPTS = [
25
28
  '--quiet',
26
29
  '--title', 'Butler library API',
27
- '--main', 'README',
30
+ '--main', 'README.txt',
28
31
  '--charset', 'utf-8',
29
32
  '--inline-source',
30
33
  '--tab-width', '2',
@@ -44,7 +47,7 @@ CLEAN.include [
44
47
  '**/.DS_Store', '**/._*',
45
48
  ]
46
49
  PKG_FILES =
47
- %w[CHANGELOG LICENSE.txt GPL.txt README Rakefile] +
50
+ %w[CHANGELOG.txt LICENSE.txt GPL.txt README.txt Rakefile] +
48
51
  %w[bin/botcontrol] +
49
52
  Dir.glob("{data,conf,lib,test}/**/*")
50
53
  LOCAL_PATHS = {}
@@ -58,8 +61,8 @@ LOCAL_PATHS['strings'] = "#{LOCAL_PATHS['data']}/strings"
58
61
  LOCAL_PATHS['plugins'] = "#{LOCAL_PATHS['data']}/plugins"
59
62
  #LOCAL_PATHS['config'] = "#{Config::CONFIG['sysconfdir']}/butler"
60
63
  LOCAL_PATHS['pids'] = "#{Config::CONFIG['localstatedir']}/run/butler"
61
- CHANGES = "See CHANGELOG"
62
- DESC = "Current alpha release of Butler"
64
+ CHANGES = "See CHANGELOG.txt"
65
+ DESC = "Butler 1.8.2, 3rd alpha release of butler2."
63
66
 
64
67
  GemSpec = Gem::Specification.new do |s|
65
68
  s.homepage = HOMEPATH
@@ -72,7 +75,7 @@ GemSpec = Gem::Specification.new do |s|
72
75
  s.platform = Gem::Platform::RUBY
73
76
  s.required_ruby_version = '>= 1.8.0'
74
77
  s.has_rdoc = true
75
- s.extra_rdoc_files = %w[README CHANGELOG GPL.txt LICENSE.txt]
78
+ s.extra_rdoc_files = %w[README.txt CHANGELOG.txt GPL.txt LICENSE.txt]
76
79
  s.summary = "Butler - the IRC bot with class"
77
80
  s.description = s.summary
78
81
  s.files = PKG_FILES
@@ -87,10 +90,10 @@ end
87
90
  RDOC = Rake::RDocTask.new do |rdoc|
88
91
  rdoc.rdoc_dir = 'doc/rdoc'
89
92
  rdoc.options += RDOC_OPTS
90
- rdoc.main = "README"
93
+ rdoc.main = "README.txt"
91
94
  rdoc.rdoc_files.add [
92
- 'README',
93
- 'CHANGELOG',
95
+ 'README.txt',
96
+ 'CHANGELOG.txt',
94
97
  'GPL.txt',
95
98
  'LICENSE.txt',
96
99
  'lib/**/*.rb'
@@ -242,6 +245,8 @@ task :website => [:website_generate, :website_upload] # , :publish_docs
242
245
 
243
246
  desc 'Package and upload the release to rubyforge.'
244
247
  task :release => [:clean, :package] do |t|
248
+ require 'rubyforge'
249
+
245
250
  pkg = "pkg/#{GEM_NAME}-#{VERS}"
246
251
 
247
252
  #if $DEBUG then
@@ -9,7 +9,10 @@
9
9
 
10
10
 
11
11
  begin
12
- require 'rubygems'
12
+ require 'rubygems' # if rubygems is installed, you most likely want it be used
13
+ rescue LoadError => e; end
14
+ begin
15
+ require 'fastthread' # fixes potential bugs
13
16
  rescue LoadError => e; end
14
17
  begin
15
18
  require 'butler'
@@ -26,10 +29,12 @@ begin
26
29
  require 'time'
27
30
  require 'yaml'
28
31
 
32
+ require 'bleak_house' if $BLEAK_HOUSE
33
+
29
34
  require 'pp' # FIXME
30
35
  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(/.*? -- /, '')}."
36
+ puts "\e[31m\e[43mWarning, can't run botcontrol\e[0m\nYour installation is incomplete. Your" \
37
+ "ruby-installation is missing the file #{e.message.sub(/.*? -- /, '')}."
33
38
  puts "Backtrace:", *e.backtrace
34
39
  exit
35
40
  end
@@ -45,6 +50,7 @@ options = {}
45
50
  options["backup"] = CLOptions.new("[botname] [backupname] [directory]")
46
51
  options["config"] = CLOptions.new("[botname]")
47
52
  options["create"] = CLOptions.new("[botname]")
53
+ options["dir"] = CLOptions.new("dirname botname")
48
54
  options["delete"] = CLOptions.new("[botname]")
49
55
  options["help"] = CLOptions.new("[command]")
50
56
  options["info"] = CLOptions.new("[user]")
@@ -54,26 +60,27 @@ options["log"] = CLOptions.new("[botname]") {
54
60
  o '-F', '--no-find', 'TEXT', :no_find, "List only entries that don't contain TEXT"
55
61
  o '-g', '--grep', 'PATTERN', :grep, "List only entries that match PATTERN"
56
62
  o '-G', '--no-grep', 'PATTERN', :no_grep, "List only entries that don't match PATTERN"
57
- o '-H', '--head', 'COUNT', :head, "List the first COUNT entries"
58
- o '-h', '--help', nil, :help, "Display this help"
63
+ o '-h', '--head', 'COUNT', :head, "List the first COUNT entries"
59
64
  o '-l', '--level', 'LEVEL, ...', :level, "List only entries of LEVEL"
60
65
  o '-L', '--not-level', 'LEVEL, ...', :no_level, "List only entries not of LEVEL"
61
66
  # o '-o', '--out', 'FORMAT', :format, "Print entries using FORMAT"
62
67
  # o '-p', '--page', 'NUMBER', :page, "Show NUMBER entries per page"
63
68
  o '-s', '--start-date', 'START_DATE', :start_date, "List only entries after START_DATE"
64
- o '-T', '--tail', 'COUNT', :tail, "List the last COUNT entries"
69
+ o '-t', '--tail', 'COUNT', :tail, "List the last COUNT entries"
65
70
  }
66
71
  options["list"] = CLOptions.new("[user]")
72
+ options["quickcreate"] = CLOptions.new("[botname]")
67
73
  options["rename"] = CLOptions.new("[botname] [newname]")
68
74
  options["start"] = CLOptions.new("[botname]") {
69
75
  o '-c', '--channels', 'CHANNEL, ...', :channels, "Join CHANNELS instead of configured"
70
- o '-h', '--help', "Display this help"
76
+ o '-d', '--debug', nil, :debug, "Activate raw logging and log debug messages."
71
77
  o '-i', '--interactive', "Don't deamonize, lets the bot run interactively in shell."
72
78
  o '-n', '--nick', 'NICK', :nick, "Use NICK instead of configured"
73
79
  o '-p', '--port', 'PORT', :port, "Connect at PORT instead of configured"
74
80
  o '-r', '--remote', 'PORT', :remote_port, "Start remote control server and bind to PORT"
75
81
  o '-l', '--local', nil, :local, "Don't connect to configured server:port but to 127.0.0.1:6667"
76
82
  o '-s', '--server', 'SERVER', :server, "Connect to SERVER instead of the configured."
83
+ o '-v', '--verbose', nil, :verbose, "Sets $VERBOSE."
77
84
  o '-w', '--warnings', "Will enable warnings on stderr."
78
85
  }
79
86
  options["setup"] = CLOptions.new("[user]")
@@ -81,14 +88,10 @@ options["stop"] = CLOptions.new("[botname]")
81
88
  options["sync_plugins"] = CLOptions.new("[botname] [user]")
82
89
  options.each { |name, opt| opt.application_name "#{File.basename($0)} #{name}" }
83
90
 
84
- command = ARGV.shift.downcase
91
+ command = (ARGV.shift || "interactive").downcase
85
92
  opt = options[command].parse if options[command]
86
93
 
87
94
  case command
88
- when nil
89
- botcontrol.discuss("create_config", false, :user => nil)
90
- botcontrol.discuss("interactive")
91
-
92
95
  when "backup"
93
96
  botcontrol.discuss("create_config", false, :user => nil)
94
97
  botcontrol.discuss("backup", false,
@@ -109,6 +112,10 @@ case command
109
112
  botcontrol.discuss("create_config", false, :user => nil)
110
113
  botcontrol.discuss("create", false, :name => opt.argv.botname)
111
114
 
115
+ when "dir"
116
+ botcontrol.discuss("create_config", false, :user => nil)
117
+ botcontrol.discuss("dir", false, :dirname => opt.argv.dirname, :botname => opt.argv.botname)
118
+
112
119
  when "delete"
113
120
  botcontrol.discuss("create_config", false, :user => nil)
114
121
  botcontrol.discuss("delete", false, :name => opt.argv.botname)
@@ -122,6 +129,10 @@ case command
122
129
  when "info"
123
130
  botcontrol.discuss("info", false, :user => opt.argv.user)
124
131
 
132
+ when "interactive"
133
+ botcontrol.discuss("create_config", false, :user => nil)
134
+ botcontrol.discuss("interactive")
135
+
125
136
  when "log"
126
137
  botcontrol.discuss("create_config", false, :user => nil)
127
138
  if opt[:help] then
@@ -194,6 +205,10 @@ case command
194
205
  when "list"
195
206
  botcontrol.discuss("list", false, :user => opt.argv.user)
196
207
 
208
+ when "quickcreate"
209
+ botcontrol.discuss("create_config", false, :user => nil)
210
+ botcontrol.discuss("quickcreate", false, :name => opt.argv.botname)
211
+
197
212
  when "rename"
198
213
  botcontrol.discuss("create_config", false, :user => nil)
199
214
  botcontrol.discuss("rename", false,
@@ -206,12 +221,18 @@ case command
206
221
 
207
222
  when "start"
208
223
  botcontrol.discuss("create_config", false, :user => nil)
209
- botname = botcontrol.discuss(:start, false, :botname => opt.argv.botname)[:botname]
210
- options = {:daemonize => !opt["-i"]}
224
+ botname = botcontrol.discuss(:start, false, :botname => opt.argv.botname)[:botname]
225
+ options = {:daemonize => !opt["-i"]}
211
226
  if opt[:local] then
212
227
  options[:server] = "127.0.0.1"
213
228
  options[:port] = 6667
214
229
  end
230
+ if opt[:debug] then
231
+ $DEBUG = true
232
+ $VERBOSE = true
233
+ elsif opt[:verbose]
234
+ $VERBOSE = true
235
+ end
215
236
  Butler.start(nil, botname, options)
216
237
 
217
238
  when "stop"
@@ -10,44 +10,33 @@ end
10
10
  Butler.create(nil, name)
11
11
  bot = Butler.new(nil, name)
12
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)
13
+ nick = name
14
+ bot.config["connections/main/server"] = ask(:server, "irc.freenode.org", String, :min => 3)
15
+ bot.config["connections/main/port"] = ask(:port, 6667, Integer, :between => [0, 65535])
16
+ bot.config["connections/main/host"] = nil
17
+ bot.config["connections/main/reconnect_delay"] = ask(:reconnect_delay, 60, Integer, :greater_or_equal => 0)
18
+ bot.config["connections/main/reconnect_tries"] = ask(:reconnect_tries, -1, Integer, :greater_or_equal => -1)
19
+ bot.config["connections/main/charset"] = server_encoding = ask(:server_encoding, 'utf-8', String)
20
+ bot.config["connections/main/language"] = lang = ask(:language, "en", String, :min => 2)
21
+ bot.config["connections/main/nick"] = nick = ask(:nick, name, String, :between => [1, 32])
22
+ bot.config["connections/main/alternative"] = ask(:nick2, '[1]'+nick, String, :between => [1, 32])
23
+ bot.config["connections/main/user"] = ask(:user, nick, String, :between => [1, 32])
24
+ bot.config["connections/main/real"] = ask(:real, name+" (Butler IRC bot)", String, :between => [1, 32])
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
+ say(:config_channel, :name => channel)
30
+ prefix = "channels/#{server.config_key}/#{channel.config_key}"
31
+ bot.config["#{prefix}/password"] = ask(:channel_password, nil, String)
32
+ bot.config["#{prefix}/language"] = ask(:channel_language, lang, String)
33
+ bot.config["#{prefix}/charset"] = ask(:channel_encoding, server_encoding, String)
34
+ }
35
+ user = ask(:admin_user, nil, String, :min => 3)
36
+ pass = ask(:admin_pass, nil, String, :min => 3)
37
+ bot.access.user.create(user, pass, nil, true, :active => true)
38
+ user = bot.access.user.create("default_user", nil, nil, false, :active => true)
39
+ user.privileges.add(%w[plugin/public])
52
40
 
53
- #Object#methods has an undocumented parameter
41
+ puts
42
+ say(:how_to_start, :botname => nick, :user => user, :pass => pass)