butler 1.8.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +40 -0
- data/README +9 -9
- data/Rakefile +15 -71
- data/bin/botcontrol +151 -146
- data/data/butler/dialogs/botcontrol.rb +8 -3
- data/data/butler/dialogs/create.rb +18 -18
- data/data/butler/dialogs/create_config.rb +8 -0
- data/data/butler/dialogs/en/create_config.yaml +2 -0
- data/data/butler/dialogs/en/list.yaml +2 -1
- data/data/butler/dialogs/info.rb +2 -2
- data/data/butler/dialogs/list.rb +13 -8
- data/data/butler/plugins/games/countdown.rb +41 -0
- data/data/butler/plugins/games/roll.rb +59 -0
- data/lib/access.rb +6 -107
- data/lib/access/admin.rb +3 -0
- data/lib/access/role.rb +37 -2
- data/lib/access/savable.rb +5 -0
- data/lib/access/user.rb +21 -2
- data/lib/access/yamlbase.rb +4 -0
- data/lib/butler.rb +4 -4
- data/lib/butler/bot.rb +13 -13
- data/lib/butler/irc/client.rb +10 -2
- data/lib/butler/irc/parser.rb +7 -2
- data/lib/butler/irc/parser/commands.rb +24 -7
- data/lib/butler/irc/parser/generic.rb +27 -315
- data/lib/butler/irc/parser/rfc2812.rb +328 -0
- data/lib/butler/irc/socket.rb +1 -1
- data/lib/butler/irc/user.rb +13 -0
- data/lib/butler/plugin.rb +1 -1
- data/lib/butler/plugin/configproxy.rb +4 -4
- data/lib/butler/plugins.rb +1 -1
- data/lib/butler/version.rb +1 -1
- data/lib/configuration.rb +22 -71
- data/lib/dialogline.rb +12 -0
- data/lib/event.rb +5 -2
- data/lib/installer.rb +52 -24
- data/lib/iterator.rb +17 -7
- data/lib/log.rb +32 -5
- data/lib/log/comfort.rb +33 -16
- data/lib/log/entry.rb +25 -5
- data/lib/log/fakeio.rb +1 -0
- data/lib/log/splitter.rb +6 -2
- data/lib/ostructfixed.rb +5 -0
- data/lib/ruby/exception/detailed.rb +3 -3
- data/lib/scheduler.rb +19 -4
- data/lib/scriptfile.rb +9 -2
- data/lib/string.rb +176 -0
- data/lib/string/ascii.rb +31 -0
- data/lib/string/mbencoded.rb +79 -0
- data/lib/string/sbencoded.rb +77 -0
- data/lib/string/utf8.rb +157 -0
- data/lib/templater.rb +68 -10
- data/lib/w3validator.rb +86 -0
- data/test/irc/serverlistings/test_rpl_hiddenhost.txt +60 -0
- data/test/test_access.rb +101 -0
- data/test/test_configuration.rb +63 -0
- metadata +19 -2
@@ -0,0 +1,60 @@
|
|
1
|
+
$:.unshift("/Users/stefan/Development/Ruby/Gems/butler/trunk/lib")
|
2
|
+
require 'butler/irc/client'; include Butler::IRC; c = Client.new('127.0.0.1'); c.login("mybot1", "mybot", "My Bot")
|
3
|
+
|
4
|
+
c.irc.privmsg("foo", "bar")
|
5
|
+
|
6
|
+
:Gameservers.NJ.US.GameSurge.net 001 mybot1 :Welcome to the GameSurge IRC Network via Gameservers.com, mybot1
|
7
|
+
PING :1831737435
|
8
|
+
:Gameservers.NJ.US.GameSurge.net 396 mybot1 sfoptx.user.gamesurge :is now your hidden host
|
9
|
+
PING :1831737435
|
10
|
+
|
11
|
+
NOTICE AUTH :*** Looking up your hostname
|
12
|
+
NOTICE AUTH :*** Found your hostname, cached
|
13
|
+
NOTICE AUTH :*** Checking Ident
|
14
|
+
NOTICE AUTH :*** No ident response
|
15
|
+
PING :1831737435
|
16
|
+
:Gameservers.NJ.US.GameSurge.net 001 mybot1 :Welcome to the GameSurge IRC Network via Gameservers.com, mybot1
|
17
|
+
:Gameservers.NJ.US.GameSurge.net 002 mybot1 :Your host is Gameservers.NJ.US.GameSurge.net, running version u2.10.11.07.GS(01)
|
18
|
+
:Gameservers.NJ.US.GameSurge.net 003 mybot1 :This server was created Tue Mar 20 2007 at 21:16:30 EDT
|
19
|
+
:Gameservers.NJ.US.GameSurge.net 004 mybot1 Gameservers.NJ.US.GameSurge.net u2.10.11.07.GS(01) dioswkgxnI biklmnopstvrczCD bklov
|
20
|
+
:Gameservers.NJ.US.GameSurge.net 005 mybot1 ANNOUNCE WHOX WALLCHOPS WALLVOICES USERIP CPRIVMSG CNOTICE SILENCE=15 MODES=6 MAXCHANNELS=20 MAXBANS=45 NICKLEN=30 MAXNICKLEN=30 :are supported by this server
|
21
|
+
:Gameservers.NJ.US.GameSurge.net 005 mybot1 TOPICLEN=300 AWAYLEN=200 KICKLEN=300 CHANTYPES=#& PREFIX=(ov)@+ CHANMODES=b,k,l,imnpstrDcC CASEMAPPING=rfc1459 NETWORK=GameSurge :are supported by this server
|
22
|
+
:Gameservers.NJ.US.GameSurge.net 251 mybot1 :There are 42 users and 24634 invisible on 26 servers
|
23
|
+
:Gameservers.NJ.US.GameSurge.net 252 mybot1 63 :operator(s) online
|
24
|
+
:Gameservers.NJ.US.GameSurge.net 253 mybot1 3 :unknown connection(s)
|
25
|
+
:Gameservers.NJ.US.GameSurge.net 254 mybot1 61662 :channels formed
|
26
|
+
:Gameservers.NJ.US.GameSurge.net 255 mybot1 :I have 1 clients and 1 servers
|
27
|
+
:Gameservers.NJ.US.GameSurge.net NOTICE mybot1 :Highest connection count: 2 (1 clients)
|
28
|
+
:Gameservers.NJ.US.GameSurge.net 375 mybot1 :- Gameservers.NJ.US.GameSurge.net Message of the Day -
|
29
|
+
:Gameservers.NJ.US.GameSurge.net 372 mybot1 :.Type /MOTD to read the AUP before continuing using this service..
|
30
|
+
:Gameservers.NJ.US.GameSurge.net 372 mybot1 :The message of the day was last changed: 2007-3-22 12:51
|
31
|
+
:Gameservers.NJ.US.GameSurge.net 376 mybot1 :End of /MOTD command.
|
32
|
+
:Gameservers.NJ.US.GameSurge.net NOTICE mybot1 :on 2 ca 1(4) ft 10(10) tr
|
33
|
+
:mybot1!~mybot@c-66-176-77-3.hsd1.fl.comcast.net MODE mybot1 :+iw
|
34
|
+
:Global!Global@Services.GameSurge.net NOTICE mybot1 :.------------- MESSAGE(S) OF THE DAY --------------.
|
35
|
+
:Global!Global@Services.GameSurge.net NOTICE mybot1 :[.users.] Notice from GameSurge, posted 08:53 PM, 04/09/2007:
|
36
|
+
:Global!Global@Services.GameSurge.net NOTICE mybot1 :Interested in the broader gaming community? Remember to check out the GameSurge event calendar and homepage for upcoming events. - http://www.gamesurge.net/calendar/ - Additionally, look out for global notices on the network.
|
37
|
+
:Global!Global@Services.GameSurge.net NOTICE mybot1 :[.users.] Notice from GameSurge, posted 09:27 AM, 01/20/2007:
|
38
|
+
:Global!Global@Services.GameSurge.net NOTICE mybot1 :Please be familiar with the GameSurge Acceptable Use Policy. All users on the network are required to abide by it. http://www.gamesurge.net/aup/
|
39
|
+
:Global!Global@Services.GameSurge.net NOTICE mybot1 :.---------- END OF MESSAGE(S) OF THE DAY ----------.
|
40
|
+
:AuthServ!AuthServ@Services.GameSurge.net NOTICE mybot1 :I recognize you.
|
41
|
+
:Gameservers.NJ.US.GameSurge.net 396 mybot1 sfoptx.user.gamesurge :is now your hidden host
|
42
|
+
|
43
|
+
|
44
|
+
raw :127.0.0.1 001 apeiros :Welcome to the GameSurge IRC Network via Gameservers.com, apeiros
|
45
|
+
raw :127.0.0.1 002 apeiros :Your host is 127.0.0.1, running version u2.10.11.07.GS(01)
|
46
|
+
raw :127.0.0.1 003 apeiros :This server was created Tue Mar 20 2007 at 21:16:30 EDT
|
47
|
+
raw :127.0.0.1 004 apeiros 127.0.0.1 u2.10.11.07.GS(01) dioswkgxnI biklmnopstvrczCD bklov
|
48
|
+
raw :127.0.0.1 005 apeiros ANNOUNCE WHOX WALLCHOPS WALLVOICES USERIP CPRIVMSG CNOTICE SILENCE=15 MODES=6 MAXCHANNELS=20 MAXBANS=45 NICKLEN=30 MAXNICKLEN=30 :are supported by this server
|
49
|
+
raw :127.0.0.1 005 apeiros TOPICLEN=300 AWAYLEN=200 KICKLEN=300 CHANTYPES=#& PREFIX=(ov)@+ CHANMODES=b,k,l,imnpstrDcC CASEMAPPING=rfc1459 NETWORK=GameSurge :are supported by this server
|
50
|
+
raw :127.0.0.1 251 apeiros :There are 42 users and 24634 invisible on 26 servers
|
51
|
+
raw :127.0.0.1 252 apeiros 63 :operator(s) online
|
52
|
+
raw :127.0.0.1 253 apeiros 3 :unknown connection(s)
|
53
|
+
raw :127.0.0.1 254 apeiros 61662 :channels formed
|
54
|
+
raw :127.0.0.1 255 apeiros :I have 1 clients and 1 servers
|
55
|
+
raw :127.0.0.1 NOTICE apeiros :Highest connection count: 2 (1 clients)
|
56
|
+
raw :127.0.0.1 375 apeiros :- 127.0.0.1 Message of the Day -
|
57
|
+
raw :127.0.0.1 372 apeiros :.Type /MOTD to read the AUP before continuing using this service..
|
58
|
+
raw :127.0.0.1 372 apeiros :The message of the day was last changed: 2007-3-22 12:51
|
59
|
+
raw :127.0.0.1 376 apeiros :End of /MOTD command.
|
60
|
+
raw :127.0.0.1 NOTICE apeiros :on 2 ca 1(4) ft 10(10) tr
|
data/test/test_access.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'access'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class TestAccess < Test::Unit::TestCase
|
6
|
+
TestDir = "test_access"
|
7
|
+
def setup
|
8
|
+
#raise "#{TestDir} already exists, aborting test" if File.exist?(TestDir)
|
9
|
+
_teardown if File.exist?(TestDir)
|
10
|
+
Dir.mkdir(TestDir)
|
11
|
+
Dir.mkdir("#{TestDir}/user")
|
12
|
+
Dir.mkdir("#{TestDir}/role")
|
13
|
+
Dir.mkdir("#{TestDir}/privilege")
|
14
|
+
end
|
15
|
+
|
16
|
+
def _teardown
|
17
|
+
FileUtils.rm_r(TestDir)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_all
|
21
|
+
access = Access.new(
|
22
|
+
Access::YAMLBase.new(Access::User::Base, "#{TestDir}/user"),
|
23
|
+
Access::YAMLBase.new(Access::Role::Base, "#{TestDir}/role"),
|
24
|
+
Access::YAMLBase.new(Access::Privilege::Base, "#{TestDir}/privilege")
|
25
|
+
#:channel => Access::YAMLBase.new("#{TestDir}/channel", Access::Location)
|
26
|
+
)
|
27
|
+
assert(!access.user.exists?("test"))
|
28
|
+
access.user.create("test", "pass")
|
29
|
+
assert(access.user.exists?("test"))
|
30
|
+
|
31
|
+
%w(news news/read news/create news/edit news/delete banners banners/statistics
|
32
|
+
statistics statistics/web statistics/ftp paid_content).each { |priv|
|
33
|
+
assert(!access.privilege.exists?(priv))
|
34
|
+
access.privilege.create(priv, "test-privilege #{priv}")
|
35
|
+
assert(access.privilege.exists?(priv))
|
36
|
+
}
|
37
|
+
|
38
|
+
access.role.create("editor", "testrole description", %w(news/create news/edit statistics))
|
39
|
+
access.role.create("chiefeditor", "testrole description 2", %w(news), %w(editor))
|
40
|
+
|
41
|
+
user = access.login("test", "pass")
|
42
|
+
assert(user)
|
43
|
+
assert(user.logged?)
|
44
|
+
assert(!user.active?)
|
45
|
+
assert(user.inactive?)
|
46
|
+
user.active = true
|
47
|
+
assert(user.active?)
|
48
|
+
assert(!user.inactive?)
|
49
|
+
user = access.user["test", true]
|
50
|
+
assert(user)
|
51
|
+
assert(user.active?)
|
52
|
+
assert(!user.inactive?)
|
53
|
+
assert(!user.logged?)
|
54
|
+
|
55
|
+
assert(!user.privileged?("foo"))
|
56
|
+
assert(!user.privileged?("foo/bar"))
|
57
|
+
assert(!user.privileged?("foo/baz"))
|
58
|
+
assert(!user.privileged?("bar"))
|
59
|
+
assert(!user.privileged?("bar/foo"))
|
60
|
+
assert(!user.privileged?("baz"))
|
61
|
+
|
62
|
+
assert(!user.authorized?("foo"))
|
63
|
+
assert(!user.authorized?("foo/bar"))
|
64
|
+
assert(!user.authorized?("foo/baz"))
|
65
|
+
assert(!user.authorized?("bar"))
|
66
|
+
assert(!user.authorized?("bar/foo"))
|
67
|
+
assert(!user.authorized?("baz"))
|
68
|
+
|
69
|
+
user.privileges.add(%w(banners statistics/web paid_content))
|
70
|
+
|
71
|
+
assert(user.privileged?("banners"))
|
72
|
+
assert(user.privileged?("banners/statistics"))
|
73
|
+
assert(user.privileged?("statistics/web"))
|
74
|
+
assert(!user.privileged?("statistics"))
|
75
|
+
assert(user.privileged?("bar/foo"))
|
76
|
+
assert(user.privileged?("baz"))
|
77
|
+
|
78
|
+
assert(!user.authorized?("foo"))
|
79
|
+
assert(!user.authorized?("foo/bar"))
|
80
|
+
assert(!user.authorized?("foo/baz"))
|
81
|
+
assert(!user.authorized?("bar"))
|
82
|
+
assert(!user.authorized?("bar/foo"))
|
83
|
+
assert(!user.authorized?("baz"))
|
84
|
+
|
85
|
+
user = access.login("test", "pass")
|
86
|
+
|
87
|
+
assert(user.privileged?("foo"))
|
88
|
+
assert(user.privileged?("foo/bar"))
|
89
|
+
assert(user.privileged?("foo/baz"))
|
90
|
+
assert(!user.privileged?("bar"))
|
91
|
+
assert(user.privileged?("bar/foo"))
|
92
|
+
assert(user.privileged?("baz"))
|
93
|
+
|
94
|
+
assert(user.authorized?("foo"))
|
95
|
+
assert(user.authorized?("foo/bar"))
|
96
|
+
assert(user.authorized?("foo/baz"))
|
97
|
+
assert(!user.authorized?("bar"))
|
98
|
+
assert(user.authorized?("bar/foo"))
|
99
|
+
assert(user.authorized?("baz"))
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'configuration'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TestConfiguration < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@conf = Configuration.new("./test")
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_setup
|
10
|
+
assert(@conf)
|
11
|
+
assert(@conf.base)
|
12
|
+
assert(File.directory?(@conf.base))
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_accessor
|
16
|
+
assert(@conf["file1"] = "bar")
|
17
|
+
assert_equal(@conf[[:file1]], "bar")
|
18
|
+
assert_equal(@conf[["file1"]], "bar")
|
19
|
+
assert_equal(@conf["file1"], "bar")
|
20
|
+
assert(File.exist?("#{@conf.base}/file1.yaml"))
|
21
|
+
|
22
|
+
assert(@conf["file2"] = "foo")
|
23
|
+
assert_equal(@conf[:file2], "foo")
|
24
|
+
assert_equal(@conf["file2"], "foo")
|
25
|
+
assert(File.exist?("#{@conf.base}/file2.yaml"))
|
26
|
+
|
27
|
+
assert(@conf[[:file3, :sub]] = "baz")
|
28
|
+
assert_equal(@conf[[:file3, :sub]], "baz")
|
29
|
+
assert_equal(@conf["file3", "sub"], "baz")
|
30
|
+
assert(File.exist?("#{@conf.base}/file3.yaml"))
|
31
|
+
assert(!File.exist?("#{@conf.base}/file3"))
|
32
|
+
|
33
|
+
assert(@conf.exist?(:file3))
|
34
|
+
assert(!@conf.exist?(:file))
|
35
|
+
#assert_raise { @conf
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_nesting
|
39
|
+
end
|
40
|
+
|
41
|
+
def xtest_common_usecase
|
42
|
+
@conf.setup(%w(
|
43
|
+
main
|
44
|
+
plugins
|
45
|
+
plugins/demo
|
46
|
+
))
|
47
|
+
@conf.merge(
|
48
|
+
"main.language" => "de",
|
49
|
+
"main.channels" => %w(foo bar baz),
|
50
|
+
"plugins.demo.value" => 42
|
51
|
+
)
|
52
|
+
@conf["plugins.demo.other"] = 24
|
53
|
+
@conf["main.language"].replace("en")
|
54
|
+
@conf.update
|
55
|
+
file, key = @conf.send(:split, "main.language")
|
56
|
+
File.open(file, "w") { |fh| fh.write({"language" => "en"}.to_yaml) }
|
57
|
+
@conf.rehash
|
58
|
+
end
|
59
|
+
|
60
|
+
def teardown
|
61
|
+
FileUtils.rm_r(@conf.base)
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: butler
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.8.
|
7
|
-
date: 2007-10-
|
6
|
+
version: 1.8.1
|
7
|
+
date: 2007-10-27 00:00:00 +02:00
|
8
8
|
summary: Butler - the IRC bot with class
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -42,11 +42,13 @@ files:
|
|
42
42
|
- data/butler/dialogs/botcontrol.rb
|
43
43
|
- data/butler/dialogs/config.rb
|
44
44
|
- data/butler/dialogs/create.rb
|
45
|
+
- data/butler/dialogs/create_config.rb
|
45
46
|
- data/butler/dialogs/delete.rb
|
46
47
|
- data/butler/dialogs/en
|
47
48
|
- data/butler/dialogs/en/backup.yaml
|
48
49
|
- data/butler/dialogs/en/botcontrol.yaml
|
49
50
|
- data/butler/dialogs/en/create.yaml
|
51
|
+
- data/butler/dialogs/en/create_config.yaml
|
50
52
|
- data/butler/dialogs/en/delete.yaml
|
51
53
|
- data/butler/dialogs/en/help.yaml
|
52
54
|
- data/butler/dialogs/en/info.yaml
|
@@ -68,6 +70,7 @@ files:
|
|
68
70
|
- data/butler/dialogs/sync_plugins.rb
|
69
71
|
- data/butler/dialogs/uninstall.rb
|
70
72
|
- data/butler/dialogs/unknown_command.rb
|
73
|
+
- data/butler/ircd_scripts
|
71
74
|
- data/butler/plugins
|
72
75
|
- data/butler/plugins/core
|
73
76
|
- data/butler/plugins/core/logout.rb
|
@@ -81,8 +84,10 @@ files:
|
|
81
84
|
- data/butler/plugins/dev/raw.rb
|
82
85
|
- data/butler/plugins/dev/rawlog.rb
|
83
86
|
- data/butler/plugins/games
|
87
|
+
- data/butler/plugins/games/countdown.rb
|
84
88
|
- data/butler/plugins/games/eightball.rb
|
85
89
|
- data/butler/plugins/games/mastermind.rb
|
90
|
+
- data/butler/plugins/games/roll.rb
|
86
91
|
- data/butler/plugins/irc
|
87
92
|
- data/butler/plugins/irc/action.rb
|
88
93
|
- data/butler/plugins/irc/join.rb
|
@@ -142,6 +147,7 @@ files:
|
|
142
147
|
- lib/butler/irc/parser
|
143
148
|
- lib/butler/irc/parser/commands.rb
|
144
149
|
- lib/butler/irc/parser/generic.rb
|
150
|
+
- lib/butler/irc/parser/rfc2812.rb
|
145
151
|
- lib/butler/irc/parser.rb
|
146
152
|
- lib/butler/irc/socket.rb
|
147
153
|
- lib/butler/irc/string.rb
|
@@ -215,7 +221,14 @@ files:
|
|
215
221
|
- lib/ruby/string/unescaped.rb
|
216
222
|
- lib/scheduler.rb
|
217
223
|
- lib/scriptfile.rb
|
224
|
+
- lib/string
|
225
|
+
- lib/string/ascii.rb
|
226
|
+
- lib/string/mbencoded.rb
|
227
|
+
- lib/string/sbencoded.rb
|
228
|
+
- lib/string/utf8.rb
|
229
|
+
- lib/string.rb
|
218
230
|
- lib/templater.rb
|
231
|
+
- lib/w3validator.rb
|
219
232
|
- test/cloptions.rb
|
220
233
|
- test/cv.rb
|
221
234
|
- test/irc
|
@@ -226,7 +239,11 @@ files:
|
|
226
239
|
- test/irc/messages.txt
|
227
240
|
- test/irc/parser.rb
|
228
241
|
- test/irc/profile_parser.rb
|
242
|
+
- test/irc/serverlistings
|
243
|
+
- test/irc/serverlistings/test_rpl_hiddenhost.txt
|
229
244
|
- test/irc/users.rb
|
245
|
+
- test/test_access.rb
|
246
|
+
- test/test_configuration.rb
|
230
247
|
test_files: []
|
231
248
|
|
232
249
|
rdoc_options:
|