Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 70489d5

Browse files
author
Ben Brown
authoredApr 30, 2018
Merge pull request #1315 from aldovilardy/patch-1
Correction of array name to receive attachments
2 parents 3e008d7 + dee44bd commit 70489d5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
 

‎docs/readme-ciscospark.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,23 @@ bot.reply(message,{text: 'I made this file for you.', files:[fs.createReadStream
166166

167167
## Receiving files
168168

169-
Your bot may receive messages with files attached. Attached files will appear in an array called `message.original_message.files`.
169+
Your bot may receive messages with files attached. Attached files will appear in an array called `message.data.files`.
170170

171171
Botkit provides 2 methods for retrieving information about the file.
172172

173173
### bot.retrieveFileInfo(url, cb)
174174
| Parameter | Description
175175
|--- |---
176-
| url | url of file from message.original_message.files
176+
| url | url of file from message.data.files
177177
| cb | callback function in the form function(err, file_info)
178178

179179
The callback function will receive an object with fields like `filename`, `content-type`, and `content-length`.
180180

181181
~~~ javascript
182182
controller.on('direct_message', function(bot, message) {
183183
bot.reply(message, 'I got your private message. You said, "' + message.text + '"');
184-
if (message.original_message.files) {
185-
bot.retrieveFileInfo(message.original_message.files[0], function(err, file_info) {
184+
if (message.data.files) {
185+
bot.retrieveFileInfo(message.data.files[0], function(err, file_info) {
186186
bot.reply(message,'I also got an attached file called ' + file_info.filename);
187187
});
188188
}
@@ -192,18 +192,18 @@ controller.on('direct_message', function(bot, message) {
192192
### bot.retrieveFile(url, cb)
193193
| Parameter | Description
194194
|--- |---
195-
| url | url of file from message.original_message.files
195+
| url | url of file from message.data.files
196196
| cb | callback function in the form function(err, file_content)
197197

198198
The callback function will receive the full content of the file.
199199

200200
~~~ javascript
201201
controller.on('direct_message', function(bot, message) {
202202
bot.reply(message, 'I got your private message. You said, "' + message.text + '"');
203-
if (message.original_message.files) {
204-
bot.retrieveFileInfo(message.original_message.files[0], function(err, file_info) {
203+
if (message.data.files) {
204+
bot.retrieveFileInfo(message.data.files[0], function(err, file_info) {
205205
if (file_info['content-type'] == 'text/plain') {
206-
bot.retrieveFile(message.original_message.files[0], function(err, file) {
206+
bot.retrieveFile(message.data.files[0], function(err, file) {
207207
bot.reply(message,'I got a text file with the following content: ' + file);
208208
});
209209
}

0 commit comments

Comments
 (0)
This repository has been archived.