Sutto-marvin 0.4.0 → 0.8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/bin/marvin +22 -156
  2. data/handlers/keiki_thwopper.rb +21 -0
  3. data/handlers/tweet_tweet.rb +1 -3
  4. data/lib/marvin/abstract_client.rb +75 -189
  5. data/lib/marvin/abstract_parser.rb +9 -11
  6. data/lib/marvin/base.rb +134 -101
  7. data/lib/marvin/client/actions.rb +104 -0
  8. data/lib/marvin/client/default_handlers.rb +97 -0
  9. data/lib/marvin/command_handler.rb +60 -49
  10. data/lib/marvin/console.rb +4 -31
  11. data/lib/marvin/core_commands.rb +30 -12
  12. data/lib/marvin/distributed/client.rb +225 -0
  13. data/lib/marvin/distributed/handler.rb +85 -0
  14. data/lib/marvin/distributed/protocol.rb +88 -0
  15. data/lib/marvin/distributed/server.rb +154 -0
  16. data/lib/marvin/distributed.rb +4 -10
  17. data/lib/marvin/dsl.rb +103 -0
  18. data/lib/marvin/exception_tracker.rb +7 -4
  19. data/lib/marvin/irc/client.rb +127 -99
  20. data/lib/marvin/irc/event.rb +14 -10
  21. data/lib/marvin/irc.rb +0 -1
  22. data/lib/marvin/middle_man.rb +1 -1
  23. data/lib/marvin/parsers/command.rb +10 -8
  24. data/lib/marvin/parsers/prefixes/host_mask.rb +12 -7
  25. data/lib/marvin/parsers/prefixes/server.rb +1 -1
  26. data/lib/marvin/parsers/ragel_parser.rb +59 -52
  27. data/lib/marvin/parsers/ragel_parser.rl +6 -7
  28. data/lib/marvin/parsers/simple_parser.rb +4 -9
  29. data/lib/marvin/parsers.rb +1 -2
  30. data/lib/marvin/settings.rb +29 -79
  31. data/lib/marvin/test_client.rb +20 -26
  32. data/lib/marvin/util.rb +10 -3
  33. data/lib/marvin.rb +42 -39
  34. data/templates/boot.erb +3 -0
  35. data/templates/connections.yml.erb +10 -0
  36. data/templates/debug_handler.erb +5 -0
  37. data/templates/hello_world.erb +10 -0
  38. data/templates/rakefile.erb +15 -0
  39. data/templates/settings.yml.erb +8 -0
  40. data/{config/setup.rb → templates/setup.erb} +8 -10
  41. data/templates/test_helper.erb +17 -0
  42. data/test/abstract_client_test.rb +63 -0
  43. data/test/parser_comparison.rb +2 -2
  44. data/test/parser_test.rb +3 -3
  45. data/test/test_helper.rb +58 -6
  46. metadata +51 -83
  47. data/README.textile +0 -105
  48. data/TUTORIAL.textile +0 -54
  49. data/VERSION.yml +0 -4
  50. data/config/boot.rb +0 -14
  51. data/config/connections.yml.sample +0 -5
  52. data/config/settings.yml.sample +0 -13
  53. data/handlers/logging_handler.rb +0 -89
  54. data/lib/marvin/core_ext.rb +0 -11
  55. data/lib/marvin/daemon.rb +0 -71
  56. data/lib/marvin/data_store.rb +0 -73
  57. data/lib/marvin/dispatchable.rb +0 -99
  58. data/lib/marvin/distributed/dispatch_handler.rb +0 -83
  59. data/lib/marvin/distributed/drb_client.rb +0 -78
  60. data/lib/marvin/distributed/ring_server.rb +0 -41
  61. data/lib/marvin/handler.rb +0 -12
  62. data/lib/marvin/irc/server/abstract_connection.rb +0 -84
  63. data/lib/marvin/irc/server/base_connection.rb +0 -66
  64. data/lib/marvin/irc/server/channel.rb +0 -115
  65. data/lib/marvin/irc/server/named_store.rb +0 -14
  66. data/lib/marvin/irc/server/remote_interface.rb +0 -77
  67. data/lib/marvin/irc/server/user/handle_mixin.rb +0 -140
  68. data/lib/marvin/irc/server/user.rb +0 -5
  69. data/lib/marvin/irc/server/user_connection.rb +0 -134
  70. data/lib/marvin/irc/server/virtual_user_connection.rb +0 -80
  71. data/lib/marvin/irc/server.rb +0 -71
  72. data/lib/marvin/loader.rb +0 -149
  73. data/lib/marvin/logger.rb +0 -86
  74. data/lib/marvin/options.rb +0 -42
  75. data/lib/marvin/parsers/regexp_parser.rb +0 -93
  76. data/lib/marvin/status.rb +0 -72
  77. data/script/client +0 -3
  78. data/script/console +0 -3
  79. data/script/distributed_client +0 -3
  80. data/script/install +0 -1
  81. data/script/ring_server +0 -4
  82. data/script/server +0 -4
  83. data/script/status +0 -3
  84. data/spec/marvin/abstract_client_test.rb +0 -38
  85. data/spec/spec_helper.rb +0 -14
