tkellem 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/tkellem/bouncer.rb +12 -6
- data/lib/tkellem/migrations/005_add_rooms.rb +10 -0
- data/lib/tkellem/models/room.rb +6 -0
- data/lib/tkellem/plugins/backlog.rb +3 -3
- data/lib/tkellem/tkellem_server.rb +1 -0
- data/lib/tkellem/version.rb +1 -1
- data/spec/plugins/backlog_spec.rb +22 -0
- metadata +8 -4
data/Gemfile.lock
CHANGED
data/lib/tkellem/bouncer.rb
CHANGED
@@ -13,8 +13,6 @@ class Bouncer
|
|
13
13
|
cattr_accessor :plugins
|
14
14
|
self.plugins = []
|
15
15
|
|
16
|
-
class Room < Struct.new(:name, :topic, :topic_setter, :topic_time); end
|
17
|
-
|
18
16
|
def initialize(network_user)
|
19
17
|
@network_user = network_user
|
20
18
|
@user = network_user.user
|
@@ -24,7 +22,7 @@ class Bouncer
|
|
24
22
|
# maps { client_conn => state_hash }
|
25
23
|
@active_conns = {}
|
26
24
|
@welcomes = []
|
27
|
-
@rooms = {}
|
25
|
+
@rooms = Room.where(network_user_id: network_user.id).each_with_object({}) { |room,h| h[room.name] = room }
|
28
26
|
# maps { client_conn => away_status_or_nil }
|
29
27
|
@away = {}
|
30
28
|
# plugin data
|
@@ -114,10 +112,18 @@ class Bouncer
|
|
114
112
|
ready! if msg.command == "376" # end of MOTD
|
115
113
|
false
|
116
114
|
when 'JOIN'
|
117
|
-
|
115
|
+
room_name = msg.args.first
|
116
|
+
if msg.target_user == @nick && !@rooms[room_name]
|
117
|
+
room = Room.create!(network_user_id: network_user.id, name: room_name)
|
118
|
+
@rooms[room_name] = room
|
119
|
+
end
|
118
120
|
true
|
119
121
|
when 'PART'
|
120
|
-
|
122
|
+
room_name = msg.args.first
|
123
|
+
if msg.target_user == @nick
|
124
|
+
room = @rooms.delete(room_name)
|
125
|
+
room.destroy
|
126
|
+
end
|
121
127
|
true
|
122
128
|
when 'TOPIC'
|
123
129
|
if room = @rooms[msg.args.first]
|
@@ -223,7 +229,7 @@ class Bouncer
|
|
223
229
|
end
|
224
230
|
|
225
231
|
def ready!
|
226
|
-
@rooms.
|
232
|
+
@rooms.each_value do |room|
|
227
233
|
send_msg("JOIN #{room.name}")
|
228
234
|
end
|
229
235
|
|
@@ -204,7 +204,7 @@ class Backlog
|
|
204
204
|
|
205
205
|
def send_backlog(conn, ctx_name, stream)
|
206
206
|
while line = stream.gets
|
207
|
-
timestamp, msg = parse_line(line, ctx_name)
|
207
|
+
timestamp, msg = self.class.parse_line(line, ctx_name)
|
208
208
|
next unless msg
|
209
209
|
privmsg = msg.args.first[0] != '#'[0]
|
210
210
|
if msg.prefix
|
@@ -232,7 +232,7 @@ class Backlog
|
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
235
|
-
def parse_line(line, ctx_name)
|
235
|
+
def self.parse_line(line, ctx_name)
|
236
236
|
timestamp = Time.parse(line[0, 19])
|
237
237
|
case line[20..-1]
|
238
238
|
when %r{^> (\* )?(.+)$}
|
@@ -241,7 +241,7 @@ class Backlog
|
|
241
241
|
msg.ctcp = 'ACTION'
|
242
242
|
end
|
243
243
|
return timestamp, msg
|
244
|
-
when %r{^< (\* )?([
|
244
|
+
when %r{^< (\* )?([^ ]+): (.+)$}
|
245
245
|
msg = IrcMessage.new($2, 'PRIVMSG', [ctx_name, $3])
|
246
246
|
if $1 == '* '
|
247
247
|
msg.ctcp = 'ACTION'
|
data/lib/tkellem/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tkellem/irc_message'
|
3
|
+
require 'time'
|
4
|
+
|
5
|
+
include Tkellem
|
6
|
+
|
7
|
+
describe Backlog do
|
8
|
+
describe '.parse_line' do
|
9
|
+
it "should parse other user names" do
|
10
|
+
def cmp(username, message = "test 1 2")
|
11
|
+
timestamp, msg = Backlog.parse_line(%{10-07-2013 10:10:36 < #{username}: #{message}}, '#testroom')
|
12
|
+
expected = IrcMessage.new(username, 'PRIVMSG', ['#testroom', message])
|
13
|
+
msg.should == expected
|
14
|
+
end
|
15
|
+
|
16
|
+
cmp("dude")
|
17
|
+
cmp("dude@some/fancy/web/addr.blah")
|
18
|
+
cmp("dude!~dude@12:34:56")
|
19
|
+
cmp("dude!~dude@12:34:56", "hey dude: test")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tkellem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -115,11 +115,13 @@ files:
|
|
115
115
|
- lib/tkellem/migrations/002_at_connect_columns.rb
|
116
116
|
- lib/tkellem/migrations/003_settings.rb
|
117
117
|
- lib/tkellem/migrations/004_add_backlog_positions.rb
|
118
|
+
- lib/tkellem/migrations/005_add_rooms.rb
|
118
119
|
- lib/tkellem/models/backlog_position.rb
|
119
120
|
- lib/tkellem/models/host.rb
|
120
121
|
- lib/tkellem/models/listen_address.rb
|
121
122
|
- lib/tkellem/models/network.rb
|
122
123
|
- lib/tkellem/models/network_user.rb
|
124
|
+
- lib/tkellem/models/room.rb
|
123
125
|
- lib/tkellem/models/setting.rb
|
124
126
|
- lib/tkellem/models/user.rb
|
125
127
|
- lib/tkellem/plugins/backlog.rb
|
@@ -135,6 +137,7 @@ files:
|
|
135
137
|
- spec/bouncer_connection_spec.rb
|
136
138
|
- spec/irc_message_spec.rb
|
137
139
|
- spec/irc_server_spec.rb
|
140
|
+
- spec/plugins/backlog_spec.rb
|
138
141
|
- spec/spec_helper.rb
|
139
142
|
- tkellem.gemspec
|
140
143
|
homepage: http://github.com/codekitchen/tkellem
|
@@ -151,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
154
|
version: '0'
|
152
155
|
segments:
|
153
156
|
- 0
|
154
|
-
hash: -
|
157
|
+
hash: -2551777789450779146
|
155
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
159
|
none: false
|
157
160
|
requirements:
|
@@ -160,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
163
|
version: '0'
|
161
164
|
segments:
|
162
165
|
- 0
|
163
|
-
hash: -
|
166
|
+
hash: -2551777789450779146
|
164
167
|
requirements: []
|
165
168
|
rubyforge_project:
|
166
169
|
rubygems_version: 1.8.23
|
@@ -172,4 +175,5 @@ test_files:
|
|
172
175
|
- spec/bouncer_connection_spec.rb
|
173
176
|
- spec/irc_message_spec.rb
|
174
177
|
- spec/irc_server_spec.rb
|
178
|
+
- spec/plugins/backlog_spec.rb
|
175
179
|
- spec/spec_helper.rb
|