linerb 0.1.2 → 0.1.4

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
  SHA256:
3
- metadata.gz: fc0f82cf83433cc6e798d54d542ffe15839587526c60eab38a8ded0846882aea
4
- data.tar.gz: 38bc0d916bc2f9d857b9740e3a27f4d931d6dcbb27695251708e4e5dbcacbf27
3
+ metadata.gz: 17f457c799b2f67ead8e2f61b0e28314232079148ce66ab42a7d6d200919a799
4
+ data.tar.gz: 9752ea144bab0281aabe9b3a7d88020937967b6961d34dcbb8cb7b92e40811ec
5
5
  SHA512:
6
- metadata.gz: 69487a94fe2dc9c9170d16c945ef5010ce96d6a0c6fbcc897e52b92296177a8b123638fb8e55b1eddc42eba743887f02f141bbf4d47db6800e491728fb9eb376
7
- data.tar.gz: c4f65d968af9e5c843e9b3325e9f12b1afc93470e2c6f1529423cebd0a5e35840605854919e278dd7a4146cdf528849b6bf9993b083719f316e9ade4e4d6a473
6
+ metadata.gz: 763a3c93dd1cc72c35a26c6b8ec91e6d0f5eb56db71de00e55028b6f29624f6f64ace53b9ae4248b775bd90f9445573ed55ba8540c7c8a10c27c4e6ffd6533d0
7
+ data.tar.gz: 2cdae63e62fd54b5138298d65642c835ca5edeb89779b0676c69775885d7c94eff1d9cd34cf7efa418c0e2d846c293ce7cae61cdf40ba32b451e2bd02ab0f112
@@ -1 +1,5 @@
1
1
  require 'linerb/client'
2
+ require 'linerb/api/talkApi'
3
+ require 'linerb/api/pollApi'
4
+
5
+ require 'async'
@@ -1 +1,44 @@
1
- #in progress
1
+ require_relative 'pollRecv'
2
+
3
+ require 'time'
4
+
5
+ class PollApi
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ def api_fetch_operations
11
+ recv = PollRecv.new
12
+
13
+ rev = @client.getLastOpRevision()
14
+
15
+ @local_rev = rev
16
+
17
+ last_rev = rev
18
+
19
+ while true do
20
+ begin
21
+ operations = @client.fetchOperations(@local_rev, 50)
22
+
23
+ operations.each { |op|
24
+
25
+ if op::type == J0_a_e_a_b_nd::END_OF_OPERATION || op::type == J0_a_e_a_b_nd::DUMMY
26
+ next
27
+ end
28
+
29
+ @local_rev = op::revision
30
+
31
+ if last_rev < op::revision
32
+ last_rev = op::revision
33
+ Async do
34
+ recv.op_process(op)
35
+ end
36
+ end
37
+ }
38
+
39
+ rescue Net::ReadTimeout
40
+ retry
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ class PollRecv
2
+ def op_process(op) end
3
+ end
@@ -1,13 +1,21 @@
1
- $:.push('./gen-rb')
2
-
3
1
  class TalkApi
4
2
  def initialize(client)
5
3
  @client = client
4
+ @reqSeq = 0
6
5
  end
7
6
  end
8
- def api_sendMessage(text:, to:)
9
- mes = Message.new
10
- mes:: text = text
11
- mes::to = to
12
- @client.sendMessage(0, mes)
13
- end
7
+
8
+ def api_sendMessage(text:, to:, **param)
9
+ mes = Message.new
10
+ mes::text = text
11
+ mes::to = to
12
+ mes::contentType = param[:contentType]
13
+ @client.sendMessage(@reqSeq += 1, mes)
14
+ end
15
+
16
+ def api_deleteOtherFromChat(chatMid:, targetUserMids:)
17
+ del = DeleteOtherFromChatRequest.new
18
+ del::chatMid = chatMid
19
+ del::targetUserMids = "[#{targetUserMids}]"
20
+ @client.deleteOtherFromChat(0, del)
21
+ end
@@ -1,6 +1,3 @@
1
- $:.push('./gen-rb')
2
-
3
- require 'thrift'
4
1
  require 'openssl'
5
2
  require "base64"
6
3
  require 'cgi'
@@ -16,9 +13,9 @@ begin
16
13
 
17
14
  class Auth
18
15
 
19
- def initialize(authToken:, certificate:)
20
- @a = authToken
21
- @c = certificate
16
+ def initialize(auth_token:, certificate:)
17
+ @auth = auth_token
18
+ @cert = certificate
22
19
 
23
20
  #authToken login is in progress
24
21
  end
@@ -28,95 +25,99 @@ begin
28
25
  transport = Thrift::HTTPClientTransport.new(url)
29
26
  transport.add_headers(headers)
30
27
 
31
- protocol = Thrift::CompactProtocol.new(transport)
32
-
33
- return protocol
28
+ Thrift::CompactProtocol.new(transport)
34
29
  end
35
30
 
36
31
  def login
37
32
  protocol = client_proto(Config::LOGIN_URL, Config::HEADERS)
38
- loginClient = SecondaryQrcodeLoginService::Client.new(protocol)
33
+ login_client = SecondaryQrcodeLoginService::Client.new(protocol)
39
34
 
40
- sessionId = loginClient.createSession(CreateQrSessionRequest).authSessionId
35
+ session_id = login_client.createSession(CreateQrSessionRequest).authSessionId
41
36
 
42
37
  qr_req = CreateQrCodeRequest.new
43
- qr_req::authSessionId = sessionId
38
+ qr_req::authSessionId = session_id
44
39
 
45
- qr_url = loginClient.createQrCode(qr_req).callbackUrl
40
+ qr_url = login_client.createQrCode(qr_req).callbackUrl
46
41
 
47
42
  secret = Base64.strict_encode64(SecureRandom.base64(32))
48
43
  version = 1
49
44
  e2ee = "?secret=#{secret}" + "&e2eeVersion=#{version}"
50
- puts "[LOGIN] => " + qr_url + e2ee
45
+ puts "LINE-RB: [LOGIN] => #{qr_url}#{e2ee}"
51
46
 
52
47
  Config::HEADERS[:"X-Line-Access"] = ""
53
48
 
54
49
  protocol = client_proto(Config::PERMIT_NOTICE_URL, Config::HEADERS)
55
- certClient = SecondaryQrCodeLoginPermitNoticeService::Client.new(protocol)
50
+ cert_client = SecondaryQrCodeLoginPermitNoticeService::Client.new(protocol)
56
51
 
57
52
  qr_check = CheckQrCodeVerifiedRequest.new
58
- qr_check::authSessionId = sessionId
53
+ qr_check::authSessionId = session_id
59
54
 
60
55
  begin
61
- certClient.checkQrCodeVerified(qr_check)
56
+ cert_client.checkQrCodeVerified(qr_check)
62
57
 
63
58
  rescue Net::ReadTimeout
64
- puts "[Timeout] QrCode verification"
59
+ puts "\nLINE-RB: [Timeout] QrCode verification\n"
65
60
  exit(1)
66
61
  end
67
62
 
68
63
  Config::HEADERS.delete(:"X-Line-Access") #=> ""
69
64
 
70
65
  protocol = client_proto(Config::LOGIN_URL, Config::HEADERS)
71
- loginClient = SecondaryQrcodeLoginService::Client.new(protocol)
66
+ login_client = SecondaryQrcodeLoginService::Client.new(protocol)
72
67
 
73
68
  begin
74
69
 
75
70
  certificate_check = VerifyCertificateRequest.new
76
- certificate_check::authSessionId = sessionId
77
- certificate_check::certificate = @certificate
71
+ certificate_check::authSessionId = session_id
72
+ certificate_check::certificate = @cert
78
73
 
79
- loginClient.verifyCertificate(certificate_check)
74
+ login_client.verifyCertificate(certificate_check)
80
75
 
81
76
  login_req = QrCodeLoginRequest.new
82
- login_req.authSessionId = sessionId
77
+ login_req.authSessionId = session_id
83
78
  login_req.systemName = "Ruby on Rails"
84
79
  login_req.autoLoginIsRequired = FALSE
85
80
 
86
- res = loginClient.qrCodeLogin(login_req)
81
+ res = login_client.qrCodeLogin(login_req)
87
82
 
88
- puts "[CERT] => " + res.certificate
89
- puts "[TOKEN] => " + res.accessToken
83
+ #DO NOT SHOW IN PUBLIC
84
+ #DO NOT EDIT IF YOU DONT KNOW WHAT YOU ARE DOING
85
+ #puts "LINE-RB: [CERT] " + Base64.strict_encode64(res.certificate)
86
+ #puts "LINE-RB: [TOKEN] " + Base64.strict_encode64(res.accessToken)
90
87
 
91
88
  Config::HEADERS[:"X-Line-Access"] = res.accessToken
92
89
 
93
90
  rescue SecondaryQrCodeException
94
91
  pin_req = CreatePinCodeRequest.new
95
- pin_req::authSessionId = sessionId
96
- pincode = loginClient.createPinCode(pin_req).pinCode
92
+ pin_req::authSessionId = session_id
93
+ pincode = login_client.createPinCode(pin_req).pinCode
97
94
 
98
- if pincode != nil then
99
- puts "[PIN] => " + pincode
95
+ if pincode != nil
96
+ puts "LINE-RB: [PIN] => #{pincode}\n"
100
97
  pin_check = CheckPinCodeVerifiedRequest.new
101
- pin_check::authSessionId = sessionId
98
+ pin_check::authSessionId = session_id
102
99
 
103
100
  begin
104
- certClient.checkPinCodeVerified(pin_check)
101
+ cert_client.checkPinCodeVerified(pin_check)
105
102
 
106
103
  login_req = QrCodeLoginRequest.new
107
- login_req.authSessionId = sessionId
104
+ login_req.authSessionId = session_id
108
105
  login_req.systemName = "Ruby on Rails"
109
106
  login_req.autoLoginIsRequired = FALSE
110
107
 
111
- res = loginClient.qrCodeLogin(login_req)
108
+ res = login_client.qrCodeLogin(login_req)
112
109
 
113
- puts "[CERT] => " + res.certificate
114
- puts "[TOKEN] => " + res.accessToken
110
+ #DO NOT SHOW IN PUBLIC
111
+ #DO NOT EDIT IF YOU DONT KNOW WHAT YOU ARE DOING
112
+ #puts "LINE-RB: [CERT] " + Base64.strict_encode64(res.certificate)
113
+ #puts "LINE-RB: [TOKEN] " + Base64.strict_encode64(res.accessToken)
115
114
 
116
115
  Config::HEADERS[:"X-Line-Access"] = res.accessToken
117
116
 
117
+ puts "\nLINE-RB: [LOGIN SUCCESS]\n"
118
+
118
119
  rescue Net::ReadTimeout
119
- puts "[Timeout] PinCode verification"
120
+ puts "\nLINE-RB: [Timeout] PinCode verification\n"
120
121
  exit(1)
121
122
  end
122
123
  end
@@ -1,38 +1,32 @@
1
- $:.push('./gen-rb')
2
-
3
1
  require_relative 'auth'
4
2
  require_relative 'gen-rb/talk_service'
5
3
 
6
4
  class LineClient
7
5
 
8
- def initialize(authToken:, certificate:)
9
- @a = authToken
10
- @c = certificate
11
- end
12
-
13
- def doAuthService
14
- Auth.new(authToken: @a, certificate: @c).login
6
+ def initialize(auth_token:, certificate:)
7
+ @auth = auth_token
8
+ @cert = certificate
15
9
  end
16
10
 
17
- def getTalkService
11
+ def get_talk_service
18
12
  transport = Thrift::HTTPClientTransport.new(Config::TALK_SERVICE_V4_URL)
19
13
  transport.add_headers(Config::HEADERS)
20
14
 
21
15
  protocol = Thrift::CompactProtocol.new(transport)
22
16
 
23
- client = TalkService::Client.new(protocol)
24
-
25
- return client
17
+ TalkService::Client.new(protocol)
26
18
  end
