Exemplo n.º 1
0
        public static string Status(string username)
        {
            Donor d = GetDonor(username);

            if (d == null)
            {
                return("You are not a donor, use /donate to become one");
            }
            if (d.Expire > DateTime.Now)
            {
                return("You are a donor level " + d.Slots + " for " + (d.Expire - DateTime.Now).TotalDays.ToString("0") + " more days");
            }
            if (d.ExpireLegacy > DateTime.Now)
            {
                return("You are a major donor, it expired " + (DateTime.Now - d.Expire).TotalDays.ToString("0") + " days ago");
            }
            return(Chat.Purple + "You are no longer a donor, it expired " + (DateTime.Now - d.Expire).TotalDays.ToString("0") + " days ago");
        }
Exemplo n.º 2
0
 public static int CompareLongestFirst(Donor a, Donor b)
 {
     return DateTime.Compare(b.Expire, a.Expire);
 }
Exemplo n.º 3
0
        public static void LoadDonors()
        {
            if (File.Exists(DonorsPath) == false)
            {
                return;
            }

            Dictionary <string, Donor> l = new Dictionary <string, Donor>();

            //Read all donor statuses
            foreach (string u in System.IO.File.ReadAllLines(DonorsPath, System.Text.Encoding.UTF8))
            {
                if (u.Contains(" "))
                {
                    continue;
                }
                if (u.StartsWith("#"))
                {
                    continue;
                }
                string[] parts = u.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length < 3)
                {
                    continue;
                }

                Donor d = new Donor();
                d.Username = parts [0].ToLowerInvariant();

                if (int.TryParse(parts [1], out d.Slots) == false)
                {
                    continue;
                }

                if (DateTime.TryParse(parts [2], out d.Expire) == false)
                {
                    continue;
                }

                if (d.Expire < DateTime.Now)
                {
                    d.Slots = 0;
                }

                if (parts.Length < 4)
                {
                    d.ExpireLegacy = d.Expire;
                }
                else
                if (DateTime.TryParse(parts [3], out d.ExpireLegacy) == false)
                {
                    continue;
                }

                //Duplicate, keep the longest one
                if (l.ContainsKey(d.Username))
                {
                    //Merge
                    var d2 = l [d.Username];

                    if (d.ExpireLegacy > d2.ExpireLegacy)
                    {
                        d2.ExpireLegacy = d.ExpireLegacy;
                    }

                    if (d.Expire > d2.Expire)
                    {
                        d2.Expire = d.Expire;
                    }

                    d2.Slots += d.Slots;

                    //Merge done
                    continue;
                }

                l.Add(d.Username, d);
            }
            Donors.Update(l);
        }
Exemplo n.º 4
0
        public static void LoadDonors()
        {
            if (File.Exists(DonorsPath) == false)
                return;

            Dictionary<string,Donor> l = new Dictionary<string, Donor>();

            //Read all donor statuses
            foreach (string u in System.IO.File.ReadAllLines(DonorsPath, System.Text.Encoding.UTF8))
            {
                if (u.Contains(" "))
                    continue;
                if (u.StartsWith("#"))
                    continue;
                string[] parts = u.Split(new char[]{'\t'}, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length < 3)
                    continue;
                
                Donor d = new Donor();
                d.Username = parts [0].ToLowerInvariant();
                
                if (int.TryParse(parts [1], out d.Slots) == false)
                    continue;

                if (DateTime.TryParse(parts [2], out d.Expire) == false)
                    continue;
                 
                if (d.Expire < DateTime.Now)
                    d.Slots = 0;

                if (parts.Length < 4)
                    d.ExpireLegacy = d.Expire;
                else
                    if (DateTime.TryParse(parts [3], out d.ExpireLegacy) == false)
                    continue;

                //Duplicate, keep the longest one
                if (l.ContainsKey(d.Username))
                {
                    //Merge
                    var d2 = l [d.Username];

                    if (d.ExpireLegacy > d2.ExpireLegacy)
                        d2.ExpireLegacy = d.ExpireLegacy;

                    if (d.Expire > d2.Expire)
                    {
                        d2.Expire = d.Expire;
                    }

                    d2.Slots += d.Slots;

                    //Merge done
                    continue;
                }

                l.Add(d.Username, d);
            }
            Donors.Update(l);
        }
Exemplo n.º 5
0
 public static int CompareLongestFirst(Donor a, Donor b)
 {
     return(DateTime.Compare(b.Expire, a.Expire));
 }