Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.11 KB

Crosspost.md

File metadata and controls

52 lines (35 loc) · 1.11 KB

Simple Crosspost

Author

Kris Craig

Required libraries

Overview

Cross-posts the day's top post on r/news to r/MySub.

Library Installation

In the NuGet Package Manager console:

Install-Package Reddit

The Code

using Reddit;

...

var reddit = new RedditClient("YourRedditAppID", "YourBotUserRefreshToken");

// Since we only need the posts, there's no need to call .About() on this one.  --Kris
var news = reddit.Subreddit("news");

/*
 * If you call GetTop() directly, the last "t" value you passed will be used for the .Top property.
 * Remember that the .Top property is automatically cached with the results of GetTop(), so we're 
 * only doing one API query for the posts retrieval part.
 * 
 * --Kris
 */
if (news.Posts.GetTop(t: "day")[0].Listing.IsSelf)
{
	var newSelfPost = news.SelfPost(news.Posts.Top[0].Fullname).About().XPostTo("MySub");
}
else
{
	var newLinkPost = news.LinkPost(news.Posts.Top[0].Fullname).About().XPostTo("MySub");
}

Source File

Crosspost.cs