wechat 0.6.1 → 0.6.2

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: f59a6b94fe8cf2e353989117eae7ad5a628b0019
4
- data.tar.gz: 6eeadd34d849454fe236cc6316b2712c96e803f0
3
+ metadata.gz: 458dae06ac4875c8cf283fbda7cb06fa8b2260bf
4
+ data.tar.gz: cecda681714c670bb60f582fac2d3f4b25999a0a
5
5
  SHA512:
6
- metadata.gz: 8832c94b0cd387a7da39e749ad8e99099f0a3a57f47072e77f4f27de1a4a6261e0f2a2376fbf627bbae53cf1f651268329b0f0052348a62e3c665d55730c2c91
7
- data.tar.gz: 293a172e7da89170a5d459ffafc65de99b77afabab645a894e6bcbd5d0992449d7d5ae5a82a5f0398bb257900e1cf85e193a1e8cb1f80359c3edf94582f419b4
6
+ metadata.gz: d4c9ec8d9831c415a3d5a8557173e1f1c2cd37358f9b94191eafdf073b1158974954de842867d6e829150cdc95e904dcd2bc6c90c9bae877ad5dc1f50448a7b2
7
+ data.tar.gz: 8c3f2f89ec9a36d1e92af1b2408fc2de5a5f23ee8f20f924f64cb216c242253b04627169b3870ca7b51bc033491048a55726fe8ca17fff224706db664208b808
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.6.2 (released at 11/05/2015)
4
+
5
+ * Tecent report location API changed, so change wechat gems also. #64
6
+
3
7
  ## v0.6.1 (released at 10/20/2015)
4
8
 
5
9
  * Handle 40001, invalid credential, access_token is invalid or not latest hint # 57
data/README.md CHANGED
@@ -434,9 +434,9 @@ class WechatsController < ApplicationController
434
434
  request.reply.video(request[:MediaId], title: '回声', description: "#{nickname}发来的视频请求") #直接视频返回给用户
435
435
  end
436
436
 
437
- # 处理地理位置信息
437
+ # 处理上报地理位置事件
438
438
  on :location do |request|
439
- request.reply.text("#{request[:Location_X]}, #{request[:Location_Y]}") #回复地理位置
439
+ request.reply.text("Latitude: #{message[:Latitude]} Longitude: #{message[:Longitude]} Precision: #{message[:Precision]}")
440
440
  end
441
441
 
442
442
  # 当用户取消关注订阅
@@ -490,12 +490,12 @@ end
490
490
  - :image 响应图片消息
491
491
  - :voice 响应语音消息
492
492
  - :video 响应视频消息
493
- - :location 响应地理位置消息
494
493
  - :link 响应链接消息
495
494
  - :event 响应事件消息, 可以用`:with`参数来匹配事件类型
496
495
  - :click 虚拟响应事件消息, 微信仍然传入:event,但gem内部会单独处理
497
496
  - :scan 虚拟响应事件消息
498
497
  - :batch_job 虚拟响应事件消息
498
+ - :location 虚拟响应上报地理位置事件消息
499
499
  - :fallback 默认响应,当收到的消息无法被其他responder响应时,会使用这个responder.
500
500
 
501
501
  ### 多客服消息转发
@@ -77,7 +77,7 @@ class WechatsController < ApplicationController
77
77
 
78
78
  # When user sent location
79
79
  on :location do |request|
80
- request.reply.text("#{request[:Location_X]}, #{request[:Location_Y]}") # replay the GPS location
80
+ request.reply.text("Latitude: #{message[:Latitude]} Longitude: #{message[:Longitude]} Precision: #{message[:Precision]}")
81
81
  end
82
82
 
83
83
  on :event, with: 'unsubscribe' do |request|
@@ -15,7 +15,7 @@ module Wechat
15
15
  attr_accessor :wechat, :token, :corpid, :agentid, :encrypt_mode, :skip_verify_ssl, :encoding_aes_key
16
16
 
17
17
  def on(message_type, with: nil, respond: nil, &block)
18
- fail 'Unknow message type' unless [:text, :image, :voice, :video, :location, :link, :event, :click, :scan, :batch_job, :fallback].include?(message_type)
18
+ fail 'Unknow message type' unless [:text, :image, :voice, :video, :link, :event, :click, :scan, :batch_job, :location, :fallback].include?(message_type)
19
19
  config = respond.nil? ? {} : { respond: respond }
20
20
  config.merge!(proc: block) if block_given?
21
21
 
@@ -32,6 +32,8 @@ module Wechat
32
32
  user_defined_click_responders(with) << config
33
33
  when :batch_job
34
34
  user_defined_batch_job_responders(with) << config
35
+ when :location
36
+ user_defined_location_responders << config
35
37
  else
36
38
  user_defined_responders(message_type) << config
37
39
  end
@@ -48,6 +50,10 @@ module Wechat
48
50
  @batch_job_responders[with] ||= []
49
51
  end
50
52
 
53
+ def user_defined_location_responders
54
+ @location_responders ||= []
55
+ end
56
+
51
57
  def user_defined_responders(type)
52
58
  @responders ||= {}
53
59
  @responders[type] ||= []
@@ -69,6 +75,8 @@ module Wechat
69
75
  yield(* known_scan_with_match_responders(user_defined_responders(:scan), message))
70
76
  elsif 'batch_job_result' == message[:Event]
71
77
  yield(* user_defined_batch_job_responders(message[:BatchJob][:JobType]), message[:BatchJob])
78
+ elsif 'location' == message[:Event]
79
+ yield(* user_defined_location_responders, message)
72
80
  else
73
81
  yield(* match_responders(responders, message[:Event]))
74
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wechat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skinnyworm
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-20 00:00:00.000000000 Z
12
+ date: 2015-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport