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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -3
- data/lib/generators/wechat/templates/app/controllers/wechats_controller.rb +1 -1
- data/lib/wechat/responder.rb +9 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 458dae06ac4875c8cf283fbda7cb06fa8b2260bf
|
4
|
+
data.tar.gz: cecda681714c670bb60f582fac2d3f4b25999a0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4c9ec8d9831c415a3d5a8557173e1f1c2cd37358f9b94191eafdf073b1158974954de842867d6e829150cdc95e904dcd2bc6c90c9bae877ad5dc1f50448a7b2
|
7
|
+
data.tar.gz: 8c3f2f89ec9a36d1e92af1b2408fc2de5a5f23ee8f20f924f64cb216c242253b04627169b3870ca7b51bc033491048a55726fe8ca17fff224706db664208b808
|
data/CHANGELOG.md
CHANGED
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("#{
|
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("#{
|
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|
|
data/lib/wechat/responder.rb
CHANGED
@@ -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, :
|
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.
|
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-
|
12
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|