@@ -0,0 +1,10 @@
1
+ class HelloWorld < Marvin::CommandHandler
2
+
3
+ exposes :hello
4
+
5
+ desc "Says hello to you (with the current pid!)"
6
+ def hello(data)
7
+ reply "Hola from process with pid #{Process.pid}!"
8
+ end
9
+
10
+ end
@@ -0,0 +1,15 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ task :default => "test:units"
5
+
6
+ namespace :test do
7
+
8
+ desc "Runs the unit tests for perennial"
9
+ Rake::TestTask.new("units") do |t|
10
+ t.pattern = 'test/*_test.rb'
11
+ t.libs << 'test'
12
+ t.verbose = true
13
+ end
14
+
15
+ end
@@ -0,0 +1,8 @@
1
+ default:
2
+ user: MarvinBot
3
+ name: MarvinBot
4
+ nick: MarvinBot
5
+ nicks:
6
+ - MarvinBot1000
7
+ - MarvinBot2000
8
+ - MarvinBot3000
@@ -4,16 +4,12 @@
4
4
  # any connections are created
5
5
  Marvin::Loader.before_run do
6
6
 
7
- # Want a non-default namespace? Choose something simple
8
- # Marvin::Settings.distributed_namespace = :some_namespace
9
-
10
7
  # E.G.
11
8
  # MyHandler.register! (Marvin::Base subclass) or
12
- # Marvin::Settings.default_client.register_handler my_handler (a handler instance)
9
+ # Marvin::Settings.client.register_handler my_handler (a handler instance)
13
10
 
14
- # Register in ruby
15
- #
16
- # LoggingHandler.register! if Marvin::Settings.use_logging
11
+ # Register based on some setting you've added. e.g.:
12
+ # LoggingHandler.register! if Marvin::Settings.use_logging?
17
13
 
18
14
  # Conditional registration - load the distributed dispatcher
19
15
  # if an actual client, otherwise use the normal handlers.
@@ -22,12 +18,14 @@ Marvin::Loader.before_run do
22
18
  # HelloWorld.register!
23
19
  # DebugHandler.register!
24
20
  # else
25
- # Marvin::Distributed::DispatchHandler.register!
21
+ # Marvin::Distributed::Handler.register!
22
+ # else
23
+
26
24
  # end
27
25
 
28
- # And any other code here that will be run before the client
26
+ # And any other code here that will be run before the client, e.g:
29
27
 
30
28
  HelloWorld.register!
31
29
  DebugHandler.register!
32
30
 
