ircmad 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/ircmad.gemspec CHANGED
@@ -19,5 +19,5 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_dependency "eventmachine"
21
21
  gem.add_dependency "em-websocket"
22
- gem.add_dependency "zircon"
22
+ gem.add_dependency "zircon", "0.0.4"
23
23
  end
data/lib/ircmad.rb CHANGED
@@ -4,6 +4,7 @@ require 'em-websocket'
4
4
  require 'zircon'
5
5
 
6
6
  require "ircmad/version"
7
+ require "ircmad/zircon_ext"
7
8
  require "ircmad/configurable"
8
9
  require "ircmad/irc_client"
9
10
  require "ircmad/web_socket"
@@ -42,6 +43,7 @@ class Ircmad
42
43
  set :port, c[:port] || '6667'
43
44
  set :channel_list, c[:channel_list] || []
44
45
  set :username, c[:username]
46
+ set :password, c[:password]
45
47
  end.run!
46
48
  }
47
49
  end
@@ -5,32 +5,38 @@ class Ircmad
5
5
  def initialize(&block)
6
6
  instance_eval(&block) if block_given?
7
7
 
8
- unless @zircon
9
- @zircon = Zircon.new config
8
+ @client = Zircon.new config
10
9
 
11
- @zircon.send(:login) if @zircon.respond_to?(:login, true)
12
- config[:channel_list].each do |channel|
13
- @zircon.join channel
14
- end
15
- end
16
- @zircon
10
+ @client.send(:login) if @client.respond_to?(:login, true)
11
+ config[:channel_list].each { |channel| @client.join channel }
17
12
  end
18
13
 
19
14
  def run!
20
15
  Ircmad.post_channel.subscribe do |msg|
21
- data = JSON.parse(msg, :symbolize_names => true) rescue nil
22
- privmsg data[:channel], ":#{data[:message]}"
16
+ parsed_msg = begin
17
+ JSON.parse(msg, :symbolize_names => true) rescue nil
18
+ rescue JSON::ParserError
19
+ puts "#{msg} is invalid json"
20
+ rescue => e
21
+ puts "Unexpected error"
22
+ puts e.message
23
+ puts e.backtrace.join("\n")
24
+ end
25
+
26
+ if parsed_msg && parsed_msg[:channel] && parsed_msg[:message]
27
+ privmsg parsed_msg[:channel], ":#{parsed_msg[:message]}"
28
+ end
23
29
  end
24
30
 
25
31
  on_privmsg do |msg|
26
32
  Ircmad.get_channel << msg
27
33
  end
28
34
 
29
- @zircon.run!
35
+ @client.run!
30
36
  end
31
37
 
32
38
  def method_missing(action, *args, &block)
33
- @zircon.send(action.to_s, *args, &block)
39
+ @client.send(action.to_s, *args, &block)
34
40
  end
35
41
  end
36
42
  end
@@ -1,3 +1,3 @@
1
1
  class Ircmad
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,14 +1,3 @@
1
- class Zircon::Message
2
- def to_json
3
- fencoding = -> s { s.respond_to?(:force_encoding) ? s.force_encoding('UTF-8') : s }
4
- {
5
- username: fencoding.call(from),
6
- channel: fencoding.call(to),
7
- body: fencoding.call(body)
8
- }.to_json
9
- end
10
- end
11
-
12
1
  class Ircmad
13
2
  class WebSocket
14
3
  include Configurable
@@ -0,0 +1,12 @@
1
+ class Ircmad
2
+ class Zircon::Message
3
+ def to_json
4
+ fencoding = -> s { s.respond_to?(:force_encoding) ? s.force_encoding('UTF-8') : s }
5
+ {
6
+ username: fencoding.call(from),
7
+ channel: fencoding.call(to),
8
+ body: fencoding.call(body)
9
+ }.to_json
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: ircmad
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Takatoshi Matsumoto
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-09 00:00:00.000000000 Z
12
+ date: 2013-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  prerelease: false
@@ -49,16 +49,16 @@ dependencies:
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - ! '>='
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.0.4
55
55
  name: zircon
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.0.4
62
62
  description: Bringing IRC into WebSocket
63
63
  email:
64
64
  - toqoz403@gmail.com
@@ -78,6 +78,7 @@ files:
78
78
  - lib/ircmad/irc_client.rb
79
79
  - lib/ircmad/version.rb
80
80
  - lib/ircmad/web_socket.rb
81
+ - lib/ircmad/zircon_ext.rb
81
82
  homepage: http://github.com/ToQoz/ircmad
82
83
  licenses: []
83
84
  post_install_message: