示例#1
0
 public static async Task ReplyOnBirthDay(Comment comment)
 {
     if (!Core.ListOfNames.Contains(comment.AuthorName) && !Redditor.ImBot(comment.AuthorName))
     {
         NonApiTasks.CreateLog($"Comments count: {comment.Comments.Count}. Current comment: {comment.Shortlink}");
         await Task.Run(() =>
         {
             if (Redditor.HasBirthtDayToday(comment.AuthorName) && Redditor.NameIsLegal(comment.AuthorName))
             {
                 Core.ListOfNames.Add(comment.AuthorName);
                 try
                 {
                     comment.Reply(NonApiTasks.InsertNameInto_ASCII_Art(comment.AuthorName + "!"));
                 }
                 catch (Exception e)
                 {
                     NonApiTasks.CreateExceptionLog(e);
                     throw;
                 }
                 NonApiTasks.CreateLog($"SENT TO: {comment.Shortlink}" + Environment.NewLine);
             }
             else
             {
                 NonApiTasks.CreateLog($"I DID NOT SEND: {comment.Shortlink}" + Environment.NewLine);
             }
         });
     }
 }
示例#2
0
        public static int[] GetDateOfAccountCreation(string name)
        {
            int[] output = new int[3];
            try
            {
                WebClient web = new WebClient();
                string    url = "http://www.reddit.com/user//about.json";
                url = url.Insert(27, name);

                var      json              = web.DownloadString(url);
                dynamic  data              = JObject.Parse(json);
                double   unixTime          = Convert.ToDouble(data.data.created_utc);
                DateTime convertedFromUnix = NonApiTasks.UnixTimeStampToDateTime(unixTime);

                output[0] = convertedFromUnix.Month;
                output[1] = convertedFromUnix.Day;
                output[2] = convertedFromUnix.Year;
                return(output);
            }
            catch
            {
                // Why these weird values are here? It is just 210th month, 100th day and 333th year, thus its impossible so bot won't reply anyway
                // he's using those kind of random values when something "unexpected" happened.
                // Need to be done better.
                output[0] = 210;
                output[1] = 100;
                output[2] = 333;
                return(output);
            }
        }
示例#3
0
 public static async Task GoingIntoChainOfComments(Comment comment)
 {
     if (comment.Comments.Count > 0)
     {
         foreach (Comment commentChain in comment.Comments)
         {
             if (!string.IsNullOrEmpty(commentChain.AuthorName))
             {
                 NonApiTasks.CreateLog($"Going into chain: {commentChain.Shortlink}" + Environment.NewLine);
                 await CommentManagement(commentChain);
             }
         }
     }
 }