facebook-messenger 1.5.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/lib/facebook/messenger/bot.rb +7 -9
- data/lib/facebook/messenger/incoming/common.rb +4 -25
- data/lib/facebook/messenger/version.rb +1 -1
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b757052cad527d03939514250e2f3fc87fbc21e0e7c86e9f78c8a2087ed925f1
|
4
|
+
data.tar.gz: 9f18c41169ded5554f49e3faa2e22a94565f83461bc2de688ad87957426791a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23d252fce2c080a7d95f1b25795ca423e7efac86c52e7dc158203c4f0b840d3b7c14b499919a3d9fab58cdf49e1bed274a7220f25b31c235e0e93fb457e45ff2
|
7
|
+
data.tar.gz: 1aa9d963cfecb848d000a4df931a1d30430005eff5b5f58cc18f8094092956077b354e589527770007e081b3f8d0cf7a67f1229da21a3b1ce453ff94a7dbca65
|
data/README.md
CHANGED
@@ -29,6 +29,7 @@ include Facebook::Messenger
|
|
29
29
|
Bot.on :message do |message|
|
30
30
|
message.id # => 'mid.1457764197618:41d102a3e1ae206a38'
|
31
31
|
message.sender # => { 'id' => '1008372609250235' }
|
32
|
+
message.recipient # => { 'id' => '2015573629214912' }
|
32
33
|
message.seq # => 73
|
33
34
|
message.sent_at # => 2016-04-22 21:30:36 +0200
|
34
35
|
message.text # => 'Hello, bot!'
|
@@ -48,7 +49,7 @@ Bot.deliver({
|
|
48
49
|
message: {
|
49
50
|
text: 'Human?'
|
50
51
|
},
|
51
|
-
|
52
|
+
messaging_type: Facebook::Messenger::Bot::MessagingType::UPDATE
|
52
53
|
}, access_token: ENV['ACCESS_TOKEN'], app_secret_proof: app_secret_proof
|
53
54
|
)
|
54
55
|
```
|
@@ -389,7 +390,7 @@ Bot.deliver({
|
|
389
390
|
message: {
|
390
391
|
text: 'Human?'
|
391
392
|
},
|
392
|
-
|
393
|
+
messaging_type: Facebook::Messenger::Bot::MessagingType::UPDATE
|
393
394
|
}, access_token: ENV['ACCESS_TOKEN'])
|
394
395
|
```
|
395
396
|
|
@@ -406,7 +407,7 @@ Bot.deliver({
|
|
406
407
|
message: {
|
407
408
|
text: 'Human?'
|
408
409
|
},
|
409
|
-
|
410
|
+
messaging_type: Facebook::Messenger::Bot::MessagingType::MESSAGE_TAG
|
410
411
|
tag: Facebook::Messenger::Bot::Tag::NON_PROMOTIONAL_SUBSCRIPTION
|
411
412
|
}, access_token: ENV['ACCESS_TOKEN'])
|
412
413
|
```
|
@@ -481,6 +482,8 @@ Facebook::Messenger.configure do |config|
|
|
481
482
|
end
|
482
483
|
```
|
483
484
|
|
485
|
+
You can get the current configuration provider with `Facebook::Messenger.config.provider`.
|
486
|
+
|
484
487
|
### Subscribe your Application to a Page
|
485
488
|
|
486
489
|
Once you've configured your bot, subscribe it to the Page to get messages
|
@@ -41,19 +41,17 @@ module Facebook
|
|
41
41
|
# in response while sending message.
|
42
42
|
#
|
43
43
|
# @param [Hash] message A Hash describing the recipient and the message.
|
44
|
-
# @param [String]
|
45
|
-
# @param [String] app_secret_proof proof of the app_secret
|
46
|
-
# https://developers.facebook.com/docs/graph-api/securing-requests/
|
47
|
-
# Note: we provide a helper function available at
|
48
|
-
# Messenger::Configuration::Providers::Base#calculate_app_secret_proof
|
44
|
+
# @param [String] page_id A String describing the Facebook Page ID to send the message from.
|
49
45
|
#
|
50
46
|
# Returns a String describing the message ID if the message was sent,
|
51
47
|
# or raises an exception if it was not.
|
52
|
-
def deliver(message,
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
def deliver(message, page_id:)
|
49
|
+
access_token = Facebook::Messenger.config.provider.access_token_for(page_id)
|
50
|
+
app_secret_proof = Facebook::Messenger.config.provider.app_secret_proof_for(page_id)
|
51
|
+
|
52
|
+
query = { access_token: access_token }
|
56
53
|
query[:appsecret_proof] = app_secret_proof if app_secret_proof
|
54
|
+
|
57
55
|
response = post '/messages',
|
58
56
|
body: JSON.dump(message),
|
59
57
|
format: :json,
|
@@ -74,7 +74,7 @@ module Facebook
|
|
74
74
|
sender_action: 'typing_on'
|
75
75
|
}
|
76
76
|
|
77
|
-
|
77
|
+
Facebook::Messenger::Bot.deliver(payload, page_id: recipient['id'])
|
78
78
|
end
|
79
79
|
|
80
80
|
#
|
@@ -90,7 +90,7 @@ module Facebook
|
|
90
90
|
sender_action: 'typing_off'
|
91
91
|
}
|
92
92
|
|
93
|
-
|
93
|
+
Facebook::Messenger::Bot.deliver(payload, page_id: recipient['id'])
|
94
94
|
end
|
95
95
|
|
96
96
|
#
|
@@ -106,7 +106,7 @@ module Facebook
|
|
106
106
|
sender_action: 'mark_seen'
|
107
107
|
}
|
108
108
|
|
109
|
-
|
109
|
+
Facebook::Messenger::Bot.deliver(payload, page_id: recipient['id'])
|
110
110
|
end
|
111
111
|
|
112
112
|
#
|
@@ -123,28 +123,7 @@ module Facebook
|
|
123
123
|
message_type: Facebook::Messenger::Bot::MessageType::RESPONSE
|
124
124
|
}
|
125
125
|
|
126
|
-
|
127
|
-
end
|
128
|
-
|
129
|
-
#
|
130
|
-
# Function returns the configured access token.
|
131
|
-
#
|
132
|
-
# @return [String] Access token.
|
133
|
-
#
|
134
|
-
def access_token
|
135
|
-
Facebook::Messenger.config.provider.access_token_for(recipient)
|
136
|
-
end
|
137
|
-
|
138
|
-
def app_secret_proof
|
139
|
-
Facebook::Messenger.config.provider.app_secret_proof_for(recipient)
|
140
|
-
end
|
141
|
-
|
142
|
-
private
|
143
|
-
|
144
|
-
def deliver_payload(payload)
|
145
|
-
Facebook::Messenger::Bot.deliver(payload,
|
146
|
-
access_token: access_token,
|
147
|
-
app_secret_proof: app_secret_proof)
|
126
|
+
Facebook::Messenger::Bot.deliver(payload, page_id: recipient['id'])
|
148
127
|
end
|
149
128
|
end
|
150
129
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebook-messenger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Gorset
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -48,16 +48,16 @@ dependencies:
|
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 2.1.4
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - "
|
58
|
+
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: 2.1.4
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: coveralls
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,28 +106,28 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
109
|
+
version: 13.0.1
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
116
|
+
version: 13.0.1
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: rspec
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '3.
|
123
|
+
version: '3.9'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: '3.
|
130
|
+
version: '3.9'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: rubocop
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,14 +148,14 @@ dependencies:
|
|
148
148
|
requirements:
|
149
149
|
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version:
|
151
|
+
version: 3.8.1
|
152
152
|
type: :development
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version:
|
158
|
+
version: 3.8.1
|
159
159
|
description: Facebook Messenger client
|
160
160
|
email:
|
161
161
|
- jgorset@gmail.com
|
@@ -219,8 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
219
|
- !ruby/object:Gem::Version
|
220
220
|
version: '0'
|
221
221
|
requirements: []
|
222
|
-
|
223
|
-
rubygems_version: 2.7.6
|
222
|
+
rubygems_version: 3.0.6
|
224
223
|
signing_key:
|
225
224
|
specification_version: 4
|
226
225
|
summary: Facebook Messenger client
|