-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.rb
49 lines (47 loc) · 1.38 KB
/
config.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module RailsWechat
include ActiveSupport::Configurable
configure do |config|
config.email_domain = 'mail.work.design'
config.confirm = false
config.suite_id = ''
config.rules = ActiveSupport::OrderedOptions.new
config.rules.a = {
msg_type: 'event',
event: 'templatesendjobfinish',
proc: ->(request) {
r = Wechat::Notice.find_by(msg_id: request.raw_body['MsgID'])
r.update status: request.raw_body['Status']
Wechat::TextReply.new(value: 'SUCCESS')
}
}
config.rules.b = {
msg_type: 'event',
event: 'click',
body: 'bind',
proc: ->(request) { request.reply_for_user }
}
config.rules.b2 = {
msg_type: 'event',
event: ['subscribe', 'scan'],
body: /^invite_(member|by)_/,
proc: ->(request) { request.reply_for_blank_info }
}
config.rules.c1 = {
msg_type: 'text',
body: 'TESTCOMPONENT_MSG_TYPE_TEXT',
proc: ->(request) { Wechat::TextReply.new(value: 'TESTCOMPONENT_MSG_TYPE_TEXT_callback') }
}
config.rules.c2 = {
msg_type: 'text',
body: /QUERY_AUTH_CODE:/,
proc: ->(request) {
auth = request.platform.auths.build
auth.auth_code = request.body.delete_prefix 'QUERY_AUTH_CODE:'
auth.request = request
auth.testcase = true
auth.save
Wechat::SuccessReply.new
}
}
end
end