muzang 1.0.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  rvm:
2
2
  - 1.9.2
3
+ - 1.9.3
3
4
  - ruby-head
4
- - jruby
5
- - rbx
6
- - rbx-2.0
5
+ - rbx-19mode
6
+
7
+ env:
8
+ - JRUBY_OPTS="--1.9"
data/Gemfile CHANGED
@@ -4,6 +4,6 @@ gemspec
4
4
 
5
5
  group :development do
6
6
  gem "em-ventually", "~> 0.1.2"
7
- gem "rspec", "~> 2.6.0"
7
+ gem "rspec", "~> 2.8.0"
8
8
  gem "jeweler", "~> 1.6.3"
9
9
  end
@@ -1,45 +1,40 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- muzang (0.0.1)
5
- coffeemaker (~> 0.0.1.beta.3)
6
- em-http-request (~> 0.3.0)
4
+ muzang (1.1.0)
5
+ coffeemaker (~> 0.1.0)
7
6
 
8
7
  GEM
9
8
  remote: http://rubygems.org/
10
9
  specs:
11
- activesupport (3.1.1)
10
+ activesupport (3.2.6)
11
+ i18n (~> 0.6)
12
12
  multi_json (~> 1.0)
13
- addressable (2.2.6)
14
13
  callsite (0.0.11)
15
- coffeemaker (0.0.1.beta.3)
14
+ coffeemaker (0.1.1)
16
15
  activesupport
17
16
  eventmachine (~> 1.0.0.beta.3)
18
17
  diff-lcs (1.1.3)
19
- em-http-request (0.3.0)
20
- addressable (>= 2.0.0)
21
- escape_utils
22
- eventmachine (>= 0.12.9)
23
- em-ventually (0.1.2)
18
+ em-ventually (0.1.3)
24
19
  callsite (~> 0.0.5)
25
20
  eventmachine
26
- escape_utils (0.2.4)
27
- eventmachine (1.0.0.beta.4)
21
+ eventmachine (1.0.0.rc.2)
28
22
  git (1.2.5)
23
+ i18n (0.6.0)
29
24
  jeweler (1.6.4)
30
25
  bundler (~> 1.0)
31
26
  git (>= 1.2.5)
32
27
  rake
33
- multi_json (1.0.3)
28
+ multi_json (1.3.6)
34
29
  rake (0.9.2.2)
35
- rspec (2.6.0)
36
- rspec-core (~> 2.6.0)
37
- rspec-expectations (~> 2.6.0)
38
- rspec-mocks (~> 2.6.0)
39
- rspec-core (2.6.4)
40
- rspec-expectations (2.6.0)
30
+ rspec (2.8.0)
31
+ rspec-core (~> 2.8.0)
32
+ rspec-expectations (~> 2.8.0)
33
+ rspec-mocks (~> 2.8.0)
34
+ rspec-core (2.8.0)
35
+ rspec-expectations (2.8.0)
41
36
  diff-lcs (~> 1.1.2)
42
- rspec-mocks (2.6.0)
37
+ rspec-mocks (2.8.0)
43
38
 
44
39
  PLATFORMS
45
40
  ruby
@@ -48,4 +43,4 @@ DEPENDENCIES
48
43
  em-ventually (~> 0.1.2)
49
44
  jeweler (~> 1.6.3)
50
45
  muzang!
51
- rspec (~> 2.6.0)
46
+ rspec (~> 2.8.0)
data/README.md CHANGED
@@ -1,46 +1,99 @@
1
1
  muzang
2
- ========
2
+ ======
3
3
 
4
- IRC bot for #drug.pl channel
4
+ Super simple IRCbot with **plugins**
5
5
 
