aproxacs-sms_client 0.1.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/sms_client/client/joyzen_client.rb +1 -5
- data/lib/sms_client/client/lgt_client.rb +1 -2
- data/lib/sms_client/client/paran_client.rb +2 -4
- data/lib/sms_client/client/xpeed_client.rb +1 -3
- data/lib/sms_client/client_methods.rb +9 -3
- data/lib/sms_client/client_pool.rb +17 -36
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
@@ -14,9 +14,7 @@ module SMS
|
|
14
14
|
page = @agent.get("http://www.joyzen.co.kr/community/message/pop_message.html")
|
15
15
|
page = @agent.get("http://www.joyzen.co.kr/community/message/pop_message.html")
|
16
16
|
@remains = page.search("tr td font strong").first.content.to_i
|
17
|
-
|
18
|
-
SMS.log.info "[Joyzen] Remains : #{remains} times" if SMS.log
|
19
|
-
available?
|
17
|
+
super
|
20
18
|
rescue Exception => e
|
21
19
|
SMS.log.debug e if SMS.log
|
22
20
|
false
|
@@ -31,8 +29,6 @@ module SMS
|
|
31
29
|
form.phone = from
|
32
30
|
form.group_name1 = to
|
33
31
|
end.submit
|
34
|
-
|
35
|
-
true
|
36
32
|
end
|
37
33
|
end
|
38
34
|
end
|
@@ -19,8 +19,7 @@ module SMS
|
|
19
19
|
page = page.forms.first.submit
|
20
20
|
page = @agent.get("http://cworld.ez-i.co.kr/mylgt2007/web2phone.asp")
|
21
21
|
@remains = page.search(".mysms2_1 .accent").first.content.to_i
|
22
|
-
|
23
|
-
available?
|
22
|
+
super
|
24
23
|
rescue Exception => e
|
25
24
|
SMS.log.debug e if SMS.log
|
26
25
|
false
|
@@ -2,7 +2,7 @@ module SMS
|
|
2
2
|
class ParanClient
|
3
3
|
include ClientMethods
|
4
4
|
|
5
|
-
def login(id, password)
|
5
|
+
def login(id, password)
|
6
6
|
id, domain = id.split("@")
|
7
7
|
page = @agent.get("http://www.paran.com")
|
8
8
|
page = page.form_with(:name => "fmLogin") do |form|
|
@@ -16,9 +16,7 @@ module SMS
|
|
16
16
|
if page.search("#smsinfo a").first.content =~ /(\d+).*/
|
17
17
|
@remains = $1.to_i
|
18
18
|
end
|
19
|
-
|
20
|
-
SMS.log.info "[Paran] Remains : #{remains} times" if SMS.log
|
21
|
-
available?
|
19
|
+
super
|
22
20
|
rescue Exception => e
|
23
21
|
SMS.log.debug e if SMS.log
|
24
22
|
false
|
@@ -15,9 +15,7 @@ module SMS
|
|
15
15
|
page.form_with(:name => "phone_form") do |form|
|
16
16
|
@remains = form.remainFreeStr.split(":").last.to_i
|
17
17
|
end
|
18
|
-
|
19
|
-
SMS.log.info "[Xpeed] Remains : #{remains} times" if SMS.log
|
20
|
-
available?
|
18
|
+
super
|
21
19
|
rescue Exception => e
|
22
20
|
SMS.log.debug e if SMS.log
|
23
21
|
false
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module SMS
|
2
2
|
module ClientMethods
|
3
|
-
attr_accessor :priority
|
4
|
-
|
5
3
|
def initialize
|
6
4
|
@agent = WWW::Mechanize.new do |agent|
|
7
5
|
agent.user_agent_alias = 'Windows IE 7'
|
@@ -24,6 +22,14 @@ module SMS
|
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
25
|
+
def login(id, password)
|
26
|
+
@id = id
|
27
|
+
@password = password
|
28
|
+
SMS.log.info "[Paran] Remains : #{remains} times" if SMS.log
|
29
|
+
available?
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
27
33
|
def deliver(to, msg)
|
28
34
|
return false unless available?
|
29
35
|
return false unless valid_number?(to)
|
@@ -36,7 +42,7 @@ module SMS
|
|
36
42
|
end
|
37
43
|
|
38
44
|
def to_s
|
39
|
-
"#{self.class} : avaliable=#{available?}, from=#{from}, remains=#{remains}
|
45
|
+
"#{self.class} : avaliable=#{available?}, from=#{from}, remains=#{remains}"
|
40
46
|
end
|
41
47
|
|
42
48
|
protected
|
@@ -8,62 +8,43 @@ module SMS
|
|
8
8
|
# ...
|
9
9
|
# }
|
10
10
|
#
|
11
|
-
def initialize(config)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def clients
|
16
|
-
@clients ||= []
|
11
|
+
def initialize(config = {})
|
12
|
+
@config = config.to_a
|
13
|
+
sort
|
17
14
|
end
|
15
|
+
attr_accessor :from
|
18
16
|
|
19
17
|
def size
|
20
|
-
|
18
|
+
@config.size
|
21
19
|
end
|
22
20
|
|
23
21
|
def add(cli)
|
24
|
-
|
25
|
-
clients << cli
|
26
|
-
else cli.is_a? Hash
|
27
|
-
cli.each do |key, val|
|
28
|
-
val.symbolize_keys!
|
29
|
-
client = SMS::Client.new(key) do |c|
|
30
|
-
c.priority = val[:priority] || 10
|
31
|
-
c.login(val[:id], val[:password])
|
32
|
-
end
|
33
|
-
clients << client if client.available?
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
22
|
+
@config.concat cli.to_a
|
37
23
|
sort
|
38
24
|
end
|
39
25
|
|
40
|
-
def remove(
|
41
|
-
|
26
|
+
def remove(key)
|
27
|
+
@config.delete(key)
|
42
28
|
end
|
43
29
|
|
44
30
|
def first
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
def from=(num)
|
52
|
-
clients.each do |c|
|
53
|
-
c.from = num
|
31
|
+
@config.each do |cf|
|
32
|
+
cli = Client.new(cf[0]) do |cli|
|
33
|
+
cli.from = from if from
|
34
|
+
cli.login(cf[1]["id"], cf[1]["password"])
|
35
|
+
end
|
36
|
+
return cli if cli.available?
|
54
37
|
end
|
55
38
|
end
|
56
39
|
|
57
40
|
def to_s
|
58
|
-
|
59
|
-
ret << " (#{cli.to_s})"
|
60
|
-
end.join("\n")
|
41
|
+
@config.to_s
|
61
42
|
end
|
62
43
|
|
63
44
|
private
|
64
45
|
def sort
|
65
|
-
|
66
|
-
a
|
46
|
+
@config.sort! do |a,b|
|
47
|
+
a[1]["priority"] <=> b[1]["priority"]
|
67
48
|
end
|
68
49
|
end
|
69
50
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aproxacs-sms_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aproxacs
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-23 00:00:00 -07:00
|
13
13
|
default_executable: send_text
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|