colloquy_log_to_text 1.1.6 → 1.2
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.
@@ -1,7 +1,11 @@
|
|
1
1
|
class ColloquyLogToText
|
2
2
|
def self.convert(file)
|
3
|
-
if !
|
3
|
+
if !File.exists?(file)
|
4
|
+
puts "Error: File does not exist."
|
5
|
+
exit 1
|
6
|
+
elsif !file.match(/(.+)\.colloquyTranscript$/)
|
4
7
|
puts "Error: File is not a Colloquy log."
|
8
|
+
exit 1
|
5
9
|
end
|
6
10
|
puts "Converting #{file}..."
|
7
11
|
f = File.open(file)
|
@@ -10,13 +14,6 @@ class ColloquyLogToText
|
|
10
14
|
f = File.open(file.gsub(".colloquyTranscript", ".txt"), "w")
|
11
15
|
envelopes = doc.css("envelope")
|
12
16
|
envelopes.each { |envelope|
|
13
|
-
messages = envelope.css("message")
|
14
|
-
messages.each { |message|
|
15
|
-
@printed_message = message.content
|
16
|
-
@timestamp_string = message.attr("received")
|
17
|
-
@timestamp = DateTime.strptime(@timestamp_string, "%F %H:%M:%S")
|
18
|
-
@is_action = message.attr("action")
|
19
|
-
}
|
20
17
|
senders = envelope.css("sender")
|
21
18
|
senders.each { |sender|
|
22
19
|
@nick = sender.content
|
@@ -31,11 +28,18 @@ class ColloquyLogToText
|
|
31
28
|
@class = "&"
|
32
29
|
end
|
33
30
|
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
messages = envelope.css("message")
|
32
|
+
messages.each { |message|
|
33
|
+
@printed_message = message.content
|
34
|
+
@timestamp_string = message.attr("received")
|
35
|
+
@timestamp = DateTime.strptime(@timestamp_string, "%F %H:%M:%S")
|
36
|
+
@is_action = message.attr("action")
|
37
|
+
if @is_action == "yes"
|
38
|
+
f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] * #{@nick} #{@printed_message}"
|
39
|
+
else
|
40
|
+
f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] <#{@class}#{@nick}> #{@printed_message}"
|
41
|
+
end
|
42
|
+
}
|
39
43
|
}
|
40
44
|
end
|
41
45
|
end
|