4chan-full 中文文档教程

发布于 3年前 浏览 23 项目主页 更新于 3年前

4CHAN-FULL ????

www.4chan.org 非官方只读 api。


Installation

npm install 4chan-full

Possibilities

Example Codes

那个小脚本列出了线程的所有文件..

const { fchf } = require("4chan-full");

(async () => {
  const thread = await fchf.thread("wg", "7694540");

  // thread.file -> Thread owner (OP) file.
  // thread.replies[?].file -> reply file.

  const files = [thread.file, ...thread.replies.map((i) => i?.file)].filter(
    (i) => i != null
  );

  console.log(files);
})();

那个小脚本监视线程的新回复..

const { fchf } = require("4chan-full");

(async () => {
  let watcher = fchf.threadWatcher("vg", "337012489");

  // Events: updated, nowUpdated, checked, error, #start, #stop

  watcher.on("updated", (oldThread, newThread) => {
    console.log({ oldThread, newThread });
  });

  watcher.on("notUpdated", () => {
    console.log("there is no new replies..");
  });

  watcher.on("checked", (oldThread, newThread) => {
    console.log("checked new checkInterval:", watcher.checkInterval);
  });

  watcher.start();
})();

TODO

  • [x] Full Code REWRITE
  • [x] Parse Message Contents (Quotes etc.)
  • [x] Thread Update Watcher
  • [ ] Board Update Watcher

Type List

HUGE Update 1.2.0

  • Thread Watcher
  • Update Boards
  • Bug fixes

Update 1.1.1

  • Parse Message Contents
  • Add Type List To README MD

HUGE Update 1.1.0

  • Full Rewrite API
  • Update README MD

4CHAN-FULL ????

www.4chan.org non-official read only api.


Installation

npm install 4chan-full

Possibilities

Example Codes

That small script lists all files of the thread..

const { fchf } = require("4chan-full");

(async () => {
  const thread = await fchf.thread("wg", "7694540");

  // thread.file -> Thread owner (OP) file.
  // thread.replies[?].file -> reply file.

  const files = [thread.file, ...thread.replies.map((i) => i?.file)].filter(
    (i) => i != null
  );

  console.log(files);
})();

That small script watches the thread for new replies..

const { fchf } = require("4chan-full");

(async () => {
  let watcher = fchf.threadWatcher("vg", "337012489");

  // Events: updated, nowUpdated, checked, error, #start, #stop

  watcher.on("updated", (oldThread, newThread) => {
    console.log({ oldThread, newThread });
  });

  watcher.on("notUpdated", () => {
    console.log("there is no new replies..");
  });

  watcher.on("checked", (oldThread, newThread) => {
    console.log("checked new checkInterval:", watcher.checkInterval);
  });

  watcher.start();
})();

TODO

  • [x] Full Code REWRITE
  • [x] Parse Message Contents (Quotes etc.)
  • [x] Thread Update Watcher
  • [ ] Board Update Watcher

Type List

HUGE Update 1.2.0

  • Thread Watcher
  • Update Boards
  • Bug fixes

Update 1.1.1

  • Parse Message Contents
  • Add Type List To README MD

HUGE Update 1.1.0

  • Full Rewrite API
  • Update README MD
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文