skype_archive 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +21 -21
- data/bin/skype_archive +19 -11
- data/jp.co.gree.skype_archive.plist +29 -0
- data/lib/skype_archive.rb +7 -3
- data/lib/skype_archive/model.rb +20 -4
- data/lib/skype_archive/version.rb +1 -1
- data/skype_archive.gemspec +1 -0
- data/skype_archive.rb +18 -0
- data/spec/model/skype_archive_spec.rb +1 -1
- metadata +19 -1
data/README.md
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
# SkypeArchive
|
2
2
|
|
3
|
-
|
3
|
+
skype archive for gii hackathon
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
gem 'skype_archive'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install skype_archive
|
7
|
+
curl -L http://bit.ly/ONcFkw | ruby
|
18
8
|
|
19
9
|
## Usage
|
20
10
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
11
|
+
skype_archive search account_name [options] search_text
|
12
|
+
skype_archive sync
|
13
|
+
|
14
|
+
--author AUTHOR who sent the message
|
15
|
+
--conversation CONVERSATION search which channel
|
16
|
+
--from TIME search the message from when
|
17
|
+
-h, --help Show this message
|
18
|
+
|
19
|
+
## Example
|
20
|
+
|
21
|
+
skype_archive search gii.richard.huang ruby
|
22
|
+
skype_archive search gii.richard.huang --conversation Operations
|
23
|
+
ruby
|
24
|
+
skype_archive search gii.richard.huang --conversation Operations
|
25
|
+
--from "1 month ago" ruby
|
26
|
+
skype_archive search gii.richard.huang --conversation Operations
|
27
|
+
--from "1 month ago" ruby
|
28
|
+
skype_archive search gii.richard.huang --conversation Operations
|
29
|
+
--from "1 month ago" --author Jason ruby
|
data/bin/skype_archive
CHANGED
@@ -7,16 +7,20 @@ require 'optparse'
|
|
7
7
|
|
8
8
|
options = {}
|
9
9
|
OptionParser.new do |opts|
|
10
|
-
opts.banner = "Usage
|
11
|
-
skype_archive search account_name [options] search_text
|
12
|
-
skype_archive sync"
|
10
|
+
opts.banner = "Usage:
|
11
|
+
skype_archive search account_name [options] search_text
|
12
|
+
skype_archive sync\n\n"
|
13
13
|
|
14
|
-
opts.on("--
|
15
|
-
options[
|
14
|
+
opts.on("--author AUTHOR", "who sent the message") do |author|
|
15
|
+
options[:author] = author
|
16
16
|
end
|
17
17
|
|
18
|
-
opts.on("--
|
19
|
-
options[
|
18
|
+
opts.on("--conversation CONVERSATION", "search which channel") do |conversation|
|
19
|
+
options[:conversation] = conversation
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on("--from TIME", "search the message from when") do |from|
|
23
|
+
options[:from] = from
|
20
24
|
end
|
21
25
|
|
22
26
|
opts.on_tail("-h", "--help", "Show this message") do
|
@@ -34,10 +38,14 @@ else
|
|
34
38
|
if command == "search"
|
35
39
|
account_name = ARGV[1]
|
36
40
|
text = ARGV.last
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
begin
|
42
|
+
SkypeArchive.search(account_name, text, options).each do |message|
|
43
|
+
printf "[%s] %-20s: %s\n", message.created_at.strftime("%Y-%m-%d %H:%M:%S"),
|
44
|
+
message.from_dispname,
|
45
|
+
message.body_xml.gsub(text, "\e[1m\e[34m#{text}\e[0m")
|
46
|
+
end
|
47
|
+
rescue Sequel::DatabaseConnectionError
|
48
|
+
puts "did you input correct account name, see skype_archive -h" and exit
|
41
49
|
end
|
42
50
|
elsif command == "sync"
|
43
51
|
SkypeArchive.sync
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>Label</key>
|
6
|
+
<string>jp.co.gree.skype_archive</string>
|
7
|
+
|
8
|
+
<key>ProgramArguments</key>
|
9
|
+
<array>
|
10
|
+
<string>skype_archive</string>
|
11
|
+
<string>sync</string>
|
12
|
+
</array>
|
13
|
+
|
14
|
+
<key>Nice</key>
|
15
|
+
<integer>1</integer>
|
16
|
+
|
17
|
+
<key>StartInterval</key>
|
18
|
+
<integer>60</integer>
|
19
|
+
|
20
|
+
<key>RunAtLoad</key>
|
21
|
+
<true/>
|
22
|
+
|
23
|
+
<key>StandardErrorPath</key>
|
24
|
+
<string>/tmp/skype_archive.err</string>
|
25
|
+
|
26
|
+
<key>StandardOutPath</key>
|
27
|
+
<string>/tmp/skype_archive.out</string>
|
28
|
+
</dict>
|
29
|
+
</plist>
|
data/lib/skype_archive.rb
CHANGED
@@ -2,15 +2,19 @@ require "skype_archive/version"
|
|
2
2
|
require "sqlite3"
|
3
3
|
require "sequel"
|
4
4
|
require "json"
|
5
|
+
require "chronic"
|
5
6
|
|
6
7
|
module SkypeArchive
|
7
|
-
URL = "http://
|
8
|
+
URL = "http://qa1.api.openfeint.com:8088"
|
8
9
|
|
9
10
|
autoload :Model, "skype_archive/model"
|
10
11
|
autoload :Message, "skype_archive/message"
|
11
12
|
|
12
|
-
def self.search(account_name, text)
|
13
|
-
|
13
|
+
def self.search(account_name, text, options={})
|
14
|
+
if options[:from]
|
15
|
+
options[:timestamp] = Chronic.parse(options[:from]).to_i
|
16
|
+
end
|
17
|
+
Model.new(account_name).search(text, options)
|
14
18
|
end
|
15
19
|
|
16
20
|
def self.sync
|
data/lib/skype_archive/model.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require "sqlite3"
|
2
2
|
require "sequel"
|
3
|
-
require "active_support/core_ext"
|
4
3
|
require "rest_client"
|
5
4
|
require "json"
|
6
5
|
require "base64"
|
7
6
|
|
8
7
|
module SkypeArchive
|
9
8
|
class Model
|
9
|
+
LAST_SYNC_FILE = "/tmp/skype_archive_last_sync"
|
10
|
+
|
10
11
|
attr_reader :account_name
|
11
12
|
|
12
13
|
def initialize(account_name)
|
@@ -15,7 +16,7 @@ module SkypeArchive
|
|
15
16
|
|
16
17
|
def search(text, options={})
|
17
18
|
query = connection[:Messages].filter(:type => 61).filter("body_xml LIKE ?", "%#{text}%")
|
18
|
-
query = query.filter(
|
19
|
+
query = query.filter("from_dispname LIKE ?", "%#{options[:author]}%") if options[:author]
|
19
20
|
query = query.filter("timestamp > ?", options[:timestamp]) if options[:timestamp]
|
20
21
|
if options[:conversation]
|
21
22
|
convo_ids = connection[:Conversations].filter("displayname LIKE ?", "%#{options[:conversation]}%").all.map { |convo| convo[:id] }
|
@@ -26,12 +27,13 @@ module SkypeArchive
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def sync
|
29
|
-
start_time =
|
30
|
-
end_time = Time.now.
|
30
|
+
start_time = last_sync_time
|
31
|
+
end_time = Time.now.to_i
|
31
32
|
sync_contacts
|
32
33
|
sync_conversations
|
33
34
|
sync_participants
|
34
35
|
sync_messages(start_time, end_time)
|
36
|
+
update_sync_file(end_time)
|
35
37
|
end
|
36
38
|
|
37
39
|
def sync_contacts
|
@@ -70,6 +72,20 @@ module SkypeArchive
|
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
75
|
+
def last_sync_time
|
76
|
+
if File.exists?(LAST_SYNC_FILE)
|
77
|
+
File.read(LAST_SYNC_FILE).to_i
|
78
|
+
else
|
79
|
+
Time.now.to_i - 3600 * 24 * 30
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def update_sync_file(time)
|
84
|
+
File.open(LAST_SYNC_FILE, 'w') do |file|
|
85
|
+
file.puts time
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
73
89
|
private
|
74
90
|
def connection
|
75
91
|
@connection ||= Sequel.sqlite(File.expand_path("~/Library/Application\ Support/Skype/#{account_name}/main.db"))
|
data/skype_archive.gemspec
CHANGED
data/skype_archive.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
system "gem install skype_archive"
|
4
|
+
|
5
|
+
plist_path = File.expand_path("~/Library/LaunchAgents/jp.co.gree.skype_archive.plist")
|
6
|
+
if File.exists? plist_path
|
7
|
+
system "launchctl unload #{plist_path}"
|
8
|
+
end
|
9
|
+
|
10
|
+
puts "downloading jp.co.gree.skype_archive.plist..."
|
11
|
+
system "curl -o jp.co.gree.skype_archive.plist https://raw.github.com/flyerhzm/skype_archive/master/jp.co.gree.skype_archive.plist"
|
12
|
+
|
13
|
+
FileUtils.mv "jp.co.gree.skype_archive.plist", plist_path
|
14
|
+
system "launchctl setenv PATH #{ENV['PATH']}"
|
15
|
+
system "launchctl setenv GEM_PATH #{ENV['GEM_PATH']}"
|
16
|
+
system "launchctl load #{plist_path}"
|
17
|
+
|
18
|
+
puts "skype_archive installed successfully"
|
@@ -17,7 +17,7 @@ describe SkypeArchive::Model do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should search by user" do
|
20
|
-
model.search("message", :
|
20
|
+
model.search("message", :author => "Jason").should have(2).items
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should search by timestamp" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skype_archive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: chronic
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
94
110
|
- !ruby/object:Gem::Dependency
|
95
111
|
name: rspec
|
96
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,11 +169,13 @@ files:
|
|
153
169
|
- README.md
|
154
170
|
- Rakefile
|
155
171
|
- bin/skype_archive
|
172
|
+
- jp.co.gree.skype_archive.plist
|
156
173
|
- lib/skype_archive.rb
|
157
174
|
- lib/skype_archive/message.rb
|
158
175
|
- lib/skype_archive/model.rb
|
159
176
|
- lib/skype_archive/version.rb
|
160
177
|
- skype_archive.gemspec
|
178
|
+
- skype_archive.rb
|
161
179
|
- spec/model/skype_archive_spec.rb
|
162
180
|
- spec/skype_archive_spec.rb
|
163
181
|
- spec/spec_helper.rb
|