Code Monkey home page Code Monkey logo

ph-summary's Introduction

ProductHunt 每日摘要

Twitter Twitter

该项目会在每天中午 12 点抓取 ProductHunt 的当日排名,并将投票前三的产品介绍翻译为中文自动发送到 Twitter 账号 ph_summary 和 Telegram 频道 PHSummary

该项目部署在 Cloudflare Workers 之上,使用了 Cron 定时器在每天中午 11 点 55 分自动执行。如果你也有类似需求或想法,可以以该项目作为参考。

执行时的完整流程如下:

本地测试

  1. 安装依赖
npm install
  1. 配置环境变量,在项目根目录创建 .dev.vars 文件并在 环境变量 中填入正确的值。

  2. 启动服务

npm run start
  1. 测试定时执行脚本
npm run test

如果想要 Telegram 的机器人在频道中发送消息,需要将该机器人添加到频道的管理员中。

部署

直接执行以下命令可将该脚本部署到 Cloudflare Workers 中

npm run deploy

如果是首次部署,在部署成功后,需到该 Worker 的控制台中配置相应的 环境变量

环境变量

该脚本会用到的一些敏感信息,将会使用环境变量的形式进行访问。在本地开发测试时,会使用项目根目录的 .dev.vars 文件作为变量来源。在部署到 Cloudflare Workers 时,可在对应 Worker 中进行配置。具体变量如下:

# Typefully 的 API Key,用于发送推文
TYPEFULLY_API_KEY = XXX
# OpenAI 的 API Key,用于翻译简述到中文
OPENAI_API_KEY = sk-XXX
# Telegram Bot 的 Token,用于向频道中发送消息
TELEGRAM_TOKEN = XXX
# Telegram 的频道用户名,用于指定将要发送消息的频道
TELEGRAM_TARGET_USERNAME = XXX

License

MIT

ph-summary's People

Contributors

noobnooc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.