33
- end
31
+ end
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+
3
+ # Testing dependencies
4
+ require 'test/unit'
5
+ require 'shoulda'
6
+ # RedGreen doesn't seem to be needed under 1.9
7
+ require 'redgreen' if RUBY_VERSION < "1.9"
8
+
9
+ require 'pathname'
10
+ root_directory = Pathname.new(__FILE__).dirname.join("..").expand_path
11
+ require root_directory.join("config", "boot")
12
+
13
+ class Test::Unit::TestCase
14
+
15
+ # Add your extensions here
16
+
17
+ end
@@ -0,0 +1,63 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class AbstractClientTest < Test::Unit::TestCase
4
+
5
+ context 'testing out a connection' do
6
+
7
+ setup do
8
+ @client = Marvin::Settings.client
9
+ @client.setup
10
+ @config = @client.configuration
11
+ @client.configuration = {
12
+ :user => "DemoUser",
13
+ :name => "Demo Users Name",
14
+ :nick => "Haysoos",
15
+ :nicks => ["Haysoos_", "Haysoos__"]
16
+ }
17
+ end
18
+
19
+ should "dispatch :client_connected as the first event on process_connect" do
20
+ assert_resets_client
21
+ client.process_connect
22
+ assert_equal [:client_connected, {}], client.dispatched_events.first
23
+ assert_dispatched :client_connected, 0, {}
24
+ end
25
+
26
+ should "dispatch :client_connected as the first event on process_connect" do
27
+ assert_resets_client
28
+ client.default_channels = ["#awesome", "#rock"]
29
+ client.process_connect
30
+ assert_dispatched :client_connected, -2, {}
31
+ assert_dispatched :outgoing_nick, -1
32
+ assert_equal 2, client.outgoing_commands.length
33
+ assert_equal "NICK Haysoos\r\n", client.outgoing_commands[0]
34
+ assert_sent_line "NICK Haysoos\r\n", 0
35
+ assert_sent_line "USER DemoUser 0 \* :Demo Users Name\r\n", 1
36
+ end
37
+
38
+ should "dispatch :client_disconnect on process_disconnect" do
39
+ assert_resets_client
40
+ client.process_disconnect
41
+ assert_dispatched :client_disconnected
42
+ end
43
+
44
+ should 'attempt to join the default channels on receiving welcome' do
45
+ assert_resets_client
46
+ client.default_channels = ["#awesome", "#rock"]
47
+ client.handle_welcome
48
+ assert_sent_line "JOIN #awesome,#rock\r\n"
49
+ end
50
+
51
+ should "add an :incoming_line event for each incoming line" do
52
+ assert_resets_client
53
+ client.receive_line "SOME RANDOM LINE THAT HAS ZERO ACTUAL USE"
54
+ assert_dispatched :incoming_line, 0, :line => "SOME RANDOM LINE THAT HAS ZERO ACTUAL USE"
55
+ end
56
+
57
+ teardown do
58
+ @client.configuration = @config
59
+ end
60
+
61
+ end
62
+
63
+ end
@@ -12,7 +12,7 @@ LINES = [
12
12
  ":SuttoL!n=SuttoL@li6-47.members.linode.com PRIVMSG #relayrelay :testing...",
13
13
  ":wolfe.freenode.net 004 MarvinBot3000 wolfe.freenode.net hyperion-1.0.2b aAbBcCdDeEfFGhHiIjkKlLmMnNopPQrRsStTuUvVwWxXyYzZ01234569*@ bcdefFhiIklmnoPqstv"
14
14
  ]
15
- PARSERS = [Marvin::Parsers::RagelParser, Marvin::Parsers::SimpleParser, Marvin::Parsers::RegexpParser]
15
+ PARSERS = [Marvin::Parsers::SimpleParser, Marvin::Parsers::RagelParser]
16
16
 
17
17
  LINES.each do |line|
18
18
 
@@ -44,7 +44,7 @@ puts ""
44
44
 
45
45
  width = PARSERS.map { |p| p.name.length }.max + 2
46
46
 
47
- ITERATIONS = 1000
47
+ ITERATIONS = 100
48
48
 
49
49
  Benchmark.bm(width) do |b|