6
6
  [![BuildStatus](http://travis-ci.org/LTe/muzang.png)](http://github.com/LTe/muzang)
7
7
 
8
- Plugin
9
- ======
8
+ Create bot instance
9
+ ===================
10
+
11
+ ```
12
+ mkdir muzang-instance
13
+ cd muzang-instance
14
+ bundle init
15
+ ```
16
+
17
+ ### Edit Gemfile
18
+
19
+ ```ruby
20
+ source "http://rubygems.org"
21
+
22
+ gem 'muzang'
23
+ ```
24
+
25
+ ### Template
26
+
27
+ ```ruby
28
+ # muzang.rb
29
+ require 'muzang'
30
+
31
+ EM.run do
32
+ @bot = Muzang::Bot.new(irc_host: 'localhost',
33
+ irc_port: 6667,
34
+ nick: 'muzang',
35
+ channels: ['#test'])
36
+ @bot.register_plugin(PluginClass)
37
+ @bot.start # start after register plugins
38
+ end
39
+ ```
40
+
41
+ ### Run
42
+
43
+ ```
44
+ bundle exec ruby muzang.rb
45
+ ```
46
+
47
+
48
+ How to create plugin?
49
+ =====================
10
50
 
11
51
  ```ruby
12
52
  class PluginName
13
53
  def initialize(bot)
54
+ # initialize stuff
14
55
  end
15
56
 
16
- def call(connection, message)
57
+ def call(connection, *message)
58
+ # plugin stuff
17
59
  end
18
60
  end
19
61
  ```
20
62
 
21
- *connection* - you can use methods from Coffeemaker::Commands
63
+ ## Connection
22
64
 
23
- message
65
+ def call(**connection**, message)
24
66
 
25
- ```ruby
26
- # example message
27
- {
28
- :command => "PRIVMSG",
29
- :user => "LTe",
30
- :nick => "LTe",
31
- :host => "localhost",
32
- :message => "Hi there!",
33
- :channel => "#test"
34
- }
35
- ```
67
+ ### Methods of connection object
68
+ * *join(channel)* **join to channel**
69
+ * *part(channel)* **exit from the channel**
70
+ * *msg(channel, text)* **send message to channel or to user**
36
71
 
37
- After that just execute .register_plugin before bot start
72
+ ## Message
38
73
 
39
- ```ruby
40
- @bot = Muzang::Bot.new
41
- @bot.register_plugin(PluginName)
42
- @bot.start
43
- ```
74
+ def call(connection, **message**)
75
+
76
+ ### Methods of message object
77
+ * numeric_reply
78
+ * *nick* **who sent the message**
79
+ * user
80
+ * host
81
+ * *sever* **server from which the message was sent**
82
+ * error
83
+ * *channel* **channel from which the message was sent**
84
+ * *message* **message body**
85
+ * *command* **message command**
86
+
87
+ ## Plugins
88
+
89
+ [muzang-plugins](http://github.com/LTe/muzang-plugins)
90
+
91
+ ## Ruby
92
+
93
+ * 1.9.2
94
+ * 1.9.3
95
+ * ruby-head
96
+ * rubinius 1.9 mode
44
97
 
45
98
  Contributing to muzang
46
99
  ========================
@@ -19,11 +19,15 @@ module Muzang
19
19
  instance.call(connection, m) rescue nil
20
20
  end
21
21
  end
22
+
23
+ connection.on_connect = Proc.new do
24
+ @channels.each { |channel| connection.join(channel) }
25
+ end
22
26
  end
23
27
  end
24
28
 
25
29
  def start
26
- @bot.start { |irc| @channels.each { |channel| irc.join(channel) } }
30
+ @bot.start
27
31
  end
28
32
 
29
33
  def register_plugin(plugin)
@@ -1,3 +1,3 @@
1
1
  module Muzang
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -18,6 +18,5 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_runtime_dependency "em-http-request", "~> 0.3.0"
22
- s.add_runtime_dependency "coffeemaker", "~> 0.0.1.beta.3"
21
+ s.add_runtime_dependency "coffeemaker", "~> 0.1.0"
23
22
  end
@@ -4,7 +4,11 @@ describe "Muzang" do
4
4
  before do
5
5
  @muzang = Muzang::Bot.new
6
6
  @muzang.bot.stub(:start) do
7
- Class.new{attr_accessor :on_message}.new
7
+ @connection = Class.new { include Coffeemaker::Bot::Irc::Connection }.new
8
+ @connection.on_connect = @muzang.bot.irc.on_connect
9
+ @connection.on_message = @muzang.bot.irc.on_message
10
+ @connection.stub(:send_data)
11
+ @connection
8
12
  end
9
13
  end
10
14
 
@@ -20,15 +24,24 @@ describe "Muzang" do
20
24
  end
21
25
 
22
26
  it "should create plugins proc" do
23
- @muzang.start
24
27
  @muzang.bot.irc.on_message.is_a?(Proc).should be_true
25
28
  end
26
29
 
30
+ it "should create hook for joining to the channels" do
31
+ @muzang.bot.irc.on_connect.is_a?(Proc).should be_true
32
+ end
33
+
34
+ it "should join to channels" do
35
+ @muzang.bot.irc.on_connect.should_receive(:call).once
36
+ connection = @muzang.start
37
+ connection.connection_completed
38
+ end
39
+
27
40
  it "should execute call on plugin instance" do
28
41
  @muzang.register_plugin(DummyPlugin)
29
42
  @plugin_instance = @muzang.plugins[DummyPlugin]
30
43
  @plugin_instance.should_receive(:call).once
31
- @muzang.start
32
- @muzang.bot.irc.on_message.call
44
+ connection = @muzang.start
45
+ connection.receive_line(':CalebDelnay!calebd@localhost PRIVMSG #mychannel :Hello everyone!')
33
46
  end
34
47
  end
@@ -1,2 +1,7 @@
1
1
  class DummyPlugin
2
+ def initialize(bot)
3
+ end
4
+
5
+ def call(connection, message)
6
+ end
2
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muzang
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,30 +10,24 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-15 00:00:00.000000000Z
13
+ date: 2012-06-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: em-http-request
17
- requirement: &69872948653680 !ruby/object:Gem::Requirement
16
+ name: coffeemaker
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 0.3.0
22
+ version: 0.1.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *69872948653680
26
- - !ruby/object:Gem::Dependency
27
- name: coffeemaker
28
- requirement: &69872948652460 !ruby/object:Gem::Requirement
25
+ version_requirements: !ruby/object:Gem::Requirement
29
26
  none: false
30
27
  requirements:
31
28
  - - ~>
32
29
  - !ruby/object:Gem::Version
33
- version: 0.0.1.beta.3
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: *69872948652460
30
+ version: 0.1.0
37
31
  description: IRC bot with easy plugin managment
38
32
  email:
39
33
  - piotr.nielacny@gmail.com
@@ -77,8 +71,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
71
  version: '0'
78
72
  requirements: []
79
73
  rubyforge_project: muzang
80
- rubygems_version: 1.8.10
74
+ rubygems_version: 1.8.24
81
75
  signing_key:
82
76
  specification_version: 3
83
77
  summary: Dolnoslaska Ruby User Group IRC bot
84
78
  test_files: []
79
+ has_rdoc: