[英]Hubot Slack attachment fields
Basically, this is what I want to achieve in Slack using Hubot. 基本上, 这就是我想使用Hubot在Slack中实现的目标。 I've tried using
我试过使用
attachment =
fields: [
{
title: "User info"
value: json.user
short: false
}
]
But this doesn't work. 但这是行不通的。 Does someone have an example of how I can make this work?
有人举我如何做这项工作的例子吗?
Thanks in advance ^^ 在此先感谢^^
Solved it by using 通过使用解决
$attachments = [
'text' => "Active codebases: (total = $total)",
'attachments' => [
[
'color' => '#3333ff',
'fields' => [
]
]
]
];
And then inserted data using 然后使用插入数据
$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.