50
50
  PARSERS.each do |parser|
data/test/parser_test.rb CHANGED
@@ -8,7 +8,7 @@ require File.join(File.dirname(__FILE__), 'test_helper')
8
8
  class ParserTest < Test::Unit::TestCase
9
9
 
10
10
  # The default parser
11
- @@parser = Marvin::Parsers::SimpleParser
11
+ @@parser = Marvin::Settings.parser
12
12
 
13
13
  context "When parsing a LIST" do
14
14
  setup { @parsed = @@parser.new("LIST #twilight_zone,#42") }
@@ -79,7 +79,7 @@ class ParserTest < Test::Unit::TestCase
79
79
  end
80
80
 
81
81
  should "have the correct nick" do
82
- assert_equal "RelayBot", @parsed.command.prefix.nickname
82
+ assert_equal "RelayBot", @parsed.command.prefix.nick
83
83
  end
84
84
 
85
85
  should "have the correct user" do
@@ -136,7 +136,7 @@ class ParserTest < Test::Unit::TestCase
136
136
  end
137
137
 
138
138
  should "have the correct nick" do
139
- assert_equal "SuttoL", @parsed.command.prefix.nickname
139
+ assert_equal "SuttoL", @parsed.command.prefix.nick
140
140
  end
141
141
 
142
142
  should "have the correct user" do
data/test/test_helper.rb CHANGED
@@ -1,10 +1,62 @@
1
- BASE_DIR = File.expand_path(File.join(File.dirname(__FILE__), ".."))
2
-
3
1
  require 'rubygems'
4
- require 'shoulda'
2
+
3
+ # Testing dependencies
5
4
  require 'test/unit'
6
- require File.join(BASE_DIR, "lib/marvin")
5
+ require 'shoulda'
6
+ # RedGreen doesn't seem to be needed under 1.9
7
+ require 'redgreen' if RUBY_VERSION < "1.9"
8
+
9
+ require 'pathname'
10
+ root_directory = Pathname.new(__FILE__).dirname.join("..").expand_path
11
+ require root_directory.join("lib", "marvin")
12
+
13
+ Marvin::Settings.setup!
14
+ Marvin::Logger.setup!
15
+
16
+ Marvin::Settings.client = Marvin::TestClient
7
17
 
8
18
  class Test::Unit::TestCase
9
- # Any extra helpers go here
10
- end
19
+
20
+ @test_client = nil
21
+
22
+ protected
23
+
24
+ def client(force_new = false)
25
+ @test_client = Marvin::TestClient.new if force_new || @test_client.nil?
26
+ @test_client
27
+ end
28
+
29
+ # Short hand for creating a class with
30
+ # a given class_eval block.
31
+ def class_via(*args, &blk)
32
+ klass = Class.new(*args)
33
+ klass.class_eval(&blk) unless blk.blank?
34
+ return klass
35
+ end
36
+
37
+ # Short hand for creating a test class
38
+ # for a set of mixins - give it the modules
39
+ # and it will include them all.
40
+ def test_class_for(*mods, &blk)
41
+ klass = Class.new
42
+ klass.class_eval { include(*mods) }
43
+ klass.class_eval(&blk) unless blk.blank?
44
+ return klass
45
+ end
46
+
47
+ def assert_dispatched(name, position = -1, opts = nil)
48
+ res = client.dispatched_events[position]
49
+ assert !res.nil?
50
+ assert_equal name, res[0]
51
+ assert_equal opts, res[1] if !opts.nil?
52
+ end
53
+
54
+ def assert_sent_line(line, position = -1)
55
+ assert_equal line, client.outgoing_commands[position]
56
+ end
57
+
58
+ def assert_resets_client
59
+ assert_equal [], client(true).dispatched_events
60
+ end
61
+
62
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Sutto-marvin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darcy Laycock
@@ -9,140 +9,113 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-22 00:00:00 -07:00
13
- default_executable: marvin
12
+ date: 2009-09-16 00:00:00 -07:00
13
+ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: json
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: activesupport
16
+ name: Sutto-perennial
27
17
  type: :runtime
