tkellem 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -4,14 +4,16 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :test do
7
- gem 'rspec', '~> 2.13.0'
7
+ gem 'coveralls', require: false
8
8
  gem 'mocha', '0.14.0', require: false
9
+ gem 'rake'
10
+ gem 'rspec', '~> 2.13.0'
9
11
  gem 'simplecov', require: false
10
- gem 'coveralls', require: false
11
12
  end
12
13
 
13
14
  group :development do
15
+ gem 'debugger'
14
16
  gem 'guard-rspec'
17
+ gem 'rake'
15
18
  gem 'rspec-nc'
16
- gem 'debugger'
17
19
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tkellem (0.9.4)
4
+ tkellem (0.9.5)
5
5
  activerecord (~> 4.0.0.rc2)
6
6
  eventmachine (~> 1.0.3)
7
7
  geoip (~> 1.3.2)
@@ -78,6 +78,7 @@ GEM
78
78
  slop (~> 3.4)
79
79
  rails-observers (0.1.2)
80
80
  activemodel (~> 4.0)
81
+ rake (10.1.0)
81
82
  rb-fsevent (0.9.3)
82
83
  rb-inotify (0.9.0)
83
84
  ffi (>= 0.5.0)
@@ -116,6 +117,7 @@ DEPENDENCIES
116
117
  debugger
117
118
  guard-rspec
118
119
  mocha (= 0.14.0)
120
+ rake
119
121
  rspec (~> 2.13.0)
120
122
  rspec-nc
121
123
  simplecov
@@ -101,6 +101,17 @@ class Bouncer
101
101
  if forward
102
102
  # send to server
103
103
  send_msg(msg)
104
+
105
+ # replay to other connected clients
106
+ if msg.command == "PRIVMSG" && (!msg.ctcp? || msg.action?)
107
+ msg.readdress_to(nick)
108
+
109
+ @active_conns.each do |c,s|
110
+ next if c == client
111
+ c.send_msg(msg)
112
+ end
113
+ end
114
+
104
115
  flag_for_reply(msg.command, forward) if forward != true
105
116
  end
106
117
  end
@@ -45,6 +45,21 @@ module BouncerConnection
45
45
  def ssl_handshake_completed
46
46
  end
47
47
 
48
+ def schedule_ping_client
49
+ EM::Timer.new(60) { ping_client }
50
+ end
51
+
52
+ def ping_client
53
+ failsafe("ping_client") do
54
+ send_msg("PING tkellem")
55
+ @ping_timer = EM::Timer.new(10) do
56
+ # ping timeout
57
+ info("PING timeout, closing connection")
58
+ close_connection
59
+ end
60
+ end
61
+ end
62
+
48
63
  def error!(msg)
49
64
  info("ERROR :#{msg}")
50
65
  say_as_tkellem(msg)
@@ -57,6 +72,7 @@ module BouncerConnection
57
72
  return error!("Unknown connection: #{@conn_name}") unless @bouncer
58
73
  @state = :connected
59
74
  info "connected"
75
+ schedule_ping_client
60
76
  @bouncer.connect_client(self)
61
77
  end
62
78
 
@@ -102,6 +118,14 @@ module BouncerConnection
102
118
  msg_tkellem(IrcMessage.new(nil, 'TKELLEM', [msg.args.last]))
103
119
  elsif command == 'TKELLEM' || command == 'TK'
104
120
  msg_tkellem(msg)
121
+ elsif command == 'PONG'
122
+ if @ping_timer
123
+ @ping_timer.cancel
124
+ @ping_timer = nil
125
+ # only schedule again if @ping_timer existed, so we don't schedule
126
+ # multiple if the client just randomly sends PONGs
127
+ schedule_ping_client
128
+ end
105
129
  elsif command == 'CAP'
106
130
  # TODO: full support for CAP -- this just gets mobile colloquy connecting
107
131
  if msg.args.first =~ /req/i
@@ -91,6 +91,31 @@ class IrcMessage < Struct.new(:prefix, :command, :args, :ctcp)
91
91
  IrcMessage.new(prefix, command, args, ctcp)
92
92
  end
93
93
 
94
+ def readdress_to(nick)
95
+ privmsg = args.first[0] != '#'[0]
96
+
97
+ if msg.prefix
98
+ # to this user
99
+ if privmsg
100
+ args[0] = nick
101
+ else
102
+ # do nothing, it's good to send
103
+ end
104
+ else
105
+ # from this user
106
+ if privmsg
107
+ # a one-on-one chat -- every client i've seen doesn't know how to
108
+ # display messages from themselves here, so we fake it by just
109
+ # adding an arrow and pretending the other user said it. shame.
110
+ prefix = msg.args.first
111
+ args[0] = nick
112
+ args[-1] = "-> #{msg.args.last}"
113
+ else
114
+ # it's a room, we can just replay
115
+ prefix = nick
116
+ end
117
+ end
118
+ end
94
119
  end
95
120
 
96
121
  end
@@ -230,28 +230,7 @@ class Backlog
230
230
  timestamp = timestamp.in_time_zone(time_zone) if timestamp && time_zone
231
231
  timestamp = timestamp.localtime if timestamp && !time_zone
232
232
  next unless msg
233
- privmsg = msg.args.first[0] != '#'[0]
234
- if msg.prefix
235
- # to this user
236
- if privmsg
237
- msg.args[0] = @bouncer.nick
238
- else
239
- # do nothing, it's good to send
240
- end
241
- else
242
- # from this user
243
- if privmsg
244
- # a one-on-one chat -- every client i've seen doesn't know how to
245
- # display messages from themselves here, so we fake it by just
246
- # adding an arrow and pretending the other user said it. shame.
247
- msg.prefix = msg.args.first
248
- msg.args[0] = @bouncer.nick
249
- msg.args[-1] = "-> #{msg.args.last}"
250
- else
251
- # it's a room, we can just replay
252
- msg.prefix = @bouncer.nick
253
- end
254
- end
233
+ msg.readdress_to(@bouncer.nick)
255
234
  conn.send_msg(msg.with_timestamp(timestamp))
256
235
  end
257
236
  end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Tkellem
3
- VERSION = "0.9.4"
3
+ VERSION = "0.9.5"
4
4
  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
4
+ version: 0.9.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -184,12 +184,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
184
  - - ! '>='
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
+ segments:
188
+ - 0
189
+ hash: 4535993549696292820
187
190
  required_rubygems_version: !ruby/object:Gem::Requirement
188
191
  none: false
189
192
  requirements:
190
193
  - - ! '>='
191
194
  - !ruby/object:Gem::Version
192
195
  version: '0'
196
+ segments:
197
+ - 0
198
+ hash: 4535993549696292820
193
199
  requirements: []
194
200
  rubyforge_project:
195
201
  rubygems_version: 1.8.23
@@ -203,4 +209,3 @@ test_files:
203
209
  - spec/irc_server_spec.rb
204
210
  - spec/plugins/backlog_spec.rb
205
211
  - spec/spec_helper.rb
206
- has_rdoc: