示例#1
0
        /// <summary>
        /// Gets all of the boards
        /// </summary>
        public void StartRunningBot()
        {
            ////////////////////////////////////////////
            //Test Code
            //AwardPost("CdEG5wxA93h7jj2BjBunLWgZy1pdfPoHAN", "22323232", 0.1);
            ////////////////////////////////////////////

            WriteToLog("Starting up");
            logger.Info("Starting up");
            BoardRootObject BoardsRootObject = FourChinCore.GetBoard();

            //for each board, parse it.
            foreach (Board board in BoardsRootObject.Boards)
            {
                ParseBoard(board.BoardName);
            }

            lastRun = (ulong)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            Properties.Settings.Default.LastRun = lastRun;
            Properties.Settings.Default.Save();
        }
示例#2
0
        /// <summary>
        /// Main method that will parse the board for any gets.
        /// Starts by collecting all of the threads on the board at this time. For each thread, if
        /// the last modified date is more recent than the previous run, request the posts for that thread.
        /// Iterate through the posts looking for posters that have the correct $4CHN: prefix. If they do,
        /// check for a get. Award the user if they got a get.
        /// </summary>
        /// <param name="board"></param>
        public static void ParseBoard(string board)
        {
            //get all the threads from the passed in board
            List <Thread> threads = FourChinCore.GetAllThreadsFromBoard(board);

            if (threads != null)
            {
                foreach (Thread thread in threads)
                {
                    //Check if the last modified time is greater than the last run of the bot
                    ulong LastModified = ulong.Parse(thread.LastModified);
                    if (LastModified > lastRun)
                    {
                        //get the full details about the thread
                        Thread fullThread = FourChinCore.GetThread(board, thread.ThreadNumber);
                        WriteToLog("Parsing Thread: " + thread.ThreadNumber + " - Board: " + board);

                        foreach (Post post in fullThread.Posts)
                        {
                            //for each post, check to see if the poster's name has their address
                            string posterName = post.Name;
                            if (posterName != null && posterName.StartsWith("$4CHN:"))
                            {
                                string walletAddress = posterName.Replace("$4CHN:", "");
                                WriteToLog("Found wallet - " + walletAddress);

                                //if the user has their address, check to see if they got a get
                                CheckAndHandleGet(post.PostNumber, walletAddress);
                            }
                        }
                    }
                    else
                    {
                        WriteToLog("Thread has been parsed already");
                    }
                }
            }
        }