Skip to content

Commit

Permalink
Return attachment objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Oct 1, 2017
1 parent 3da89f8 commit e072f98
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/SlackRTMDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,26 +163,25 @@ public function getMessages()
if (is_array($channel_id)) {
$channel_id = $channel_id['id'];
}

if ($this->event->get('subtype') === 'file_share') {
$file = Collection::make($this->event->get('file'));

if (strstr($file->get('mimetype'), 'image')) {
$message = new IncomingMessage(Image::PATTERN, $user_id, $channel_id, $this->event);
$message->setIsFromBot($this->isBot());
$message->setImages([$file->get('permalink')]);
$message->setImages([new Image($file->get('permalink'), $file)]);
} elseif (strstr($file->get('mimetype'), 'audio')) {
$message = new IncomingMessage(Audio::PATTERN, $user_id, $channel_id, $this->event);
$message->setIsFromBot($this->isBot());
$message->setAudio([$file->get('permalink')]);
$message->setAudio([new Audio($file->get('permalink'), $file)]);
} elseif (strstr($file->get('mimetype'), 'video')) {
$message = new IncomingMessage(Video::PATTERN, $user_id, $channel_id, $this->event);
$message->setIsFromBot($this->isBot());
$message->setVideos([$file->get('permalink')]);
$message->setVideos([new Video($file->get('permalink'), $file)]);
} else {
$message = new IncomingMessage(\BotMan\BotMan\Messages\Attachments\File::PATTERN, $user_id, $channel_id, $this->event);
$message->setIsFromBot($this->isBot());
$message->setFiles([$file->get('permalink')]);
$message->setFiles([new \BotMan\BotMan\Messages\Attachments\File($file->get('permalink'), $file)]);
}

return [$message];
Expand Down

0 comments on commit e072f98

Please sign in to comment.