cinch 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/cinch.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'cinch/bot'
2
2
 
3
3
  module Cinch
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
 
6
6
  # @return [String]
7
7
  # @todo Handle mIRC color codes more gracefully.
data/lib/cinch/PLANNED ADDED
@@ -0,0 +1,4 @@
1
+ - advanced log levels
2
+ - support for channel forwards
3
+ - a mode-change parser
4
+ - support for DCC
data/lib/cinch/bot.rb CHANGED
@@ -110,7 +110,7 @@ module Cinch
110
110
  :options => Hash.new {|h,k| h[k] = {}},
111
111
  }),
112
112
  :channels => [],
113
- :encoding => nil,
113
+ :encoding => Encoding.default_external,
114
114
  })
115
115
 
116
116
  @semaphores_mutex = Mutex.new
data/lib/cinch/irc.rb CHANGED
@@ -32,9 +32,6 @@ module Cinch
32
32
  else
33
33
  @socket = tcp_socket
34
34
  end
35
- @socket.set_encoding(@bot.config.encoding || Encoding.default_external,
36
- Encoding.default_internal,
37
- {:invalid => :replace, :undef => :replace})
38
35
 
39
36
  @queue = MessageQueue.new(@socket, @bot)
40
37
  message "PASS #{@config.password}" if @config.password
@@ -45,6 +42,7 @@ module Cinch
45
42
  begin
46
43
  while line = @socket.gets
47
44
  begin
45
+ line.force_encoding(@bot.config.encoding).encode!({:invalid => :replace, :undef => :replace})
48
46
  parse line
49
47
  rescue => e
50
48
  @bot.logger.log_exception(e)
@@ -55,7 +55,7 @@ module Cinch
55
55
  @bot.logger.log(message, :outgoing) if @bot.config.verbose
56
56
 
57
57
  @time_since_last_send = Time.now
58
- @socket.print message + "\r\n"
58
+ @socket.print message.encode(@bot.config.encoding, {:invalid => :replace, :undef => :replace}) + "\r\n"
59
59
  end
60
60
  end
61
61
  end
data/lib/cinch/plugin.rb CHANGED
@@ -114,20 +114,24 @@ module Cinch
114
114
  prefix = Regexp.escape(prefix)
115
115
  end
116
116
  @__cinch_patterns.each do |pattern|
117
+ pattern_to_register = nil
118
+
117
119
  if pattern.use_prefix && prefix
118
120
  case pattern.pattern
119
121
  when Regexp
120
- pattern.pattern = /^#{prefix}#{pattern.pattern}/
122
+ pattern_to_register = /^#{prefix}#{pattern.pattern}/
121
123
  when String
122
- pattern.pattern = prefix + pattern.pattern
124
+ pattern_to_register = prefix + pattern.pattern
123
125
  end
126
+ else
127
+ pattern_to_register = pattern.pattern
124
128
  end
125
129
 
126
130
  react_on = @__cinch_react_on || :message
127
131
 
128
- bot.debug "[plugin] #{plugin_name}: Registering executor with pattern `#{pattern.pattern}`, reacting on `#{react_on}`"
132
+ bot.debug "[plugin] #{plugin_name}: Registering executor with pattern `#{pattern_to_register}`, reacting on `#{react_on}`"
129
133
 
130
- bot.on(react_on, pattern.pattern, instance, pattern) do |message, plugin, pattern, *args|
134
+ bot.on(react_on, pattern_to_register, instance, pattern) do |message, plugin, pattern, *args|
131
135
  if plugin.respond_to?(pattern.method)
132
136
  method = plugin.method(pattern.method)
133
137
  arity = method.arity - 1
data/lib/cinch/user.rb CHANGED
@@ -231,7 +231,7 @@ module Cinch
231
231
  }.merge(values).each do |attr, value|
232
232
  sync(attr, value, true)
233
233
  end
234
- p [self, values, not_found]
234
+
235
235
  sync(:unknown?, false, true)
236
236
  @synced = true
237
237
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 0
8
- - 1
9
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Lee Jarvis
@@ -15,16 +16,18 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-08-20 00:00:00 +02:00
19
+ date: 2010-09-02 00:00:00 +02:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: rspec
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - "="
27
29
  - !ruby/object:Gem::Version
30
+ hash: 27
28
31
  segments:
29
32
  - 1
30
33
  - 3
@@ -68,6 +71,7 @@ files:
68
71
  - lib/cinch/user.rb
69
72
  - lib/cinch/constants.rb
70
73
  - lib/cinch/callback.rb
74
+ - lib/cinch/PLANNED
71
75
  - lib/cinch/syncable.rb
72
76
  - lib/cinch/message_queue.rb
73
77
  - lib/cinch/helpers.rb
@@ -108,25 +112,29 @@ rdoc_options: []
108
112
  require_paths:
109
113
  - lib
110
114
  required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
111
116
  requirements:
112
117
  - - ">="
113
118
  - !ruby/object:Gem::Version
119
+ hash: 49
114
120
  segments:
115
121
  - 1
116
122
  - 9
117
123
  - 1
118
124
  version: 1.9.1
119
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
120
127
  requirements:
121
128
  - - ">="
122
129
  - !ruby/object:Gem::Version
130
+ hash: 3
123
131
  segments:
124
132
  - 0
125
133
  version: "0"
126
134
  requirements: []
127
135
 
128
136
  rubyforge_project:
129
- rubygems_version: 1.3.6
137
+ rubygems_version: 1.3.7
130
138
  signing_key:
131
139
  specification_version: 3
132
140
  summary: An IRC Bot Building Framework