skype 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ede6c4cab33484aaf2f5f269c346e5ac7c4bb069
4
- data.tar.gz: 649f35174cfeaa41a7702b4b663b5f21370433fb
3
+ metadata.gz: e1715eeb6270ab42387b2f16b396ff8d3216d690
4
+ data.tar.gz: 56e7b9d58ba245b15729de2cd2b22af2c929c0a4
5
5
  SHA512:
6
- metadata.gz: c382139f8baeb26b1e7e41948c5a74bdf551a04f335349ac7a3471b8aa720bc72d147b4b7f5fee14748650fd00a17c0f460a804e7eccdf12bb5d1d04a6ec73a8
7
- data.tar.gz: b0fe574de19ead18aa875759fe31f0dcd4486ac428d52139c3d31c8ee5a9864cc9426785ae9650c7e9c7d2e6cd7d8ae99e4b25992fab1ea3cf49b9d2b2525984
6
+ metadata.gz: db905f810d96b25eb01234c732ebcfe1e93e8bef311e0528690fedd7c372da17038d44ee7e1d2904b194d1bedc98926a36bdc2a00c9b500a1606b95f86b6b5c1
7
+ data.tar.gz: ba1ac32a63d698a197586f71d96768c1245ee0d7b053e43a77f6f4f6ad876bd6f98f4f1191dd96fa0d62f4cee48b80caa0d58c12f7e486e92ffd9a184db9fb1c
@@ -1,3 +1,7 @@
1
+ === 0.1.0 2013-06-27
2
+
3
+ * add Chat API
4
+
1
5
  === 0.0.3 2013-06-20
2
6
 
3
7
  * give up choose dbus/applescript in gemspec
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
- ### send message
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
- ### call
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
- ### get recent chat list
66
+ post message to the chat
49
67
  ```ruby
50
- puts Skype.search("recentchats")
68
+ chat.post "hello chat!!"
51
69
  ```
52
70
 
53
- ### send message to group chat
71
+ show chat messages
54
72
  ```ruby
55
- Skype.chatmessage "#name1/name2;$a1b2cdef3456", "hello chat!!"
73
+ chat.messages.each do |m|
74
+ puts m
75
+ end
56
76
  ```
57
77
 
58
78
  Samples
File without changes
@@ -1,7 +1,18 @@
1
1
  require "rubygems"
2
+ require "kconv"
3
+ require "tmp_cache"
2
4
 
3
5
  require "skype/version"
4
- require "skype/skype"
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
@@ -1,10 +1,3 @@
1
- require case RUBY_PLATFORM
2
- when /darwin/
3
- "skype/platforms/mac"
4
- when /linux/
5
- "skype/platforms/linux"
6
- end
7
-
8
1
  module Skype
9
2
  @@config = {:app_name => "ruby-skype"}
10
3
  def self.config(conf=nil)
@@ -1,3 +1,3 @@
1
1
  module Skype
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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
@@ -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
@@ -3,4 +3,6 @@ require 'rubygems'
3
3
  $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
4
4
  require 'skype'
5
5
 
6
- p Skype.message "shokaishokai", "hello"
6
+ user = ARGV.shift || "shokaishokai"
7
+ msg = ARGV.shift || "hello"
8
+ p Skype.message user, msg
@@ -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.3
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-19 00:00:00.000000000 Z
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/send_groupchat.rb
76
+ - samples/chat.rb
61
77
  - samples/send_message.rb
62
78
  - skype.gemspec
63
79
  homepage: https://github.com/shokai/skype-ruby