当前位置: 首页>>代码示例>>C#>>正文


C# RedditSharp.Reddit类代码示例

本文整理汇总了C#中RedditSharp.Reddit的典型用法代码示例。如果您正苦于以下问题:C# Reddit类的具体用法?C# Reddit怎么用?C# Reddit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Reddit类属于RedditSharp命名空间,在下文中一共展示了Reddit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AuthenticatedUser

 public AuthenticatedUser(Reddit reddit, JToken json)
     : base(reddit, json)
 {
     Modhash = json["data"]["modhash"].Value<string>();
     HasMail = json["data"]["has_mail"].Value<bool>();
     HasModMail = json["data"]["has_mod_mail"].Value<bool>();
 }
开发者ID:diggforbeer,项目名称:RedditSharpDiggFork,代码行数:7,代码来源:AuthenticatedUser.cs

示例2: Post

        public Post(Reddit reddit, JToken post)
            : base(reddit, post)
        {
            Reddit = reddit;

            var data = post["data"];
            AuthorName = data["author"].Value<string>();
            AuthorFlairClass = data["author_flair_css_class"].Value<string>();
            AuthorFlairText = data["author_flair_text"].Value<string>();
            Domain = data["domain"].Value<string>();
            Edited = data["edited"].Value<bool>();
            IsSelfPost = data["is_self"].Value<bool>();
            LinkFlairClass = data["link_flair_css_class"].Value<string>();
            LinkFlairText = data["link_flair_text"].Value<string>();
            CommentCount = data["num_comments"].Value<int>();
            NSFW = data["over_18"].Value<bool>();
            Permalink = data["permalink"].Value<string>();
            Saved = data["saved"].Value<bool>();
            Score = data["score"].Value<int>();
            SelfText = data["selftext"].Value<string>();
            SelfTextHtml = data["selftext_html"].Value<string>();
            Subreddit = data["subreddit"].Value<string>();
            Thumbnail = data["thumbnail"].Value<string>();
            Title = HttpUtility.HtmlDecode(data["title"].Value<string>());
            Url = data["url"].Value<string>();

            if (data["num_reports"] != null)
                Reports = data["num_reports"].Value<int>();
        }
开发者ID:joeletizia,项目名称:RedditSharp,代码行数:29,代码来源:Post.cs

示例3: Main

 static void Main(string[] args)
 {
     var reddit = new Reddit();
     while (reddit.User == null)
     {
         Console.Write("Username: ");
         var username = Console.ReadLine();
         Console.Write("Password: ");
         var password = ReadPassword();
         try
         {
             Console.WriteLine("Logging in...");
             reddit.LogIn(username, password);
         }
         catch (AuthenticationException)
         {
             Console.WriteLine("Incorrect login.");
         }
     }
     var subreddit = reddit.GetSubreddit("pokemon");
     var posts = subreddit.GetNew();
     foreach (var post in posts.Take(25))
         Console.WriteLine("/u/{0}: (+{1}-{2}:{3}) {4}", post.AuthorName, post.Upvotes, post.Downvotes, post.Score, post.Title);
     Console.ReadKey(true);
 }
开发者ID:hadez378,项目名称:RedditSharp,代码行数:25,代码来源:Program.cs

示例4: GetReddit

        private Reddit GetReddit()
        {
            var reddit = new Reddit(_appSettings.Options.RedditUsername, _appSettings.Options.RedditPassword, true);
            reddit.CaptchaSolver = new CaptchaIgnorer();

            return reddit;
        }
开发者ID:SSWConsulting,项目名称:RedditDL,代码行数:7,代码来源:RedditService.cs

示例5: Post

        public Post(Reddit reddit, JToken post)
            : base(reddit, post)
        {
            Reddit = reddit;

            var data = post["data"];
            AuthorName = data["author"].Value<string>();
            AuthorFlairClass = data["author_flair_css_class"].Value<string>();
            AuthorFlairText = data["author_flair_text"].Value<string>();
            Created = Reddit.UnixTimeStampToDateTime(data["created"].Value<double>());
            Domain = data["domain"].Value<string>();
            Downvotes = data["downs"].Value<int>();
            Edited = data["edited"].Value<bool>();
            IsSelfPost = data["is_self"].Value<bool>();
            LinkFlairClass = data["link_flair_css_class"].Value<string>();
            LinkFlairText = data["link_flair_text"].Value<string>();
            CommentCount = data["num_comments"].Value<int>();
            NSFW = data["over_18"].Value<bool>();
            Permalink = data["permalink"].Value<string>();
            Saved = data["saved"].Value<bool>();
            Score = data["score"].Value<int>();
            SelfText = data["selftext"].Value<string>();
            SelfTextHtml = data["selftext_html"].Value<string>();
            Subreddit = data["subreddit"].Value<string>();
            Thumbnail = data["thumbnail"].Value<string>();
            Title = HttpUtility.HtmlDecode(data["title"].Value<string>());
            Upvotes = data["ups"].Value<int>();
            Url = data["url"].Value<string>();
            Name = data["name"].Value<string>().Replace("t3_", "");
        }
