tkellem 0.9.0.beta6 → 0.9.0.beta7

Sign up to get free protection for your applications and to get access to all the features.
@@ -88,7 +88,6 @@ class Tkellem::Daemon
88
88
 
89
89
  def start
90
90
  trap("INT") { EM.stop }
91
- remove_files
92
91
  EM.run do
93
92
  @admin = EM.start_unix_domain_server(socket_file, Tkellem::SocketServer)
94
93
  Tkellem::TkellemServer.new
@@ -103,6 +102,7 @@ class Tkellem::Daemon
103
102
  Process.setsid
104
103
  exit if fork
105
104
  @daemon = true
105
+ remove_files
106
106
  File.open(pid_file, 'wb') { |f| f.write(Process.pid.to_s) }
107
107
 
108
108
  STDIN.reopen("/dev/null")
@@ -78,10 +78,15 @@ class IrcMessage < Struct.new(:prefix, :command, :args, :ctcp)
78
78
  end
79
79
 
80
80
  def with_timestamp(timestamp)
81
+ if timestamp <= 24.hours.ago
82
+ timestring = timestamp.strftime("%Y-%m-%d %H:%M:%S")
83
+ else
84
+ timestring = timestamp.strftime("%H:%M:%S")
85
+ end
81
86
  args = self.args
82
87
  if args && args[-1]
83
88
  args = args.dup
84
- args[-1] = "#{timestamp.strftime("%H:%M:%S")}> #{args[-1]}"
89
+ args[-1] = "#{timestring}> #{args[-1]}"
85
90
  end
86
91
  IrcMessage.new(prefix, command, args, ctcp)
87
92
  end
@@ -95,7 +95,10 @@ class Backlog
95
95
 
96
96
  def get_stream(ctx, for_reading = false)
97
97
  mode = for_reading ? 'rb' : 'ab'
98
- stream_path(ctx).open(mode) do |stream|
98
+ ctx = ctx.gsub(%r{[\./\\]}, '')
99
+ path = stream_path(ctx)
100
+ return unless path.file?
101
+ path.open(mode) do |stream|
99
102
  if !for_reading
100
103
  stream.seek(0, IO::SEEK_END)
101
104
  end
@@ -186,7 +189,12 @@ class Backlog
186
189
  contexts.each do |ctx_name|
187
190
  get_stream(ctx_name, true) do |stream|
188
191
  last_line_len = 0
189
- BackwardsFileReader.scan(stream) { |line| last_line_len = line.length; Time.parse(line[0,19]) >= start_time }
192
+ BackwardsFileReader.scan(stream) do |line|
193
+ # remember this last line length so we can scan past it
194
+ last_line_len = line.length
195
+ timestamp = Time.parse(line[0,19]) rescue nil
196
+ !timestamp || timestamp >= start_time
197
+ end
190
198
  stream.seek(last_line_len, IO::SEEK_CUR)
191
199
  send_backlog(conn, ctx_name, stream)
192
200
  end
@@ -252,8 +260,10 @@ class BacklogCommand < TkellemBot::Command
252
260
  end
253
261
 
254
262
  def execute
255
- hours = args.pop.to_f
256
- hours = 1 if hours <= 0 || hours >= (24*31)
263
+ hour_str = args.pop
264
+ hours = hour_str.to_f
265
+ hours *= 24 if hour_str && hour_str[-1] == 'd'[-1]
266
+ hours = 1 if hours <= 0 || hours >= (24*365)
257
267
  cutoff = hours.hours.ago
258
268
  backlog = Backlog.get_instance(bouncer)
259
269
  rooms = [args.pop].compact
@@ -1,3 +1,3 @@
1
1
  module Tkellem
2
- VERSION = "0.9.0.beta6"
2
+ VERSION = "0.9.0.beta7"
3
3
  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.0.beta6
4
+ version: 0.9.0.beta7
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -179,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  segments:
181
181
  - 0
182
- hash: -3227479256214669237
182
+ hash: 3003758682723293778
183
183
  required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  none: false
185
185
  requirements: