tkellem 0.9.0.beta6 → 0.9.0.beta7
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/lib/tkellem/daemon.rb +1 -1
- data/lib/tkellem/irc_message.rb +6 -1
- data/lib/tkellem/plugins/backlog.rb +14 -4
- data/lib/tkellem/version.rb +1 -1
- metadata +2 -2
data/lib/tkellem/daemon.rb
CHANGED
@@ -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")
|
data/lib/tkellem/irc_message.rb
CHANGED
@@ -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] = "#{
|
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
|
-
|
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)
|
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
|
-
|
256
|
-
hours =
|
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
|
data/lib/tkellem/version.rb
CHANGED
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.
|
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:
|
182
|
+
hash: 3003758682723293778
|
183
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
184
|
none: false
|
185
185
|
requirements:
|