开发者ID:diggforbeer,项目名称:RedditSharpDiggFork,代码行数:30,代码来源:Post.cs

示例6: Launch

 public void Launch()
 {
     var reddit = new Reddit();
     var user = reddit.LogIn("bot_wallpaper", "qwerty");
     var subreddit = reddit.GetSubreddit("/r/botwallpaper");
     DateTime today = DateTime.Today;
     if (today.DayOfWeek == DayOfWeek.Sunday && !sentMessages)
     {
         using (StreamReader sr = new StreamReader("subreddits.txt"))
         {
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 SubredditProcessor wallpaper = new SubredditProcessor(
                     line);
                 wallpaper.Launch();
             }
             Console.WriteLine("ServerListener: Created subreddits");
         }
         sentMessages = true;
     }
     else if (today.DayOfWeek == DayOfWeek.Monday)
     {
         sentMessages = false;
     }
 }
开发者ID:erickchin,项目名称:RedditWallpaperBot,代码行数:26,代码来源:ServerListener.cs

示例7: Post

 public Post(Reddit reddit, JToken post, IWebAgent webAgent)
     : base(reddit, webAgent, post)
 {
     Reddit = reddit;
     WebAgent = webAgent;
     JsonConvert.PopulateObject(post["data"].ToString(), this, reddit.JsonSerializerSettings);
 }
开发者ID:JohnstonB,项目名称:RedditSharp-WP,代码行数:7,代码来源:Post.cs

示例8: Main

 static void Main(string[] args)
 {
     var reddit = new Reddit();
     int backDays;
     try
     {
         reddit.User = reddit.LogIn(ModUserName, ModPassword);
         _sub = reddit.GetSubreddit(SubReddit);
         int.TryParse(ReadBackDays, out backDays);
         if(backDays<1)
         {
             Console.WriteLine("Invalid value for readBackDays in config file. Please enter an integer greater than 0.");
             throw new Exception();
         }
     }
     catch
     {
         Console.WriteLine("Configuration Error. Please confirm values in config file.");
         Console.WriteLine("Press Enter to exit.");
         Console.Read();
         return;
     }
     while (true)
     {
         try
         {
             AssignFlairs(TriggerText, DateTime.Today.AddDays(backDays));
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
         }
     }
 }
开发者ID:Erok21,项目名称:RedditReflairBot,代码行数:34,代码来源:Program.cs

示例9: RedditUser

 public RedditUser(Reddit reddit, JToken json, IWebAgent webAgent)
     : base(json)
 {
     Reddit = reddit;
     WebAgent = webAgent;
     JsonConvert.PopulateObject(json["data"].ToString(), this, reddit.JsonSerializerSettings);
 }
开发者ID:JohnstonB,项目名称:RedditSharp-WP,代码行数:7,代码来源:RedditUser.cs

示例10: SubredditImage

 public SubredditImage(Reddit reddit, SubredditStyle subredditStyle,
     string cssLink, string name)
 {
     Reddit = reddit;
     SubredditStyle = subredditStyle;
     Name = name;
     CssLink = cssLink;
 }
开发者ID:hetelek,项目名称:RedditSharp,代码行数:8,代码来源:SubredditImage.cs

示例11: CreatedThing

        public CreatedThing(Reddit reddit, JToken json)
            : base(json)
        {
            Reddit = reddit;

            var data = json["data"];
            Created = Reddit.UnixTimeStampToDateTime(data["created"].Value<double>());
        }
开发者ID:joeletizia,项目名称:RedditSharp,代码行数:8,代码来源:CreatedThing.cs

