0reddit 中文文档教程

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

0reddit

NPM 版本

snoowrap 的一个小扩展,带有一些简化的 reddit API 函数。

Screenshot

Install

npm i 0reddit

Use

const snoowrap = require("snoowrap");
const $reddit = require("0reddit");

const requester = new snoowrap({
  /* OAuth credentials here */
});
const $subreddit = $reddit(requester, "SomeSubreddit");

// Submit a link
const submission = await $subreddit.submitLink({
  title: "Wracurd",
  url: "https://example.com/wracurd.jpg",
  oc: true,
  flairs: ["artwork", "comic", "color"],
});

// Get own newest submission
const myLatestSubmission = await $subreddit.getNewByMe({ one: true });

API

  • reddit(requester, subredditName) :创建一个包含函数的对象。

  • 请求者:snoowrap :Snoowrap 请求者对象。

  • subredditName: String : Subreddit 名称(不带 r/ 前缀)。

  • await submitLink(post) :提交链接帖子。

  • post: Object :描述链接帖子的对象。

    • title: String : post title.
    • url: String : post link.
    • oc?: Boolean : If true, mark post as OC.
    • flairs?: String[] : Texts of flairs to assign to post.
  • await getNewByMe(options) :获取自己的新提交。

  • options?: 对象:选项对象。

    • one?: Boolean : If true, return the first submission object (Instead of Array).
    • limit?: Number : Maximum number of submissions to retrieve.
  • await markAsOC(submission) :将提交标记为 OC。

  • 提交:提交:Snowrap 提交

  • await applyFlairs(submission, flairsTexts) :将 flairs 分配给提交。

  • 提交:提交:Snowrap 提交

  • flairsTexts: String[]:天赋文本数组。

License

麻省理工学院 © Ambratolm

???? 0reddit

NPM version

A small extension of snoowrap with some simplified reddit API functions.

Screenshot

???? Install

npm i 0reddit

???? Use

const snoowrap = require("snoowrap");
const $reddit = require("0reddit");

const requester = new snoowrap({
  /* OAuth credentials here */
});
const $subreddit = $reddit(requester, "SomeSubreddit");

// Submit a link
const submission = await $subreddit.submitLink({
  title: "Wracurd",
  url: "https://example.com/wracurd.jpg",
  oc: true,
  flairs: ["artwork", "comic", "color"],
});

// Get own newest submission
const myLatestSubmission = await $subreddit.getNewByMe({ one: true });

???? API

  • reddit(requester, subredditName) : Create an object containing the functions.

  • requester: snoowrap : Snoowrap requester object.

  • subredditName: String : Subreddit name (without r/ prefix).

  • await submitLink(post) : Submit a link post.

  • post: Object : Object describing a link post.

    • title: String : post title.
    • url: String : post link.
    • oc?: Boolean : If true, mark post as OC.
    • flairs?: String[] : Texts of flairs to assign to post.
  • await getNewByMe(options) : Get own new submissions.

  • options?: Object: Options object.

    • one?: Boolean : If true, return the first submission object (Instead of Array).
    • limit?: Number : Maximum number of submissions to retrieve.
  • await markAsOC(submission) : Mark a submission as OC.

  • submission: Submission : Snowrap submission.

  • await applyFlairs(submission, flairsTexts) : assign flairs to a submissions.

  • submission: Submission : Snowrap submission.

  • flairsTexts: String[] : Array of flairs texts.

???? License

MIT © Ambratolm

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