imessage 0.0.2 → 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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4fa9051a3ac20744feaf5430e2630d587d80964
|
4
|
+
data.tar.gz: 8aaafb2a16d83a42838ea369f61b717a6deed0a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b00e4d7697dde2ff635ae8b54fa10c233363100f756ca24d724b63552e955dc07661a19468ab364ec6761234b171f37db189341743c5943ca082b1333be110cf
|
7
|
+
data.tar.gz: f1e1b8e0db34eaf7e3e0fc9904cf3a0a29f52639d960b91b47b2df31833202d492a575ba788873bcf9334a9b1c000b063cd95f5e6a6ffd9f4e91022f3bff5cd7
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## [v0.1.0](https://github.com/linjunpop/imessage/tree/v0.1.0)
|
6
|
+
|
7
|
+
* Now imessage can send attachment with `-a`.
|
8
|
+
|
5
9
|
## [v0.0.2](https://github.com/linjunpop/imessage/tree/v0.0.2)
|
6
10
|
|
7
11
|
* Keep ruby 1.9 compatibility [@otzy007](https://github.com/otzy007) (https://github.com/linjunpop/imessage/pull/1)
|
data/bin/imessage
CHANGED
@@ -10,19 +10,29 @@ version Imessage::VERSION
|
|
10
10
|
|
11
11
|
desc 'Send iMessage'
|
12
12
|
long_desc <<-EOS
|
13
|
-
Example: $ imessage send "hello" --to "foo@example.com"
|
13
|
+
Example: $ imessage send "hello" --to "foo@example.com" --attachment 'oh.png'
|
14
14
|
EOS
|
15
15
|
|
16
16
|
command :send do |c|
|
17
17
|
c.desc 'Contacts'
|
18
18
|
c.flag [:to, :contacts], type: Array
|
19
|
+
c.flag [:a, :attachment], type: String
|
19
20
|
|
20
21
|
c.action do |global_options, options, args|
|
21
|
-
help_now!('Message is required') if args.empty?
|
22
|
+
help_now!('Message or Attachment is required') if !options[:attachment] && args.empty?
|
22
23
|
help_now!('Contacts is required') unless options[:contacts]
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
attachment = options[:attachment]
|
26
|
+
if File.exists?(attachment)
|
27
|
+
attachment = File.expand_path(attachment)
|
28
|
+
else
|
29
|
+
exit_now!("Can not find file #{attachment}")
|
30
|
+
end
|
31
|
+
|
32
|
+
sender = Imessage::Sender.new
|
33
|
+
sender.deliver(
|
34
|
+
text: args.first,
|
35
|
+
attachment: attachment,
|
26
36
|
contacts: options[:contacts]
|
27
37
|
)
|
28
38
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
on run argv
|
2
|
+
set toAddress to first item of argv
|
3
|
+
set theFilePath to second item of argv
|
4
|
+
set theFile to POSIX file theFilePath
|
5
|
+
|
6
|
+
tell application "System Events"
|
7
|
+
if exists file theFilePath then
|
8
|
+
tell application "Messages"
|
9
|
+
send theFile to buddy toAddress of (service 1 whose service type is iMessage)
|
10
|
+
end tell
|
11
|
+
else
|
12
|
+
error "File not exist."
|
13
|
+
end if
|
14
|
+
end tell
|
15
|
+
end run
|
File without changes
|
data/lib/imessage/sender.rb
CHANGED
@@ -1,9 +1,24 @@
|
|
1
1
|
module Imessage
|
2
2
|
class Sender
|
3
|
-
|
3
|
+
TYPES = [:text, :attachment]
|
4
|
+
|
5
|
+
def deliver(options = {text:nil, attachment:nil, contacts: []})
|
4
6
|
options[:contacts].each do |contact|
|
5
|
-
|
6
|
-
|
7
|
+
_deliver(options[:text], options[:attachment], contact)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def _deliver(text, attachment, contact)
|
14
|
+
unless text.nil?
|
15
|
+
apple_script_file = File.join(File.dirname(File.expand_path(__FILE__)), 'scripts/send_text.applescript')
|
16
|
+
`osascript #{apple_script_file} '#{contact}' '#{text}'`
|
17
|
+
end
|
18
|
+
|
19
|
+
unless attachment.nil?
|
20
|
+
apple_script_file = File.join(File.dirname(File.expand_path(__FILE__)), 'scripts/send_attachment.applescript')
|
21
|
+
`osascript #{apple_script_file} '#{contact}' '#{attachment}'`
|
7
22
|
end
|
8
23
|
end
|
9
24
|
end
|
data/lib/imessage/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imessage
|
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
|
- Jun Lin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,7 +85,8 @@ files:
|
|
85
85
|
- bin/imessage
|
86
86
|
- imessage.gemspec
|
87
87
|
- lib/imessage.rb
|
88
|
-
- lib/imessage/scripts/
|
88
|
+
- lib/imessage/scripts/send_attachment.applescript
|
89
|
+
- lib/imessage/scripts/send_text.applescript
|
89
90
|
- lib/imessage/sender.rb
|
90
91
|
- lib/imessage/version.rb
|
91
92
|
- spec/spec_helper.rb
|
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
110
|
version: '0'
|
110
111
|
requirements: []
|
111
112
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.4.6
|
113
114
|
signing_key:
|
114
115
|
specification_version: 4
|
115
116
|
summary: Command line tool to send iMessage.
|