Hubot Slack附件字段

时间:2016-09-21 10:55:57

标签: coffeescript slack hubot

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

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

但这不起作用。 有人有一个如何使我的工作成功的例子吗?

提前致谢^^

1 个答案:

答案 0 :(得分:0)

使用

解决了这个问题
        $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;
            }
        }

然后使用

插入数据
SELECT zip, primary_city, latitude, longitude,
      111.045* DEGREES(ACOS(COS(RADIANS(latpoint))
                 * COS(RADIANS(latitude))
                 * COS(RADIANS(longpoint) - RADIANS(longitude))
                 + SIN(RADIANS(latpoint))
                 * SIN(RADIANS(latitude)))) AS distance_in_km
 FROM zip
 JOIN (
     SELECT  42.81  AS latpoint,  -70.81 AS longpoint
   ) AS p ON 1=1
 ORDER BY distance_in_km;