28
18
  version_requirement:
29
19
  version_requirements: !ruby/object:Gem::Requirement
30
20
  requirements:
31
21
  - - ">="
32
22
  - !ruby/object:Gem::Version
33
- version: 2.1.0
23
+ version: 0.2.4.6
34
24
  version:
35
25
  - !ruby/object:Gem::Dependency
36
- name: eventmachine
26
+ name: eventmachine-eventmachine
37
27
  type: :runtime
38
28
  version_requirement:
39
29
  version_requirements: !ruby/object:Gem::Requirement
40
30
  requirements:
41
31
  - - ">="
42
32
  - !ruby/object:Gem::Version
43
- version: 0.12.0
33
+ version: 0.12.9
44
34
  version:
45
35
  - !ruby/object:Gem::Dependency
46
- name: thor
36
+ name: json
47
37
  type: :runtime
48
38
  version_requirement:
49
39
  version_requirements: !ruby/object:Gem::Requirement
50
40
  requirements:
51
41
  - - ">="
52
42
  - !ruby/object:Gem::Version
53
- version: 0.9.7
43
+ version: "0"
54
44
  version:
55
- description: Marvin is a Ruby IRC library / framework for ultimate awesomeness and with an evented design.
45
+ description:
56
46
  email: sutto@sutto.net
57
- executables:
58
- - marvin
47
+ executables: []
48
+
59
49
  extensions: []
60
50
 
61
- extra_rdoc_files:
62
- - README.textile
51
+ extra_rdoc_files: []
52
+
63
53
  files:
64
- - README.textile
65
- - TUTORIAL.textile
66
- - VERSION.yml
67
54
  - bin/marvin
68
- - config/boot.rb
69
- - config/connections.yml.sample
70
- - config/settings.yml.sample
71
- - config/setup.rb
72
- - handlers/debug_handler.rb
73
- - handlers/hello_world.rb
74
- - handlers/logging_handler.rb
75
- - handlers/simple_logger.rb
76
- - handlers/tweet_tweet.rb
77
- - lib/marvin.rb
55
+ - lib/marvin
78
56
  - lib/marvin/abstract_client.rb
79
57
  - lib/marvin/abstract_parser.rb
80
58
  - lib/marvin/base.rb
59
+ - lib/marvin/client
60
+ - lib/marvin/client/actions.rb
61
+ - lib/marvin/client/default_handlers.rb
81
62
  - lib/marvin/command_handler.rb
82
63
  - lib/marvin/console.rb
83
64
  - lib/marvin/core_commands.rb
84
- - lib/marvin/core_ext.rb
85
- - lib/marvin/daemon.rb
86
- - lib/marvin/data_store.rb
87
- - lib/marvin/dispatchable.rb
65
+ - lib/marvin/distributed
66
+ - lib/marvin/distributed/client.rb
67
+ - lib/marvin/distributed/handler.rb
68
+ - lib/marvin/distributed/protocol.rb
69
+ - lib/marvin/distributed/server.rb
88
70
  - lib/marvin/distributed.rb
89
- - lib/marvin/distributed/dispatch_handler.rb
90
- - lib/marvin/distributed/drb_client.rb
91
- - lib/marvin/distributed/ring_server.rb
71
+ - lib/marvin/dsl.rb
92
72
  - lib/marvin/exception_tracker.rb
93
73
  - lib/marvin/exceptions.rb
94
- - lib/marvin/handler.rb
95
- - lib/marvin/irc.rb
74
+ - lib/marvin/irc
96
75
  - lib/marvin/irc/client.rb
97
76
  - lib/marvin/irc/event.rb
98
77
  - lib/marvin/irc/replies.rb
