rfetion 0.3.12 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +17 -4
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/rfetion/command.rb +10 -4
- data/lib/rfetion/fetion.rb +27 -5
- data/rfetion.gemspec +3 -3
- metadata +3 -3
data/README.textile
CHANGED
@@ -31,9 +31,14 @@ send sms to friends
|
|
31
31
|
Fetion.send_sms_to_friends(mobile_no, password, friends_mobile_or_fetion_number, content)
|
32
32
|
</code></pre>
|
33
33
|
|
34
|
-
add friend
|
34
|
+
add friend with mobile
|
35
35
|
<pre><code>
|
36
|
-
Fetion.
|
36
|
+
Fetion.add_buddy_with_mobile(mobile_no, password, friend_mobile)
|
37
|
+
</code></pre>
|
38
|
+
|
39
|
+
add friend with sip
|
40
|
+
<pre><code>
|
41
|
+
Fetion.add_buddy_with_sip(mobile_no, password, friend_sip)
|
37
42
|
</code></pre>
|
38
43
|
|
39
44
|
**************************************************************************
|
@@ -44,19 +49,27 @@ you can use it in shell command directly
|
|
44
49
|
|
45
50
|
<pre><code>
|
46
51
|
Usage: rfetion [options]
|
52
|
+
|
47
53
|
Example: rfetion -m mobile -p password -f friends_mobile_or_fetion_number -c sms_content
|
48
54
|
|
49
|
-
rfetion -m mobile -p password -
|
55
|
+
rfetion -m mobile -p password --add-buddy-with-mobile friend_mobile
|
56
|
+
|
57
|
+
rfetion -m mobile -p password --add-buddy-with-sip friend_sip
|
50
58
|
|
51
59
|
-m, --mobile MOBILE Fetion mobile number
|
52
60
|
-p, --password PASSWORD Fetion password
|
53
61
|
-c, --content CONTENT Fetion message content
|
54
62
|
-f, --friends MOBILE,FETION (optional) Fetion friends mobile number or fetion number, if no friends mobile number and fetion number, send message to yourself
|
55
|
-
|
63
|
+
--add-buddy-with-mobile MOBILE
|
64
|
+
Add friend mobile as fetion friend
|
65
|
+
--add-buddy-with-sip SIP Add friend fetion sip as fetion friend
|
66
|
+
|
56
67
|
different mode:
|
57
68
|
--debug debug mode
|
58
69
|
--silence silence mode
|
70
|
+
|
59
71
|
Common options:
|
72
|
+
-v, --version Show this version
|
60
73
|
-h, --help Show this message
|
61
74
|
</code></pre>
|
62
75
|
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ Jeweler::Tasks.new do |gemspec|
|
|
6
6
|
gemspec.summary = 'rfetion is a ruby gem for China Mobile fetion service that you can send SMS free.'
|
7
7
|
gemspec.description = 'rfetion is a ruby gem for China Mobile fetion service that you can send SMS free.'
|
8
8
|
gemspec.email = 'flyerhzm@gmail.com'
|
9
|
-
gemspec.homepage = ''
|
9
|
+
gemspec.homepage = 'http://github.com/flyerhzm/rfetion'
|
10
10
|
gemspec.authors = ['Richard Huang']
|
11
11
|
gemspec.files.exclude '.gitignore'
|
12
12
|
gemspec.add_dependency 'guid', '>= 0.1.1'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.13
|
data/lib/rfetion/command.rb
CHANGED
@@ -9,7 +9,8 @@ OptionParser.new do |opts|
|
|
9
9
|
opts.separator ""
|
10
10
|
opts.separator <<-EOF
|
11
11
|
Example: rfetion -m mobile -p password -f friends_mobile_or_fetion_number -c sms_content
|
12
|
-
rfetion -m mobile -p password -
|
12
|
+
rfetion -m mobile -p password --add-buddy-with-mobile friend_mobile
|
13
|
+
rfetion -m mobile -p password --add-buddy-with-sip friend_sip
|
13
14
|
EOF
|
14
15
|
|
15
16
|
opts.on('-m', '--mobile MOBILE', 'Fetion mobile number') do |mobile|
|
@@ -29,10 +30,14 @@ OptionParser.new do |opts|
|
|
29
30
|
options[:friends] = f
|
30
31
|
end
|
31
32
|
|
32
|
-
opts.on('-
|
33
|
+
opts.on('--add-buddy-with-mobile MOBILE', 'Add friend mobile as fetion friend') do |f|
|
33
34
|
options[:add_mobile] = f
|
34
35
|
end
|
35
36
|
|
37
|
+
opts.on('--add-buddy-with-sip SIP', 'Add friend fetion sip as fetion friend') do |f|
|
38
|
+
options[:add_sip] = f
|
39
|
+
end
|
40
|
+
|
36
41
|
opts.separator ""
|
37
42
|
opts.separator "different mode:"
|
38
43
|
|
@@ -67,9 +72,10 @@ def level(options)
|
|
67
72
|
end
|
68
73
|
|
69
74
|
begin
|
70
|
-
if options[:add_mobile]
|
75
|
+
if options[:add_mobile] or options[:add_sip]
|
71
76
|
raise FetionException.new('You must input your mobile number and password') unless options[:mobile_no] and options[:password]
|
72
|
-
Fetion.
|
77
|
+
Fetion.add_buddy_with_mobile(options[:mobile_no], options[:password], options[:add_mobile], level(options)) if options[:add_mobile]
|
78
|
+
Fetion.add_buddy_with_sip(options[:mobile_no], options[:password], options[:add_sip], level(options)) if options[:add_sip]
|
73
79
|
exit
|
74
80
|
end
|
75
81
|
|
data/lib/rfetion/fetion.rb
CHANGED
@@ -55,14 +55,25 @@ class Fetion
|
|
55
55
|
fetion.logout
|
56
56
|
end
|
57
57
|
|
58
|
-
def Fetion.
|
58
|
+
def Fetion.add_buddy_with_mobile(mobile_no, password, friend_mobile, level = Logger::INFO)
|
59
59
|
fetion = Fetion.new
|
60
60
|
fetion.logger_level = level
|
61
61
|
fetion.mobile_no = mobile_no
|
62
62
|
fetion.password = password
|
63
63
|
fetion.login
|
64
64
|
fetion.register
|
65
|
-
fetion.
|
65
|
+
fetion.add_buddy_with_mobile(friend_mobile)
|
66
|
+
fetion.logout
|
67
|
+
end
|
68
|
+
|
69
|
+
def Fetion.add_buddy_with_sip(mobile_no, password, friend_sip, level = Logger::INFO)
|
70
|
+
fetion = Fetion.new
|
71
|
+
fetion.logger_level = level
|
72
|
+
fetion.mobile_no = mobile_no
|
73
|
+
fetion.password = password
|
74
|
+
fetion.login
|
75
|
+
fetion.register
|
76
|
+
fetion.add_buddy_with_sip(friend_sip)
|
66
77
|
fetion.logout
|
67
78
|
end
|
68
79
|
|
@@ -203,15 +214,26 @@ class Fetion
|
|
203
214
|
@logger.info "fetion send sms to #{to} success"
|
204
215
|
end
|
205
216
|
|
206
|
-
def
|
207
|
-
@logger.info "fetion send request to add
|
217
|
+
def add_buddy_with_mobile(mobile, nickname = nil)
|
218
|
+
@logger.info "fetion send request to add mobile:#{mobile} as friend"
|
208
219
|
arg = %Q{<args><contacts><buddies><buddy uri="tel:#{mobile}" local-name="#{nickname}" buddy-lists="1" expose-mobile-no="1" expose-name="1" /></buddies></contacts></args>}
|
209
220
|
msg = sip_create('S fetion.com.cn SIP-C/2.0', {'F' => @sid, 'I' => next_call, 'Q' => '1 S', 'N' => 'AddBuddy'}, arg) + FETION_SIPP
|
210
221
|
curl_exec(next_url, @ssic, msg)
|
211
222
|
response = curl_exec(next_url, @ssic, FETION_SIPP)
|
212
223
|
|
213
224
|
raise FetionException.new("Fetion Error: Add buddy error") unless response.is_a? Net::HTTPSuccess
|
214
|
-
@logger.info "fetion send request to add
|
225
|
+
@logger.info "fetion send request to add mobile:#{mobile} as friend success"
|
226
|
+
end
|
227
|
+
|
228
|
+
def add_buddy_with_sip(sip, nickname = nil)
|
229
|
+
@logger.info "fetion send request to add sip:#{sip} as friend"
|
230
|
+
arg = %Q{<args><contacts><buddies><buddy uri="sip:#{sip}" local-name="#{nickname}" buddy-lists="1" expose-mobile-no="1" expose-name="1" /></buddies></contacts></args>}
|
231
|
+
msg = sip_create('S fetion.com.cn SIP-C/2.0', {'F' => @sid, 'I' => next_call, 'Q' => '1 S', 'N' => 'AddBuddy'}, arg) + FETION_SIPP
|
232
|
+
curl_exec(next_url, @ssic, msg)
|
233
|
+
response = curl_exec(next_url, @ssic, FETION_SIPP)
|
234
|
+
|
235
|
+
raise FetionException.new("Fetion Error: Add buddy error") unless response.is_a? Net::HTTPSuccess
|
236
|
+
@logger.info "fetion send request to add sip:#{sip} as friend success"
|
215
237
|
end
|
216
238
|
|
217
239
|
def logout
|
data/rfetion.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rfetion}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.13"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Richard Huang"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-28}
|
13
13
|
s.description = %q{rfetion is a ruby gem for China Mobile fetion service that you can send SMS free.}
|
14
14
|
s.email = %q{flyerhzm@gmail.com}
|
15
15
|
s.executables = ["rfetion", "rfetion"]
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"lib/rfetion/fetion.rb",
|
28
28
|
"rfetion.gemspec"
|
29
29
|
]
|
30
|
-
s.homepage = %q{}
|
30
|
+
s.homepage = %q{http://github.com/flyerhzm/rfetion}
|
31
31
|
s.rdoc_options = ["--charset=UTF-8"]
|
32
32
|
s.require_paths = ["lib"]
|
33
33
|
s.rubygems_version = %q{1.3.5}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rfetion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-28 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,7 +42,7 @@ files:
|
|
42
42
|
- lib/rfetion/fetion.rb
|
43
43
|
- rfetion.gemspec
|
44
44
|
has_rdoc: true
|
45
|
-
homepage:
|
45
|
+
homepage: http://github.com/flyerhzm/rfetion
|
46
46
|
licenses: []
|
47
47
|
|
48
48
|
post_install_message:
|