skype 0.0.3 → 0.1.0
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.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/README.md +26 -6
- data/{samples/send_groupchat.rb → chat.rb} +0 -0
- data/lib/skype.rb +12 -1
- data/lib/skype/{skype.rb → main.rb} +0 -7
- data/lib/skype/version.rb +1 -1
- data/lib/skype/wrappers/chat.rb +52 -0
- data/samples/chat.rb +16 -0
- data/samples/send_message.rb +3 -1
- data/skype.gemspec +2 -0
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1715eeb6270ab42387b2f16b396ff8d3216d690
|
4
|
+
data.tar.gz: 56e7b9d58ba245b15729de2cd2b22af2c929c0a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db905f810d96b25eb01234c732ebcfe1e93e8bef311e0528690fedd7c372da17038d44ee7e1d2904b194d1bedc98926a36bdc2a00c9b500a1606b95f86b6b5c1
|
7
|
+
data.tar.gz: ba1ac32a63d698a197586f71d96768c1245ee0d7b053e43a77f6f4f6ad876bd6f98f4f1191dd96fa0d62f4cee48b80caa0d58c12f7e486e92ffd9a184db9fb1c
|
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -23,6 +23,13 @@ for Linux
|
|
23
23
|
|
24
24
|
% gem install skype ruby-dbus
|
25
25
|
|
26
|
+
Gemfile
|
27
|
+
```ruby
|
28
|
+
gem "skype"
|
29
|
+
gem "rb-appscript" if RUBY_PLATFORM =~ /darwin/i
|
30
|
+
gem "ruby-dbus" if RUBY_PLATFORM =~ /linux/i
|
31
|
+
```
|
32
|
+
|
26
33
|
Usage
|
27
34
|
-----
|
28
35
|
please read [API Reference](http://dev.skype.com/desktop-api-reference) before use.
|
@@ -35,24 +42,37 @@ require 'skype'
|
|
35
42
|
Skype.config :app_name => "my_skype_app"
|
36
43
|
```
|
37
44
|
|
38
|
-
###
|
45
|
+
### Skype API
|
46
|
+
|
47
|
+
send message
|
39
48
|
```ruby
|
40
49
|
Skype.message "USER_NAME", "hello!!"
|
50
|
+
Skype.exec "MESSAGE USER_NAME hello!!"
|
41
51
|
```
|
42
52
|
|
43
|
-
|
53
|
+
call
|
44
54
|
```ruby
|
45
55
|
Skype.call "USER_NAME"
|
56
|
+
Skype.exec "CALL USER_NAME"
|
57
|
+
```
|
58
|
+
|
59
|
+
### Chat API
|
60
|
+
|
61
|
+
find a chat
|
62
|
+
```ruby
|
63
|
+
chat = Skype.chats.find{|c| c.members.include? "shokaishokai" and c.topic =~ /testchat/ }
|
46
64
|
```
|
47
65
|
|
48
|
-
|
66
|
+
post message to the chat
|
49
67
|
```ruby
|
50
|
-
|
68
|
+
chat.post "hello chat!!"
|
51
69
|
```
|
52
70
|
|
53
|
-
|
71
|
+
show chat messages
|
54
72
|
```ruby
|
55
|
-
|
73
|
+
chat.messages.each do |m|
|
74
|
+
puts m
|
75
|
+
end
|
56
76
|
```
|
57
77
|
|
58
78
|
Samples
|
File without changes
|
data/lib/skype.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
require "rubygems"
|
2
|
+
require "kconv"
|
3
|
+
require "tmp_cache"
|
2
4
|
|
3
5
|
require "skype/version"
|
4
|
-
require
|
6
|
+
require case RUBY_PLATFORM
|
7
|
+
when /darwin/
|
8
|
+
"skype/platforms/mac"
|
9
|
+
when /linux/
|
10
|
+
"skype/platforms/linux"
|
11
|
+
else
|
12
|
+
STDERR.puts %Q{!!Skype gem cannot support your platform "#{RUBY_PLATFORM}" not support.}
|
13
|
+
end
|
14
|
+
require "skype/main"
|
15
|
+
require "skype/wrappers/chat"
|
5
16
|
|
6
17
|
module Skype
|
7
18
|
end
|
data/lib/skype/version.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
module Skype
|
2
|
+
|
3
|
+
def self.chats
|
4
|
+
search("recentchats").
|
5
|
+
scan(/(#[^\s,]+)[\s,]/).
|
6
|
+
map{|i| Chat.new i[0] }
|
7
|
+
end
|
8
|
+
|
9
|
+
class Chat
|
10
|
+
@@message_cache = TmpCache::Cache.new
|
11
|
+
|
12
|
+
attr_reader :id, :topic, :members
|
13
|
+
|
14
|
+
def initialize(id)
|
15
|
+
@id = id
|
16
|
+
@topic = ::Skype::exec("GET CHAT #{@id} TOPIC").scan(/TOPIC (.*)$/)[0][0].toutf8
|
17
|
+
@members = ::Skype::exec("GET CHAT #{@id} MEMBERS").scan(/MEMBERS (.+)$/)[0][0].split(/\s/)
|
18
|
+
end
|
19
|
+
|
20
|
+
def messages
|
21
|
+
::Skype.exec("GET CHAT #{@id} RECENTCHATMESSAGES").
|
22
|
+
split(/,? /).
|
23
|
+
select{|i| i =~ /^\d+$/ }.
|
24
|
+
map{|i| i.to_i }.
|
25
|
+
map{|i| @@message_cache.get(i) || @@message_cache.set(i, Skype::Chat::Message.new(i), 3600*72) }.
|
26
|
+
sort{|a,b| b.time <=> a.time }
|
27
|
+
end
|
28
|
+
|
29
|
+
def post(message)
|
30
|
+
::Skype.exec "CHATMESSAGE #{@id} #{message}"
|
31
|
+
end
|
32
|
+
|
33
|
+
class Message
|
34
|
+
|
35
|
+
attr_reader :id, :user, :body, :time
|
36
|
+
|
37
|
+
def initialize(id)
|
38
|
+
@id = id
|
39
|
+
@user = ::Skype.exec("GET CHATMESSAGE #{@id} from_handle").split(/\s/).last
|
40
|
+
@body = ::Skype.exec("GET CHATMESSAGE #{@id} body").scan(/^MESSAGE #{@id} BODY (.+)$/)[0][0]
|
41
|
+
@time = Time.at ::Skype.exec("GET CHATMESSAGE #{@id} timestamp").split(/\s/).last.to_i
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
"[#{@time}] <#{@user}> #{@body} "
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
data/samples/chat.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
require 'rubygems'
|
4
|
+
$:.unshift File.expand_path '../lib', File.dirname(__FILE__)
|
5
|
+
require 'skype'
|
6
|
+
|
7
|
+
chats = Skype.chats
|
8
|
+
puts "#{chats.length} chats found"
|
9
|
+
chat = chats.find{|c| c.members.include? "shokaishokai" and c.topic =~ /test/}
|
10
|
+
|
11
|
+
p chat
|
12
|
+
chat.post "test"
|
13
|
+
|
14
|
+
chat.messages.each do |m|
|
15
|
+
puts m
|
16
|
+
end
|
data/samples/send_message.rb
CHANGED
data/skype.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "tmp_cache"
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
24
|
spec.add_development_dependency "rake"
|
23
25
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skype
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Hashimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tmp_cache
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,13 +65,15 @@ files:
|
|
51
65
|
- LICENSE.txt
|
52
66
|
- README.md
|
53
67
|
- Rakefile
|
68
|
+
- chat.rb
|
54
69
|
- lib/skype.rb
|
70
|
+
- lib/skype/main.rb
|
55
71
|
- lib/skype/platforms/linux.rb
|
56
72
|
- lib/skype/platforms/mac.rb
|
57
|
-
- lib/skype/skype.rb
|
58
73
|
- lib/skype/version.rb
|
74
|
+
- lib/skype/wrappers/chat.rb
|
59
75
|
- samples/call.rb
|
60
|
-
- samples/
|
76
|
+
- samples/chat.rb
|
61
77
|
- samples/send_message.rb
|
62
78
|
- skype.gemspec
|
63
79
|
homepage: https://github.com/shokai/skype-ruby
|