99
- - lib/marvin/irc/server.rb
100
- - lib/marvin/irc/server/abstract_connection.rb
101
- - lib/marvin/irc/server/base_connection.rb
102
- - lib/marvin/irc/server/channel.rb
103
- - lib/marvin/irc/server/named_store.rb
104
- - lib/marvin/irc/server/remote_interface.rb
105
- - lib/marvin/irc/server/user.rb
106
- - lib/marvin/irc/server/user/handle_mixin.rb
107
- - lib/marvin/irc/server/user_connection.rb
108
- - lib/marvin/irc/server/virtual_user_connection.rb
109
- - lib/marvin/loader.rb
110
- - lib/marvin/logger.rb
78
+ - lib/marvin/irc.rb
111
79
  - lib/marvin/logging_handler.rb
112
80
  - lib/marvin/middle_man.rb
113
- - lib/marvin/options.rb
114
- - lib/marvin/parsers.rb
81
+ - lib/marvin/parsers
115
82
  - lib/marvin/parsers/command.rb
116
- - lib/marvin/parsers/prefixes.rb
83
+ - lib/marvin/parsers/prefixes
117
84
  - lib/marvin/parsers/prefixes/host_mask.rb
118
85
  - lib/marvin/parsers/prefixes/server.rb
86
+ - lib/marvin/parsers/prefixes.rb
119
87
  - lib/marvin/parsers/ragel_parser.rb
120
88
  - lib/marvin/parsers/ragel_parser.rl
121
- - lib/marvin/parsers/regexp_parser.rb
122
89
  - lib/marvin/parsers/simple_parser.rb
90
+ - lib/marvin/parsers.rb
123
91
  - lib/marvin/settings.rb
124
- - lib/marvin/status.rb
125
92
  - lib/marvin/test_client.rb
126
93
  - lib/marvin/util.rb
127
- - script/client
128
- - script/console
129
- - script/distributed_client
130
- - script/install
131
- - script/ring_server
132
- - script/server
133
- - script/status
134
- - spec/marvin/abstract_client_test.rb
135
- - spec/spec_helper.rb
94
+ - lib/marvin.rb
95
+ - templates/boot.erb
96
+ - templates/connections.yml.erb
97
+ - templates/debug_handler.erb
98
+ - templates/hello_world.erb
99
+ - templates/rakefile.erb
100
+ - templates/settings.yml.erb
101
+ - templates/setup.erb
102
+ - templates/test_helper.erb
103
+ - test/abstract_client_test.rb
136
104
  - test/parser_comparison.rb
137
105
  - test/parser_test.rb
138
106
  - test/test_helper.rb
139
107
  - test/util_test.rb
108
+ - handlers/debug_handler.rb
109
+ - handlers/hello_world.rb
110
+ - handlers/keiki_thwopper.rb
111
+ - handlers/simple_logger.rb
112
+ - handlers/tweet_tweet.rb
140
113
  has_rdoc: false
141
- homepage: http://blog.ninjahideout.com/
114
+ homepage: http://sutto.net/
142
115
  licenses:
143
116
  post_install_message:
144
- rdoc_options:
145
- - --charset=UTF-8
117
+ rdoc_options: []
118
+
146
119
  require_paths:
147
120
  - lib
148
121
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -163,11 +136,6 @@ rubyforge_project:
163
136
  rubygems_version: 1.3.5
164
137
  signing_key:
165
138
  specification_version: 3
