Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Newtonsoft.Json.Linq;
- using System; //Copyright 2015 (c) NorbiPeti
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- /*
- * This project uses data from karmadecay.com which I found in Karmancer which I was pointed to by Nathan_Heburn (Minecraft name)
- * And it also uses Newtonsoft.Json
- * And someone should translate it to Java
- */
- namespace TheButtonMCAutoFlairProto
- {
- class Program
- { //2015.07.13.
- //public static int LastUpdate;
- //public static int CommentCount = 0;
- //public static string LastComment = "";
- static void Main(string[] args)
- {
- while(true)
- {
- DownloadFlairs();
- Thread.Sleep(5000);
- Console.Clear();
- }
- //Console.ReadLine();
- }
- public static void DownloadFlairs()
- {
- Console.WriteLine("Downloading information...");
- try
- {
- //string data = new WebClient().DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?count=" + CommentCount + "&after=" + LastComment);
- string data = new WebClient().DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json");
- var obj = JArray.Parse(data)[1];
- var array = obj["data"]["children"];
- foreach (JObject item in array)
- {
- string author = item["data"]["author"].ToString();
- string ign = item["data"]["body"].ToString();
- int start = ign.IndexOf("IGN:") + "IGN:".Length;
- int end = ign.IndexOf(' ', start);
- if (end == -1 || end == start)
- ign = ign.Substring(start);
- else
- ign = ign.Substring(start, end);
- ign = ign.Trim();
- //Console.WriteLine("IGN: " + ign);
- //LastComment = item["data"]["name"].ToString();
- //CommentCount++;
- if (HasIGFlair(ign))
- continue;
- string[] flairdata = new WebClient().DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).Replace("\"", "").Split(':');
- string flair = flairdata[1];
- if (flair != "-1")
- flair = flair + "s";
- else
- flair = "non-presser";
- string flairclass = flairdata[2];
- SetFlair(ign, flair, flairclass);
- }
- Console.WriteLine("Done!");
- }
- catch(Exception e)
- {
- Console.WriteLine("Error!\n" + e);
- }
- }
- /// <summary>
- /// Placeholder
- /// </summary>
- /// <param name="message"></param>
- public static void TellPlayer(string playername, string message)
- {
- Console.WriteLine("TellPlayer: (to: " + playername + ") " + message);
- }
- /// <summary>
- /// Placeholder
- /// </summary>
- /// <param name="flair"></param>
- public static void SetFlair(string playername, string flair, string flaircolor)
- {
- Console.WriteLine("SetFlair called (to: " + playername + "): " + flair + " - Class: " + flaircolor);
- }
- public static bool HasIGFlair(string playername)
- {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement