【问题标题】:Hubot Slack attachment fieldsHubot Slack 附件字段
【发布时间】:2017-01-29 14:06:57
【问题描述】:

基本上, this 是我想在 Slack 中使用 Hubot 实现的目标。我试过使用

      attachment = 
        fields: [
              {
                title: "User info"
                value: json.user
                short: false
              }
        ]

但这不起作用。 有人有我如何使这项工作的示例吗?

提前致谢^^

【问题讨论】:

    标签: coffeescript slack hubot


    【解决方案1】:

    通过使用解决了它

    $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;
                }
            }
    

    【讨论】:

      猜你喜欢
      • 2017-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-20
      • 1970-01-01
      • 2018-09-21
      • 2018-02-08
      • 2023-03-06
      相关资源
      最近更新 更多