Hubot Slack 附件字段
Hubot Slack attachment fields
基本上,
this 是我想在 Slack 中使用 Hubot 实现的。我试过使用
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;
}
}
基本上, this 是我想在 Slack 中使用 Hubot 实现的。我试过使用
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;
}
}