Glanceway Glanceway
所有信息源

华尔街见闻

财经 v1.0.0

华尔街见闻 7x24 快讯

@codytseng #finance #news #chinese #market

配置项

名称 类型 必填 默认值 描述
频道 CHANNEL select global-channel 关注的新闻频道
global-channela-stock-channelus-stock-channelforex-channelcommodity-channelhk-stock-channel

源代码

version: 1.0.0
name: 华尔街见闻
description: 华尔街见闻 7x24 快讯
author: codytseng
author_url: https://github.com/codytseng
category: Finance
tags:
  - finance
  - news
  - chinese
  - market

config:
  - key: CHANNEL
    name: 频道
    type: select
    required: false
    default: global-channel
    description: 关注的新闻频道
    options:
      - global-channel
      - a-stock-channel
      - us-stock-channel
      - forex-channel
      - commodity-channel
      - hk-stock-channel
module.exports = async (api) => {
  const channel = api.config.get("CHANNEL") || "global-channel";

  async function fetchData() {
    const res = await api.fetch(
      `https://api-one.wallstcn.com/apiv1/content/lives?channel=${channel}&limit=200`,
    );
    if (!res.ok || !res.json) {
      throw new Error(`Failed to fetch wallstreetcn news (HTTP ${res.status})`);
    }

    const items = res.json.data.items.map((item) => ({
      id: String(item.id),
      title: item.title,
      subtitle: item.content_text,
      url: item.uri,
      timestamp: item.display_time,
    }));

    api.emit(items);
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};