/**
  * {@inheritdoc}
  */
 protected function createPayload()
 {
     $payload = new ChatPostMessagePayload();
     $payload->setChannel('#acme_channel');
     $payload->setUsername('acme_user');
     $payload->setText('Hello World!');
     $payload->setIconEmoji(':truck:');
     $payload->setLinkNames(true);
     $payload->setParse('full');
     $payload->setUnfurlLinks(true);
     $payload->setUnfurlMedia(false);
     $payload->setIconUrl('http://foo.bar/emoji-1.png');
     $fakeAttachmentField = new AttachmentField();
     $fakeAttachmentField->setShort(false);
     $fakeAttachmentField->setTitle('the title');
     $fakeAttachmentField->setValue('the value');
     $fakeAttachment = new Attachment();
     $fakeAttachment->setTitle('the title');
     $fakeAttachment->setTitleLink('http://thetitlelink.com');
     $fakeAttachment->setColor('the color');
     $fakeAttachment->setFallback('the fallback');
     $fakeAttachment->setImageUrl('the image url');
     $fakeAttachment->setPreText('this is...');
     $fakeAttachment->setText('my attachment');
     $fakeAttachment->setAuthorIcon(':skull:');
     $fakeAttachment->setAuthorName('the author');
     $fakeAttachment->setAuthorLink('http://theauthor.com');
     $fakeAttachment->addField($fakeAttachmentField);
     $payload->addAttachment($fakeAttachment);
     return $payload;
 }
Esempio n. 2
0
 public function notify(DojoCreatedEvent $event)
 {
     $attachment = new Attachment();
     $attachment->setFallback(sprintf('Er is een nieuwe dojo toegevoegd! %s (Website: $s)', $event->getName(), $event->getWebsite()));
     $attachment->setText('Er is een nieuwe dojo toegevoegd, welkom! Is dit jouw dojo? Claim hem op coderdojo.nl');
     $attachment->setColor('good');
     $nameField = new AttachmentField();
     $nameField->setTitle('Name');
     $nameField->setValue($event->getName());
     $nameField->setShort(true);
     $cityField = new AttachmentField();
     $cityField->setTitle('City');
     $cityField->setValue($event->getCity());
     $cityField->setShort(true);
     $emailField = new AttachmentField();
     $emailField->setTitle('Email:');
     $emailField->setValue($event->getEmail());
     $emailField->setShort(true);
     $websiteField = new AttachmentField();
     $websiteField->setTitle('Website');
     $websiteField->setValue($event->getWebsite());
     $websiteField->setShort(true);
     $attachment->addField($nameField);
     $attachment->addField($cityField);
     $attachment->addField($emailField);
     $attachment->addField($websiteField);
     $this->slackService->sendToChannel('#website-nl', '', [$attachment]);
 }
 /**
  * Created notification for slack to keep us up to date on the sync process
  */
 private function notifySlack()
 {
     $message = "Zen synchronizer just handled dojo's.";
     $attachments = [];
     $attachment = new Attachment();
     $attachment->setFallback($this->countNew . " dojo's added.");
     $attachment->setText($this->countNew . " dojo's added.");
     $attachment->setColor('good');
     $attachments[] = $attachment;
     $attachment = new Attachment();
     $attachment->setFallback($this->countUpdated . " dojo's updated.");
     $attachment->setText($this->countUpdated . " dojo's updated.");
     $attachment->setColor('warning');
     $attachments[] = $attachment;
     $attachment = new Attachment();
     $attachment->setFallback($this->countRemoved . " dojo's removed.");
     $attachment->setText($this->countRemoved . " dojo's removed.");
     $attachment->setColor('danger');
     $attachments[] = $attachment;
     $this->slackService->sendToChannel('#website-nl', $message, $attachments);
     foreach ($this->unmatched as $unmatched) {
         $attachment = new Attachment();
         $attachment->setFallback(sprintf('This dojo resulted in multiple internal possibilities: %s (zen: $s)', $unmatched->getName(), $unmatched->getZenId()));
         $attachment->setText('A dojo resulted in multiple internal possibilities');
         $attachment->setColor('danger');
         $nameField = new AttachmentField();
         $nameField->setTitle('Name');
         $nameField->setValue($unmatched->getName());
         $nameField->setShort(true);
         $cityField = new AttachmentField();
         $cityField->setTitle('City');
         $cityField->setValue($unmatched->getCity());
         $cityField->setShort(true);
         $zenIdField = new AttachmentField();
         $zenIdField->setTitle('Zen ID');
         $zenIdField->setValue($unmatched->getZenId());
         $zenIdField->setShort(true);
         $zenUrlField = new AttachmentField();
         $zenUrlField->setTitle('Zen Url');
         $zenUrlField->setValue($unmatched->getZenUrl());
         $zenUrlField->setShort(true);
         $attachment->addField($nameField);
         $attachment->addField($cityField);
         $attachment->addField($zenIdField);
         $attachment->addField($zenUrlField);
         $this->slackService->sendToChannel('#website-nl', 'We couldn\'t match this dojo internally.', [$attachment]);
     }
 }