{
  "name": "GitHub Trending (\u5907\u9009\u63a5\u53e3\u52a0\u901f\u7248)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24
            }
          ]
        }
      },
      "id": "schedule-trigger-id",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [
        300,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://github-trending-api.com/repositories",
        "options": {}
      },
      "id": "github-fetch-id",
      "name": "Fetch GitHub Trending",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal/",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "app_id",
              "value": "={{ $env.FEISHU_APP_ID }}"
            },
            {
              "name": "app_secret",
              "value": "={{ $env.FEISHU_APP_SECRET }}"
            }
          ]
        },
        "options": {}
      },
      "id": "feishu-token-id",
      "name": "Get Feishu Token",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        700,
        200
      ]
    },
    {
      "parameters": {
        "jsCode": "const repos = $node[\"Fetch GitHub Trending\"].all();\nconst tokenData = $node[\"Get Feishu Token\"].first().json;\n\nlet cardElements = [];\n\n// \u683c\u5f0f\u5316\u524d 10 \u4e2a\u70ed\u95e8\u9879\u76ee\nrepos.slice(0, 10).forEach((repo, index) => {\n    const data = repo.json;\n    cardElements.push({\n        \"tag\": \"div\",\n        \"text\": {\n            \"content\": `**${index + 1}. [${data.author}/${data.name}](${data.url})** (${data.language || 'Unknown'})\\n${data.description || '\u65e0\u63cf\u8ff0'}\\n\u2b50 Stars: ${data.stars} | \ud83c\udf74 Forks: ${data.forks}`,\n            \"tag\": \"lark_md\"\n        }\n    });\n    cardElements.push({ \"tag\": \"hr\" });\n});\n\nif (cardElements.length > 0) cardElements.pop();\n\nconst card = {\n    header: {\n        title: {\n            \"content\": \"\ud83d\udc19 GitHub Daily Trending (Stable)\",\n            \"tag\": \"plain_text\"\n        },\n        template: \"blue\"\n    },\n    elements: cardElements,\n    footer: {\n        \"tag\": \"note\",\n        \"elements\": [{ \"tag\": \"plain_text\", \"content\": \"\u6570\u636e\u6765\u6e90\uff1aStable API \u00b7 \u6765\u81ea n8n\" }]\n    }\n};\n\nreturn [{\n    json: {\n        token: tokenData.tenant_access_token,\n        chat_id: $env.FEISHU_CHAT_ID,\n        msg_type: \"interactive\",\n        content: JSON.stringify(card)\n    }\n}];"
      },
      "id": "format-card-id",
      "name": "Format Feishu Card",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.token }}"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "receive_id",
              "value": "={{ $json.chat_id }}"
            },
            {
              "name": "msg_type",
              "value": "={{ $json.msg_type }}"
            },
            {
              "name": "content",
              "value": "={{ $json.content }}"
            }
          ]
        },
        "options": {}
      },
      "id": "send-message-id",
      "name": "Send Feishu Message",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        1100,
        300
      ]
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Fetch GitHub Trending",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch GitHub Trending": {
      "main": [
        [
          {
            "node": "Get Feishu Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Feishu Token": {
      "main": [
        [
          {
            "node": "Format Feishu Card",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Feishu Card": {
      "main": [
        [
          {
            "node": "Send Feishu Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "timezone": "Asia/Shanghai"
  }
}