166
- summary: Ruby IRC Library / Framework
167
- test_files:
168
- - spec/marvin/abstract_client_test.rb
169
- - spec/spec_helper.rb
170
- - test/parser_comparison.rb
171
- - test/parser_test.rb
172
- - test/test_helper.rb
173
- - test/util_test.rb
139
+ summary: Evented IRC Library of Doom
140
+ test_files: []
141
+
data/README.textile DELETED
@@ -1,105 +0,0 @@
1
- h1. Marvin
2
-
3
- Marvin is a ruby irc framework / library built on top of event machine.
4
- It's been build from scratch to be evented - you build "handlers" which
5
- are called whenever an event occurs.
6
-
7
- A single client instance can handle multiple IRC connections (and will
8
- automatically reconnect in the case that a connection is lost). Distributed
9
- support (e.g. 1 client => multiple handler backends) is built in out of
10
- the box on top of DRb.
11
-
12
- h2. Getting Started
13
-
14
- Starting out with Marvin is simple. You can either go the "edge" route -
15
- cloning from the GitHub repository (in this case, [here](http://github.com/sutto/marvin))
16
- and then running the following:
17
-
18
- $ rake gemspec
19
- $ gem build marvin.gemspec
20
- $ sudo gem install marvin.gem
21
-
22
- Or, for a generally more stable release you can install it from the GitHub gem
23
- server (requiring Rubygems >= 1.2.0 with the GitHub sources added), by running
24
- the following:
25
-
26
- $ sudo gem install Sutto-marvin
27
-
28
- Installing the gem will make available a new executable - "+marvin+" - which is
29
- used as an easy way to do a variety of tasks. To get started, you can create
30
- a project located at given path using the following command:
31
-
32
- $ marvin create path-to-my-bot
33
-
34
- Once that's done, you'll have a blank slate loaded with the default marvin handlers -
35
- +HelloWorld+ (which will respond to any addressed "hello"'s) and an empty debug handler
36
- which you can use for generic debugging. To run the new app, you can use either of the
37
- following:
38
-
39
- $ cd path-to-my-bot && script/client
40
-
41
- or, alternatively,
42
-
43
- $ marvin client path-to-my-bot
44
-
45
- There are a couple of options available for the client (as well as the marvin library),
46
- Each of which can be found by appending the "--help" option to the command.
47
-
48
- Once your client has been started (assuming the name wasn't taken / it could connect),
49
- simply join the chat room your bot was instructed to join and say the following (substiting
50
- BotNick for the nick name your bot connected with):
51
-
52
- BotNick: hello
53
-
54
- Or even easier, by PM'ing the bot with:
55
-
56
- hello
57
-
58
- Assuming all went well, your bot should reply back with something akin to (where YourNick)
59
- if the nickname you connected with):
60
-
61
- YourNick: Hola from process with pid 12342
62
-
63
- h2. Distributed Bots
64
-
65
- One of the relatively unique features of Marvin is the ability to write bots
66
- which use DRb and Rinda which can grow with relative ease.
67
-
68
- It's important to keep in mind that keeping state is discouraged in this case
69
- as it can not be ensured that clients are still active or that you will always
70
- get messages from the same client.
71
-
72
- For a start, take a look at the default +config/setup.rb+ file which contains
73
- an example of registering handlers on a distributed client as well as setting
74
- up the distributed handler which needs to be setup on the main client.
75
-
76
- By default, the messages will be dispatched to the first discovered tuple
77
- space (using Rinda::RingFinger) and will be of the format:
78
-
79
- [:marvin_format, :your_namespace, :message_name, {:message => "options"}, client_reference]
80
-
81
- You can change the namespace (which defaults to +:default+) by setting +Marvin::Settings.distributed_namespace+
82
-
83
- Running a distributed client requires three things:
84
-
85
- * 1 Ring server instance (+script/ring_server+ or +marvin ring_server+ or +marvin rs+)
86
- * 1+ Client instances (+script/client+ or +marvin client+ or +marvin cl+)
87
- * 1+ Distributed Client instances (+script/distributed_client+ or +marvin distributed_client+ or +marvin dc+)
88
-
89
- Each of which takes the default options of:
90
- * -v - Be verbose and print to STDOUT if not daemonized
91
- * -level=something - set level, defaults to info
92
- * -d - daemonize the process
93
- * -k - kill all daemonized instances of this specific kind
94
-
95
- h2. Example Bots
96
-
97
- Coming soon.
98
-
99
- h2. Thanks
100
-
101
- Thanks go to:
102
-
103
- * Jeff Rafter - contributed code and doc changes, now one of the co-developers.
104
- * epitron / halogrium - For the ragel state machine used in Marvin::Parsers::RagelParser
105
- * The creator of Ruby-IRCD - the server component is heavily influenced by / part derivative of said work.
data/TUTORIAL.textile DELETED
@@ -1,54 +0,0 @@
1
- h1. A Quick Introduction to Marvin
2
-
3
- Welcome young one - in today's lesson we're going to learn
4
- how to build a simple IRC bot using "Marvin":http://github.com/Sutto/marvin.
5
- If you haven't built an IRC bot before, there is a great
6
- deal of things you can do - ranging from consuming content (e.g.
7
- analysing logs of IRC rooms, seeing who swears the most)
8
- as well as other things such as bridges between other
9
- protocols (twitter => irc bridges) and all sorts of fancy stuff.
10
-
11
- h3. What is this marvin thingy-majiggy?
12
-
13
- Marvin is an IRC Library / Framework (it can be used either way)
14
- built with an evented design on top of DRb, EventMachine and a bunch
15
- of other stuff for Ruby. it's currently got a fairly complete client
16
- and a very incomplete server implementation.
17
-
18
- h2. Step #1 - Getting Marvin
19
-
20
- There are currently two different ways to get marvin - via the
21
- GitHub gem sources or directly from the source.
22
-
23
- To install from the GitHub gem source, simply use:
24
-
25
- sudo gem install Sutto-marvin -s http://gems.github.com
26
-
27
- Alternatively, you can directly clone the repository. To do this, you'll need to run the
28
- following:
29
-
30
- git clone git://github.com/Sutto/marvin.git
31
- cd marvin
32
- sudo ./script/install
33
-
34
- Once that's done, not only will you now have a handy "marvin" gem which you
35
- can require but you will also have a handy executable of the same name which
36
- you can use.
37
-
38
- h2. Step #2 - Creating a Skeleton App
39
-
40
- By default, marvin currently uses a simple skeleton app (not unlike
41
- Ruby on Rails) as a starting point. To get started, you simply use
42
- the "marvin create" command with a path to / folder name (which must not
43
- yet exist) into which you wish to create the folder. For example, if I wanted
44
- to create a new irc bot called "BlorkBot", I could do the following:
45
-
46
- marvin create BlorkBot
47
-
48
- And a new directory with the basic structure called "BlorkBot" will be created
49
- under the current directory. To get started, you can then open your editor and
50
- browse the given folder. Of this generated structure, there are only two folders
51
- you need to worry about for the moment - config and handlers.
52
-
53
- h2. Step #3 - Basic configuration
54
-
data/VERSION.yml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- :minor: 4
3
- :patch: 0
4
- :major: 0
data/config/boot.rb DELETED
@@ -1,14 +0,0 @@
1
- # Load Marvin, do any initialization etc.
2
- # Note: this is called from inside scripts
3
- # or anywhere you want to start a base marvin
4
- # instance.
5
-
6
- require 'rubygems'
7
-
8
- MARVIN_ROOT = File.expand_path(File.join(File.dirname(__FILE__), ".."))
9
-
10
- # Check if a local copy of marvin exists, and set the load path if it does.
11
- $:.unshift(File.dirname(__FILE__) + "/../lib/") if File.exist?(File.dirname(__FILE__) + "/../lib/marvin.rb")
12
-
13
- # And Require Marvin.
14
- require 'marvin'
@@ -1,5 +0,0 @@
1
- "irc.freenode.net":
2
- port: 6667
3
- channels:
4
- - "#marvin-testing"
5
- - "#relayrelay"
@@ -1,13 +0,0 @@
1
- default:
2
- name: Marvin
3
- use_logging: false
4
- datastore_location: tmp/datastore.json
5
- nicks:
6
- - MarvinBot1000
7
- - MarvinBot2000
8
- - MarvinBot3000
9
- - MarvinusBoticus
10
- development:
11
- user: MarvinBot
12
- name: MarvinBot
13
- nick: MarvinBot