skyper 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.
- data/.gitignore +18 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +16 -0
- data/LICENSE +22 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/lib/skyper.rb +8 -0
- data/lib/skyper/call.rb +50 -0
- data/lib/skyper/chat.rb +42 -0
- data/lib/skyper/chat_message.rb +7 -0
- data/lib/skyper/group.rb +31 -0
- data/lib/skyper/iam.rb +18 -0
- data/lib/skyper/platform/mac.rb +26 -0
- data/lib/skyper/profile.rb +9 -0
- data/lib/skyper/skype.rb +95 -0
- data/lib/skyper/skype_error.rb +4 -0
- data/lib/skyper/skype_object.rb +133 -0
- data/lib/skyper/sms.rb +21 -0
- data/lib/skyper/user.rb +15 -0
- data/lib/skyper/version.rb +3 -0
- data/skyper.gemspec +18 -0
- metadata +83 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Andriy Dmytrenko
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Skyper
|
2
|
+
|
3
|
+
A ruby gem, implementing Skype public API.
|
4
|
+
https://developer.skype.com/public-api-reference
|
5
|
+
|
6
|
+
Currently works only on MacOS X, using AppleScript to connect to Skype.
|
7
|
+
Inspired by rb-skypemac.
|
8
|
+
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'skyper'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install skyper
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
TODO: Write usage instructions here
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/skyper.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
$:.unshift File.expand_path('../',__FILE__)
|
2
|
+
module Skyper
|
3
|
+
autoload :SkypeObject, 'skyper/skype_object'
|
4
|
+
autoload :User, 'skyper/user'
|
5
|
+
autoload :Chat, 'skyper/chat'
|
6
|
+
autoload :Group, 'skyper/group'
|
7
|
+
end
|
8
|
+
Dir[File.join(File.dirname(__FILE__), 'skyper/**/*.rb')].sort.each { |lib| require lib }
|
data/lib/skyper/call.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
module Skyper
|
2
|
+
# Represents a Skype call. Developer is responsible for calling Call#hangup at the end of each call, whether it was placed
|
3
|
+
# by the caller or is an answered call.
|
4
|
+
class Call < SkypeObject
|
5
|
+
property_reader :TIMESTAMP => Time, :PARTNER_HANDLE => Skyper::User, :RATE => Integer
|
6
|
+
property_reader *%w[PARTNER_DISPNAME TARGET_IDENTITY CONF_ID TYPE STATUS VIDEO_STATUS VIDEO_SEND_STATUS FAILUREREASON SUBJECT
|
7
|
+
PSTN_NUMBER DURATION PSTN_STATUS CONF_PARTICIPANTS_COUNT VM_DURATION VM_ALLOWED_DURATION RATE_CURRENCY RATE_PRECISION INPUT OUTPUT CAPTURE_MIC VAA_INPUT_STATUS
|
8
|
+
FORWARDED_BY TRANSFER_ACTIVE TRANSFER_STATUS TRANSFERRED_BY TRANSFERRED_TO]
|
9
|
+
self.object_name = "CALL"
|
10
|
+
class << self
|
11
|
+
def active_call_ids
|
12
|
+
r = Skype.send_command "SEARCH ACTIVECALLS"
|
13
|
+
r.gsub(/CALLS /, "").split(", ")
|
14
|
+
end
|
15
|
+
|
16
|
+
def active_calls
|
17
|
+
Call.active_call_ids.map { |id| Call.new id unless id == "COMMAND_PENDING"}
|
18
|
+
end
|
19
|
+
|
20
|
+
def create(*users)
|
21
|
+
user_handles = users.map { |u| (u.is_a? User) ? u.handle : u }
|
22
|
+
status = Skype.send_command "CALL #{user_handles.join(', ')}"
|
23
|
+
if status =~ /CALL (\d+) STATUS/
|
24
|
+
call = Call.new($1)
|
25
|
+
else
|
26
|
+
raise RuntimeError.new("Call failed. Skype returned '#{status}'")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Attempts to hang up a call. <b>Note</b>: If Skype hangs while placing the call, this method could hang indefinitely.
|
32
|
+
# <u>Use Skype#Call instead of this method unless you like memory leaks</u>.
|
33
|
+
# Raises SkypeError if an error is reported from the Skype API
|
34
|
+
def hangup
|
35
|
+
self.status = "FINISHED"
|
36
|
+
end
|
37
|
+
|
38
|
+
def send_video(toggle_flag)
|
39
|
+
alter("#{bool_to_flag(toggle_flag)}_VIDEO_SEND")
|
40
|
+
end
|
41
|
+
|
42
|
+
def rcv_video(toggle_flag)
|
43
|
+
alter("#{bool_to_flag(toggle_flag)}_VIDEO_RECEIVE")
|
44
|
+
end
|
45
|
+
protected
|
46
|
+
def bool_to_flag(bool)
|
47
|
+
bool ? "START" : "STOP"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/skyper/chat.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Skyper
|
2
|
+
class Chat < SkypeObject
|
3
|
+
property_accessor *%w[NAME TIMESTAMP ADDER POSTERS TOPIC TOPICXML ACTIVEMEMBERS FRIENDLYNAME BOOKMARKED MEMBEROBJECTS PASSWORDHINT GUIDELINES
|
4
|
+
OPTIONS DESCRIPTION DIALOG_PARTNER ACTIVITY_TIMESTAMP TYPE MYSTATUS MYROLE BLOB APPLICANTS]
|
5
|
+
property_reader :RECENTCHATMESSAGES => Array
|
6
|
+
property_reader :STATUS, :MEMBERS, :CHATMESSAGES
|
7
|
+
self.object_name = "CHAT"
|
8
|
+
attr_reader :id
|
9
|
+
|
10
|
+
class << self
|
11
|
+
# create by user_handle
|
12
|
+
def create(user_handle)
|
13
|
+
r = Skype.send_command "CHAT CREATE #{user_handle}"
|
14
|
+
Chat.parse_from r
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns an array of your Skype recent chats
|
18
|
+
def recent_chats
|
19
|
+
r = Skype.send_command "SEARCH RECENTCHATS"
|
20
|
+
chat_ids = parse_type(r.sub(/^CHATS\s+/, ""), Array)
|
21
|
+
chat_ids.map do |id|
|
22
|
+
Chat.new(id)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# chat message to chat
|
28
|
+
def chat_message(message)
|
29
|
+
r = Skype.send_command "CHATMESSAGE #{id} #{message}"
|
30
|
+
ChatMessage.parse_from(r)
|
31
|
+
end
|
32
|
+
|
33
|
+
def recent_chat_messages
|
34
|
+
self.recentchatmessages.map {|id| ChatMessage.new(id)}
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_topic(topic)
|
38
|
+
alter('SETTOPIC', topic)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
module Skyper
|
2
|
+
class ChatMessage < Skyper::SkypeObject
|
3
|
+
property_accessor :BODY, :FROM_DISPNAME, :TYPE, :STATUS, :LEAVEREASON, :CHATNAME, :IS_EDITABLE, :EDITED_BY, :EDITED_TIMESTAMP, :OPTIONS, :ROLE
|
4
|
+
property_reader :TIMESTAMP => Time, :FROM_HANDLE => Skyper::User, :USERS => Array
|
5
|
+
self.object_name = "CHATMESSAGE"
|
6
|
+
end
|
7
|
+
end
|
data/lib/skyper/group.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Skyper
|
2
|
+
class Group < SkypeObject
|
3
|
+
#TYPE: {ALL | CUSTOM | HARDWIRED | SHARED_GROUP | PROPOSED_SHARED_GROUP}
|
4
|
+
property_reader :TYPE, :CUSTOM_GROUP_ID, :NROFUSERS, :NROFUSERS_ONLINE, :USERS
|
5
|
+
property_accessor :DISPLAYNAME
|
6
|
+
self.object_name = "GROUP"
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# Returns hash of symols (group types) => Group objects
|
10
|
+
def groups
|
11
|
+
r = Skype.send_command "SEARCH GROUPS ALL"
|
12
|
+
r.gsub!(/^\D+/, "")
|
13
|
+
group_ids = r.split /,\s*/
|
14
|
+
group_ids.map do |id|
|
15
|
+
Group.new(id)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Returns array of skype names of users in this group
|
21
|
+
def member_user_names
|
22
|
+
r = users
|
23
|
+
r && r.sub(/^.*USERS /, "").split(", ") or []
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns array of Users in this Group
|
27
|
+
def user_objects
|
28
|
+
member_user_names.map { |h| User.new h }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/skyper/iam.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Skyper
|
2
|
+
|
3
|
+
# Singleton for managing Skype user status
|
4
|
+
class Iam
|
5
|
+
@@STATUSES = [:ONLINE, :OFFLINE, :SKYPEME, :AWAY, :NA, :DND, :INVISIBLE]
|
6
|
+
|
7
|
+
def Iam.set_user_status(status)
|
8
|
+
raise NoMethodError.new("#{status} in #{Iam.to_s}") if not @@STATUSES.index status.upcase.to_sym
|
9
|
+
Skype.send_command "SET USERSTATUS #{status}"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Handles all of the user status permutations accepted by Skype otherwise Errors.
|
13
|
+
# For example, <i>Iam.away</i> is legal.
|
14
|
+
def Iam.method_missing(id)
|
15
|
+
Iam.set_user_status(id.id2name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Skyper
|
2
|
+
module Mac
|
3
|
+
class Connection
|
4
|
+
attr_accessor :logger
|
5
|
+
attr_reader :options
|
6
|
+
|
7
|
+
def initialize(options={})
|
8
|
+
@options = options
|
9
|
+
@logger ||= Logger.new(STDOUT).tap do |logger|
|
10
|
+
logger.level = Logger::ERROR
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param[String] command Skype command
|
15
|
+
def send_command(command)
|
16
|
+
params = {:script_name => options[:script_name].to_s, :command => command}
|
17
|
+
logger.debug "#{self.class}##{__method__} params: #{params.inspect}"
|
18
|
+
response = Appscript::app('Skype').send_ params
|
19
|
+
response.tap do
|
20
|
+
logger.debug "#{self.class}##{__method__} response: #{response}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Skyper
|
2
|
+
class Profile < SkypeObject
|
3
|
+
property_reader *%w[PSTN_BALANCE PSTN_BALANCE_CURRENCY SMS_VALIDATED_NUMBERS]
|
4
|
+
property_accessor *%w[FULLNAME SEX LANGUAGES COUNTRY IPCOUNTRY PROVINCE CITY PHONE_HOME PHONE_OFFICE PHONE_MOBILE HOMEPAGE ABOUT MOOD_TEXT RICH_MOOD_TEXT TIMEZONE
|
5
|
+
CALL_APPLY_CF CALL_NOANSWER_TIMEOUT CALL_FORWARD_RULES CALL_SEND_TO_VM]
|
6
|
+
property_accessor :BIRTHDAY => Time
|
7
|
+
self.object_name = "PROFILE"
|
8
|
+
end
|
9
|
+
end
|
data/lib/skyper/skype.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'appscript'
|
2
|
+
require 'logger'
|
3
|
+
require 'singleton'
|
4
|
+
require 'forwardable'
|
5
|
+
|
6
|
+
module Skyper
|
7
|
+
|
8
|
+
# Singleton for interfacing with Skype
|
9
|
+
class Skype
|
10
|
+
include Singleton
|
11
|
+
attr_accessor :script_name
|
12
|
+
attr_reader :connection
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@connection = Skyper::Mac::Connection.new
|
16
|
+
send_command("PROTOCOL 8")
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param[String] command Skype command
|
20
|
+
def send_command(command)
|
21
|
+
@connection.send_command(command)
|
22
|
+
end
|
23
|
+
|
24
|
+
def profile
|
25
|
+
@profile ||= Profile.new(nil)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Initiates a Skype call
|
29
|
+
def call(*users)
|
30
|
+
Call.create(*users)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns an Array of Call IDs if there is an incoming Skype call otherwise nil
|
34
|
+
def incoming_calls
|
35
|
+
Call.active_calls
|
36
|
+
end
|
37
|
+
|
38
|
+
# Answers a call given a skype Call ID. Returns an Array of Call objects.
|
39
|
+
def answer(call)
|
40
|
+
cmd = "ALTER CALL #{call.call_id} ANSWER"
|
41
|
+
r = Skype.send_command cmd
|
42
|
+
raise RuntimeError("Failed to answer call. Skype returned '#{r}'") unless r == cmd
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns an Array of Group
|
46
|
+
def groups
|
47
|
+
@groups ||= Group.groups
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns Array of all User in a particular Group type. Accepts types as defined by Group.types
|
51
|
+
def find_users_of_type(group_type)
|
52
|
+
groups.find { |g| g.type == group_type}.users
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns an array of users online friends as User objects
|
56
|
+
def online_friends
|
57
|
+
find_users_of_type "ONLINE_FRIENDS"
|
58
|
+
end
|
59
|
+
|
60
|
+
# Array of all User that are friends of the current user
|
61
|
+
def all_friends
|
62
|
+
find_users_of_type "ALL_FRIENDS"
|
63
|
+
end
|
64
|
+
|
65
|
+
# Array of all User defined as Skype Out users
|
66
|
+
def skypeout_friends
|
67
|
+
find_users_of_type "SKYPEOUT_FRIENDS"
|
68
|
+
end
|
69
|
+
|
70
|
+
# Array of all User that the user knows
|
71
|
+
def all_users
|
72
|
+
find_users_of_type "ALL_USERS"
|
73
|
+
end
|
74
|
+
|
75
|
+
# Array of User recently contacted by the user, friends or not
|
76
|
+
def recently_contacted_users
|
77
|
+
find_users_of_type "RECENTLY_CONTACTED_USERS"
|
78
|
+
end
|
79
|
+
|
80
|
+
# Array of User waiting for authorization
|
81
|
+
def users_waiting_for_authorization
|
82
|
+
find_users_of_type "USERS_WAITING_MY_AUTHORIZATION"
|
83
|
+
end
|
84
|
+
|
85
|
+
# Array of User blocked
|
86
|
+
def blocked_users
|
87
|
+
find_users_of_type "USERS_BLOCKED_BY_ME"
|
88
|
+
end
|
89
|
+
class << self
|
90
|
+
extend Forwardable
|
91
|
+
def_delegators :instance, *Skyper::Skype.instance_methods(false)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
module Skyper
|
2
|
+
# Represents skype object with id and properties, such as:
|
3
|
+
# USER, PROFILE, CALL, CHATMESSAGE, CHAT, etc.
|
4
|
+
# see: https://developer.skype.com/public-api-reference#OBJECTS
|
5
|
+
class SkypeObject
|
6
|
+
attr_reader :id
|
7
|
+
|
8
|
+
# @param[Object] id Integer or String
|
9
|
+
def initialize(id)
|
10
|
+
@id = id
|
11
|
+
end
|
12
|
+
|
13
|
+
# Invokes GET command for a given object, with id and property
|
14
|
+
# @param[String] property Property to retreive
|
15
|
+
def get_property(property)
|
16
|
+
cmd = ["GET", self.class.object_name, id, property].compact.join(" ")
|
17
|
+
response = Skyper::Skype.send_command(cmd)
|
18
|
+
raise Skyper::SkypeError, response if response =~ /ERROR/
|
19
|
+
reply = %r/(#{self.class.object_name})\s+([\S]+)?\s*(#{property})\s+(.*)/.match(response)
|
20
|
+
reply && reply[4]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Invokes SET command for a given object with id, property and value
|
24
|
+
# @param[String] property Property to be set
|
25
|
+
# @param[String] value Property value
|
26
|
+
def set_property(property, value)
|
27
|
+
cmd = ["SET",self.class.object_name, id, property, value].compact.join(" ")
|
28
|
+
Skyper::Skype.send_command(cmd)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Invokes ALTER command for an object
|
32
|
+
# @param[String] command Command to be sent
|
33
|
+
# @param[String] args (optional) Arguments for a command
|
34
|
+
# @example usage:
|
35
|
+
# sms = Skyper::SMS.create("+380998887766")
|
36
|
+
# sms.body = "Test"
|
37
|
+
# sms.alter("SEND")
|
38
|
+
def alter(command, args=nil)
|
39
|
+
cmd = "#{command} #{args}".strip
|
40
|
+
Skyper::Skype.send_command("ALTER #{self.class.object_name} #{id} #{cmd}")
|
41
|
+
end
|
42
|
+
|
43
|
+
def ==(other)
|
44
|
+
@id == other.id
|
45
|
+
end
|
46
|
+
|
47
|
+
class << self
|
48
|
+
|
49
|
+
# Defines Skype object name.
|
50
|
+
# see https://developer.skype.com/public-api-reference#OBJECTS
|
51
|
+
# @param[String] name Object name, usually in UPCASE
|
52
|
+
def object_name=(name)
|
53
|
+
@object_name = name
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns object name, which class represents
|
57
|
+
# @return[String] object_name
|
58
|
+
def object_name
|
59
|
+
@object_name
|
60
|
+
end
|
61
|
+
|
62
|
+
# Defines rw property for an object
|
63
|
+
# @param[Symbol,..] props Properties
|
64
|
+
def property_accessor(*props)
|
65
|
+
property_reader(*props)
|
66
|
+
property_writer(*props)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Defines write-only property for an object
|
70
|
+
def property_writer(*props)
|
71
|
+
opts = extract_options!(props)
|
72
|
+
opts.each do |prop,type|
|
73
|
+
define_method(:"#{prop.downcase}=") do |value|
|
74
|
+
set_property(prop, value)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
# Defines read-only property for an object
|
79
|
+
def property_reader(*props)
|
80
|
+
opts = extract_options!(props)
|
81
|
+
opts.each do |prop,type|
|
82
|
+
define_method(prop.downcase) do
|
83
|
+
self.class.parse_type get_property(prop), type
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Parses object_id from a response and creates a new object with that ID.
|
89
|
+
# @param[String] response Response from Skype
|
90
|
+
# @example usage:
|
91
|
+
# Skyper::SMS.parse_from 'SMS 3025 STATUS COMPOSING'
|
92
|
+
# => #<Skyper::SMS:0x007ff24b1194b0 @id=3025>
|
93
|
+
def parse_from(response)
|
94
|
+
match_data = response.match %r/^#{@object_name} ([^\ ]+)/
|
95
|
+
raise SkypeError, "Can not parse response: '#{response}'" unless match_data
|
96
|
+
self.new(match_data[1])
|
97
|
+
end
|
98
|
+
|
99
|
+
def parse_type(value, type)
|
100
|
+
return value unless value && type
|
101
|
+
return type.call(value) if type.is_a? Proc
|
102
|
+
case type.to_s
|
103
|
+
when "Integer" || "Fixnum"
|
104
|
+
value.to_i
|
105
|
+
when "Array"
|
106
|
+
value.split(/,\s*/)
|
107
|
+
when "Time"
|
108
|
+
Time.at(value.to_i)
|
109
|
+
when "bool"
|
110
|
+
value == "TRUE"
|
111
|
+
else
|
112
|
+
if type.superclass == Skyper::SkypeObject
|
113
|
+
type.new(value)
|
114
|
+
else
|
115
|
+
value
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
protected
|
121
|
+
def extract_options!(array)
|
122
|
+
opts = if array.last.is_a? Hash
|
123
|
+
array.pop
|
124
|
+
else
|
125
|
+
{}
|
126
|
+
end
|
127
|
+
opts.merge! Hash[array.zip(Array.new(array.size))]
|
128
|
+
end
|
129
|
+
|
130
|
+
end # class << self
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
data/lib/skyper/sms.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Skyper
|
2
|
+
class SMS < SkypeObject
|
3
|
+
property_accessor *%w[BODY TYPE REPLY_TO_NUMBER TARGET_NUMBERS]
|
4
|
+
property_reader *%w[STATUS FAILUREREASON IS_FAILED_UNSEEN PRICE_CURRENCY TARGET_STATUSES]
|
5
|
+
property_reader :TIMESTAMP => Time, :PRICE => Integer, :PRICE_PERICISION => Integer
|
6
|
+
self.object_name = "SMS"
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# @params [Symbol] type one of following: OUTGOING CONFIRMATION_CODE_REQUEST CONFIRMATION_CODE_SUBMIT
|
10
|
+
def create(target, type=:OUTGOING)
|
11
|
+
r = Skyper::Skype.send_command("CREATE SMS #{type.to_s.upcase} #{target}") #"SMS 354924 STATUS COMPOSING"
|
12
|
+
self.parse_from(r)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def send_sms
|
17
|
+
alter("SEND")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/skyper/user.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Skyper
|
2
|
+
class User < SkypeObject
|
3
|
+
property_reader :IS_VIDEO_CAPABLE => :bool, :IS_VOICEMAIL_CAPABLE => :bool, :IS_CF_ACTIVE => :bool, :HASCALLEQUIPMENT => :bool, :LASTONLINETIMESTAMP => Time
|
4
|
+
property_reader *%w[HANDLE FULLNAME BIRTHDAY SEX LANGUAGE COUNTRY PROVINCE CITY PHONE_HOME PHONE_OFFICE PHONE_MOBILE HOMEPAGE ABOUT
|
5
|
+
ONLINESTATUS SkypeOut SKYPEME CAN_LEAVE_VM RECEIVEDAUTHREQUEST MOOD_TEXT
|
6
|
+
RICH_MOOD_TEXT ALIASES TIMEZONE NROF_AUTHED_BUDDIES]
|
7
|
+
property_accessor *%w[BUDDYSTATUS ISBLOCKED ISAUTHORIZED SPEEDDIAL DISPLAYNAME]
|
8
|
+
self.object_name = "USER"
|
9
|
+
|
10
|
+
def chat
|
11
|
+
Chat.create id
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
data/skyper.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/skyper/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Andriy Dmytrenko"]
|
6
|
+
gem.email = ["refresh.xss@gmail.com"]
|
7
|
+
gem.description = %q{Ruby interface to Skype on Mac OS X}
|
8
|
+
gem.summary = %q{Ruby interface to Skype on Mac OS X}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "skyper"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Skyper::VERSION
|
17
|
+
gem.add_runtime_dependency 'rb-appscript', '>=0.3.0'
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skyper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andriy Dmytrenko
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rb-appscript
|
16
|
+
requirement: &70156233682640 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.3.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70156233682640
|
25
|
+
description: Ruby interface to Skype on Mac OS X
|
26
|
+
email:
|
27
|
+
- refresh.xss@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- Gemfile.lock
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- lib/skyper.rb
|
39
|
+
- lib/skyper/call.rb
|
40
|
+
- lib/skyper/chat.rb
|
41
|
+
- lib/skyper/chat_message.rb
|
42
|
+
- lib/skyper/group.rb
|
43
|
+
- lib/skyper/iam.rb
|
44
|
+
- lib/skyper/platform/mac.rb
|
45
|
+
- lib/skyper/profile.rb
|
46
|
+
- lib/skyper/skype.rb
|
47
|
+
- lib/skyper/skype_error.rb
|
48
|
+
- lib/skyper/skype_object.rb
|
49
|
+
- lib/skyper/sms.rb
|
50
|
+
- lib/skyper/user.rb
|
51
|
+
- lib/skyper/version.rb
|
52
|
+
- skyper.gemspec
|
53
|
+
homepage: ''
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
hash: -3050657956737270811
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
hash: -3050657956737270811
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.8.11
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Ruby interface to Skype on Mac OS X
|
83
|
+
test_files: []
|