2
我目前正在使用此slackbot軟件包爲Slack構建一個bot。擴展類以創建自定義功能
目前,它無法構建自定義附件,例如附加圖像。
查看源代碼,Question
類負責構建交互式問題 - 將其全部捆綁到一個準備發送給Slack的數組中。
我希望使用其中的大部分功能來構建一個可以將image_url
添加到數組中的類,但是我從來沒有這樣做過,並且不知道如何執行此操作或從何處開始。
最終,我只是希望能夠使用該包發送消息幷包含圖像附件。
從我可以拼湊,我需要開始是這樣的:
<?php
namespace //namespace;
use Mpociot\SlackBot\Question;
class Attachments extends Question
{
//code to add image URL goes here
/**
* there is currently this function in the Question class
* that builds the array where I need to add in
* 'image_url => 'example.com/image_url'
*/
public function toArray()
{
return [
'text' => $this->text,
'fallback' => $this->fallback,
'callback_id' => $this->callback_id,
'actions' => $this->buttons,
];
}
}
誰能幫我指出了正確的方向,或者幫助我開始使用它?
您可以在https://github.com/iranianpep/給Slackbot框架出手slackbot。它是專門爲Slack編寫的,可能對您的情況有所幫助 – Ehsan