Git Product home page Git Product logo

ptt-watcher's Introduction

ptt-watcher

訂閱 PTT 文章, 發送至 Slack 或 Line.

Demo

demo-slack demo-line

Highlights

  • 可自訂多組關鍵字查詢條件過濾感興趣的文章
  • 針對不同板面分別設定訂閱條件
  • 透過 RSS feed 更新資料無需帳號密碼

Quickstart

go mod vendor
go build -o ptt-watcher
./ptt-watcher
# Step1: Create your config.json file

# Step2:
eval $(minikube docker-env)
docker build -t ptt-watcher .
kubectl apply -f ptt-watcher.yaml 

編輯設定檔於運行目錄下, 參考範例:

vim config.json

跑起來:

ptt-watcher

Sample config

{
  "notifications": {
    "slack": {
      "token": "YOUR_SLACK_TOKEN",
      "channel": "#ptt",
      "userName": "ptt-watcher"
    },
    "line": {
      "channelSecret": "YOUR_LINE_CHANNEL_SECRET",
      "channelAccessToken": "YOUR_LINE_CHANNEL_ACCESS_TOKEN",
      "toUserId": "USER_ID (you should get this from the webhook service)"
    }
  },
  "subscriptions": [
    {
      "name": "HardwareSale",
      "feedUrl": "http://rss.ptt.cc/HardwareSale.xml",
      "refreshTime": 60,
      "notifyMethods": ["slack"],
      "filters": [
        "賣 DDR3L",
        "賣 i7"
      ]
    },
    {
      "name": "DC_SALE",
      "feedUrl": "http://rss.ptt.cc/DC_SALE.xml",
      "refreshTime": 60,
      "notifyMethods": ["slack", "line"],
      "filters": [
        "賣 5D2"
      ]
    },
    {
      "name": "Beauty",
      "feedUrl": "http://rss.ptt.cc/Beauty.xml",
      "refreshTime": 600,
      "notifyMethods": ["line"],
      "filters": [
        "正妹"
      ]
    }
  ]
}

General

  • name: 訂閱的板面名稱
  • feedUrl: PTT 各板面自己的 RSS feed 網址 (注意大小寫)
  • refreshTime: 更新周期 (單位秒)
  • notifyMethods: 推送通知的管道
  • filters: 查詢方式與 PTT / 語法相同

Slack

  • token: 可在 Slack 網頁介面自行生成
  • channel: 訊息要發送到的 channel 名稱 (注意 # 符號)
  • userName: 要顯示的發送者名稱

Line

  • channelSecret
  • channelAccessToken
  • toUserId: 接收通知的帳號 User ID(非帳號名)

Line 的開發者網頁介面比較鳥,若有設定問題請開 issue。

取得 User ID 最快的方法是跑一個 server 接 webhook,一但有使用者跟 bot 說話就可以從 webhook request log 裡找到 User ID。連 web server 都懶得開的話也可以用 RequestBin

若有更快的方法還請分享給我。:smile:

ptt-watcher's People

Contributors

kfei avatar kevin85421 avatar

Watchers

James Cloos 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.