示例12: Main

 static void Main(string[] args)
 {
     Reddit reddit = null;
     var authenticated = false;
     while (!authenticated)
     {
         Console.Write("OAuth? (y/n) [n]: ");
         var oaChoice = Console.ReadLine();
         if (!string.IsNullOrEmpty(oaChoice) && oaChoice.ToLower()[0] == 'y')
         {
             Console.Write("OAuth token: ");
             var token = Console.ReadLine();
             reddit = new Reddit(token);
             reddit.InitOrUpdateUser();
             authenticated = reddit.User != null;
             if (!authenticated)
                 Console.WriteLine("Invalid token");
         }
         else
         {
             Console.Write("Username: ");
             var username = Console.ReadLine();
             Console.Write("Password: ");
             var password = ReadPassword();
             try
             {
                 Console.WriteLine("Logging in...");
                 reddit = new Reddit(username, password);
                 authenticated = reddit.User != null;
             }
             catch (AuthenticationException)
             {
                 Console.WriteLine("Incorrect login.");
                 authenticated = false;
             }
         }
     }
     Console.Write("Create post? (y/n) [n]: ");
     var choice = Console.ReadLine();
     if (!string.IsNullOrEmpty(choice) && choice.ToLower()[0] == 'y')
     {
         Console.Write("Type a subreddit name: ");
         var subname = Console.ReadLine();
         var sub = reddit.GetSubreddit(subname);
         Console.WriteLine("Making test post");
         var post = sub.SubmitTextPost("RedditSharp test", "This is a test post sent from RedditSharp");
         Console.WriteLine("Submitted: {0}", post.Url);
     }
     else
     {
         Console.Write("Type a subreddit name: ");
         var subname = Console.ReadLine();
         var sub = reddit.GetSubreddit(subname);
         foreach (var post in sub.GetTop(FromTime.Week).Take(10))
             Console.WriteLine("\"{0}\" by {1}", post.Title, post.Author);
     }
     Console.ReadKey(true);
 }
开发者ID:keneo,项目名称:RedditSharp,代码行数:58,代码来源:Program.cs

示例13: Launch

 public void Launch()
 {
     List<String> title = new List<string>();
     List<String> urls = new List<string>();
     string body = "";
     var reddit = new Reddit();
     var user = reddit.LogIn("bot_wallpaper", "qwerty");
     var subreddit = reddit.GetSubreddit("/r/" + _wallpaperType);
     foreach (var post in subreddit.GetTop(FromTime.Week).Take(25))
     {
         if (_resolution == "null")
         {
             title.Add(post.Title);
             urls.Add(post.Url.ToString());
         }
         else if (post.Title.Contains(_resolution))
         {
             title.Add(post.Title);
             urls.Add(post.Url.ToString());
         }
     }
     for (int i = 0; i < title.Count; i++)
     {
         body += "[" + title[i] + "](" + urls[i] + ") \n\n";
     }
     reddit.ComposePrivateMessage("Wallpapers!", "#Here is the top wallpapers of this week in **/r/" + _wallpaperType + "** \n\n" + body + "\n\n I am a bot!", _username, "", "");
     Console.WriteLine("UserProcessor: Message sent to " + _username);
 }
开发者ID:erickchin,项目名称:RedditWallpaperBot,代码行数:28,代码来源:UserProcessor.cs

示例14: Comment

        public Comment(Reddit reddit, JToken json, IWebAgent webAgent, Thing sender)
            : base(reddit, webAgent, json)
        {
            var data = json["data"];
            JsonConvert.PopulateObject(data.ToString(), this, reddit.JsonSerializerSettings);
            Reddit = reddit;
            WebAgent = webAgent;

            // Parse sub comments
            // TODO: Consider deserializing this properly
            var subComments = new List<Comment>();
            if (data["replies"] != null && data["replies"].Any())
            {
                foreach (var comment in data["replies"]["data"]["children"])
                    subComments.Add(new Comment(reddit, comment, webAgent, sender));
            }
            Comments = subComments.ToArray();

            this.Parent = sender;

            // Handle Reddit's API being horrible
            if (data["context"] != null)
            {
                var context = data["context"].Value<string>();
                LinkId = context.Split('/')[4];
            }
        }
开发者ID:JohnstonB,项目名称:RedditSharp-WP,代码行数:27,代码来源:Comment.cs

示例15: VotableThing

 public VotableThing(Reddit reddit, IWebAgent webAgent, JToken json)
     : base(reddit, json)
 {
     Reddit = reddit;
     WebAgent = webAgent;
     JsonConvert.PopulateObject(json["data"].ToString(), this, Reddit.JsonSerializerSettings);
 }
开发者ID:AndreCAndersen,项目名称:RedditSharp,代码行数:7,代码来源:VotableThing.cs


注:本文中的RedditSharp.Reddit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。