2016-09-21 2 views
0

基本的に、 thisは、Hubotを使用してSlackで達成したいものです。私は試しましたHubot Slack attachment fields

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

しかし、これは動作しません。 誰かが私がこの仕事をどのようにすることができるかの例を持っていますか?事前に

おかげで^^

答えて

0

$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; 
      } 
     } 
を使用してデータを挿入しました