27
19
 
28
- def getPollService
20
+ def get_poll_service
29
21
  transport = Thrift::HTTPClientTransport.new(Config::POLL_SERVICE_V4_URL)
30
22
  transport.add_headers(Config::HEADERS)
31
23
 
32
24
  protocol = Thrift::CompactProtocol.new(transport)
33
25
 
34
- client = TalkService::Client.new(protocol)
26
+ TalkService::Client.new(protocol)
27
+ end
35
28
 
36
- return client
29
+ def do_auth_service
30
+ Auth.new(auth_token: @auth, certificate: @cert).login
37
31
  end
38
32
  end
@@ -1,14 +1,15 @@
1
1
  module Config
2
- HOST_URL = "https://legy-jp-addr.line.naver.jp"
2
+ HOST_URL = "https://legy-backup.line.naver.jp"
3
3
  LOGIN_URL = HOST_URL + "/acct/lgn/sq/v1"
4
4
  PERMIT_NOTICE_URL = HOST_URL + "/acct/lp/lgn/sq/v1"
5
5
 
6
- TALK_SERVICE_V4_URL = HOST_URL + "/S4"
6
+ TALK_SERVICE_V4_URL = HOST_URL + "/F4"
7
7
  POLL_SERVICE_V4_URL = HOST_URL + "/P4"
8
8
 
9
9
  HEADERS = {
10
- "User-Agent": "LLA/2.11.1 Nexus 5X 10",
11
- "X-Line-Application": "ANDROIDLITE\t2.11.1\tAndroid OS\t10.0;SECONDARY",
10
+ "User-Agent": "Mozilla/5.0 (Windows NT 6.1; rv:49.0) Gecko/20100101 Firefox/49.0",
11
+ "X-Line-Application": "DESKTOPWIN\t6.3.1.2337\tDESKTOP_WIN\t10;SECONDARY",
12
12
  "x-lal": "ja_jp",
13
13
  }
14
+
14
15
  end
@@ -5,5 +5,5 @@
5
5
  #
6
6
 
7
7
  require 'thrift'
8
- require_relative 'takagi_chan_types'
8
+ require 'takagi_chan_types'
9
9
 
@@ -89,6 +89,38 @@ module TalkService
89
89
  return
90
90
  end
91
91
 
92
+ def getLastOpRevision()
93
+ send_getLastOpRevision()
94
+ return recv_getLastOpRevision()
95
+ end
96
+
97
+ def send_getLastOpRevision()
98
+ send_message('getLastOpRevision', GetLastOpRevision_args)
99
+ end
100
+
101
+ def recv_getLastOpRevision()
102
+ result = receive_message(GetLastOpRevision_result)
103
+ return result.success unless result.success.nil?
104
+ raise result.e unless result.e.nil?
105
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getLastOpRevision failed: unknown result')
106
+ end
107
+
108
+ def fetchOperations(localRev, count)
109
+ send_fetchOperations(localRev, count)
110
+ return recv_fetchOperations()
111
+ end
112
+
113
+ def send_fetchOperations(localRev, count)
114
+ send_message('fetchOperations', FetchOperations_args, :localRev => localRev, :count => count)
115
+ end
116
+
117
+ def recv_fetchOperations()
118
+ result = receive_message(FetchOperations_result)
119
+ return result.success unless result.success.nil?
120
+ raise result.e unless result.e.nil?
121
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'fetchOperations failed: unknown result')
122
+ end
123
+
92
124
  def fetchOps(localRev, count, globalRev, individualRev)
93
125
  send_fetchOps(localRev, count, globalRev, individualRev)
94
126
  return recv_fetchOps()
@@ -1517,6 +1549,28 @@ module TalkService
1517
1549
  write_result(result, oprot, 'sendPostback', seqid)
1518
1550
  end
1519
1551
 
