[英]Hubot Slack attachment fields
基本上, 這就是我想使用Hubot在Slack中實現的目標。 我試過使用
attachment =
fields: [
{
title: "User info"
value: json.user
short: false
}
]
但這是行不通的。 有人舉我如何做這項工作的例子嗎?
在此先感謝^^
通過使用解決
$attachments = [
'text' => "Active codebases: (total = $total)",
'attachments' => [
[
'color' => '#3333ff',
'fields' => [
]
]
]
];
然后使用插入數據
$items = $codebases;
foreach ($items as $item)
{
if(LinkedUser::where('codebase_id', $item->id)->get() !== null) {
$linkedusers = LinkedUser::where('codebase_id', $item->id)->get();
$userlist = "";
$i = 0;
$len = count($linkedusers);
foreach ($linkedusers as $linkeduser)
{
if ($i == $len - 1) {
$userlist .= $linkeduser->user_name;
} else {
$userlist .= $linkeduser->user_name . ",\n";
}
$i++;
}
$a = [
'title' => $item->name,
'value' => $userlist,
'short' => true
];
$attachments['attachments'][0]['fields'][] = $a;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.