1552
+ def process_getLastOpRevision(seqid, iprot, oprot)
1553
+ args = read_args(iprot, GetLastOpRevision_args)
1554
+ result = GetLastOpRevision_result.new()
1555
+ begin
1556
+ result.success = @handler.getLastOpRevision()
1557
+ rescue ::TalkException => e
1558
+ result.e = e
1559
+ end
1560
+ write_result(result, oprot, 'getLastOpRevision', seqid)
1561
+ end
1562
+
1563
+ def process_fetchOperations(seqid, iprot, oprot)
1564
+ args = read_args(iprot, FetchOperations_args)
1565
+ result = FetchOperations_result.new()
1566
+ begin
1567
+ result.success = @handler.fetchOperations(args.localRev, args.count)
1568
+ rescue ::TalkException => e
1569
+ result.e = e
1570
+ end
1571
+ write_result(result, oprot, 'fetchOperations', seqid)
1572
+ end
1573
+
1520
1574
  def process_fetchOps(seqid, iprot, oprot)
1521
1575
  args = read_args(iprot, FetchOps_args)
1522
1576
  result = FetchOps_result.new()
@@ -2649,6 +2703,75 @@ module TalkService
2649
2703
  ::Thrift::Struct.generate_accessors self
2650
2704
  end
2651
2705
 
2706
+ class GetLastOpRevision_args
2707
+ include ::Thrift::Struct, ::Thrift::Struct_Union
2708
+
2709
+ FIELDS = {
2710
+
2711
+ }
2712
+
2713
+ def struct_fields; FIELDS; end
2714
+
2715
+ def validate
2716
+ end
2717
+
2718
+ ::Thrift::Struct.generate_accessors self
2719
+ end
2720
+
2721
+ class GetLastOpRevision_result
2722
+ include ::Thrift::Struct, ::Thrift::Struct_Union
2723
+ SUCCESS = 0
2724
+ E = 1
2725
+
2726
+ FIELDS = {
2727
+ SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'},
2728
+ E => {:type => ::Thrift::Types::STRUCT, :name => 'e', :class => ::TalkException}
2729
+ }
2730
+
2731
+ def struct_fields; FIELDS; end
2732
+
2733
+ def validate
2734
+ end
2735
+
2736
+ ::Thrift::Struct.generate_accessors self
2737
+ end
2738
+
2739
+ class FetchOperations_args
2740
+ include ::Thrift::Struct, ::Thrift::Struct_Union
2741
+ LOCALREV = 2
2742
+ COUNT = 3
2743
+
2744
+ FIELDS = {
2745
+ LOCALREV => {:type => ::Thrift::Types::I64, :name => 'localRev'},
2746
+ COUNT => {:type => ::Thrift::Types::I32, :name => 'count'}
2747
+ }
2748
+
2749
+ def struct_fields; FIELDS; end
2750
+
2751
+ def validate
2752
+ end
2753
+
2754
+ ::Thrift::Struct.generate_accessors self
2755
+ end
2756
+
2757
+ class FetchOperations_result
2758
+ include ::Thrift::Struct, ::Thrift::Struct_Union
2759
+ SUCCESS = 0
2760
+ E = 1
2761
+
2762
+ FIELDS = {
2763
+ SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Operation}},
2764
+ E => {:type => ::Thrift::Types::STRUCT, :name => 'e', :class => ::TalkException}
2765
+ }
2766
+
2767
+ def struct_fields; FIELDS; end
2768
+
2769
+ def validate
2770
+ end
2771
+
2772
+ ::Thrift::Struct.generate_accessors self
2773
+ end
2774
+
2652
2775
  class FetchOps_args
2653
2776
  include ::Thrift::Struct, ::Thrift::Struct_Union
2654
2777
  LOCALREV = 2
@@ -1,3 +1,3 @@
1
1
  module Linerb
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linerb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - TakagiChan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-15 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thrift
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.11.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: async
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.26.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.26.2
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -61,6 +75,7 @@ extra_rdoc_files: []
61
75
  files:
62
76
  - lib/linerb.rb
63
77
  - lib/linerb/api/pollApi.rb
78
+ - lib/linerb/api/pollRecv.rb
64
79
  - lib/linerb/api/talkApi.rb
65
80
  - lib/linerb/auth.rb
66
81
  - lib/linerb/client.rb