示例#1
0
        /// <summary>
        /// Gets all tribes from a server
        /// </summary>
        /// <param name="guildid"></param>
        /// <param name="sData"></param>
        /// <returns></returns>
        public static List <TribeData> GetTribes(ulong guildid, ServerData sData)
        {
            List <TribeData> rg = new List <TribeData>();

            if (Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\"))
            {
                string[] tribes = Directory.GetDirectories(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\");
                foreach (string s in tribes)
                {
                    if (File.Exists(s + "\\servers.txt"))
                    {
                        bool found = false;
                        foreach (string server in File.ReadAllText(s + "\\servers.txt").Split('\n'))
                        {
                            if (server.CompareTo(sData.Name) == 0)
                            {
                                found = true;
                            }
                        }
                        if (found)
                        {
                            rg.Add(new TribeData()
                            {
                                GuildID  = guildid,
                                ID       = int.Parse(s.Split("\\/".ToCharArray())[s.Split("\\/".ToCharArray()).Length - 1]),
                                name     = File.ReadAllText(s + "\\name.txt"),
                                relation = Compfort.IntToRelationship(int.Parse(File.ReadAllText(s + "\\relation.txt")))
                            });
                        }
                    }
                }
            }
            return(rg);
        }
示例#2
0
 /// <summary>
 /// Gets the relationship of a tribe
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="tribeID"></param>
 /// <returns></returns>
 public static Relationship GetRelationship(ulong guildid, int tribeID)
 {
     if (Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribeID))
     {
         return(Compfort.IntToRelationship(int.Parse(File.ReadAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\" + tribeID + "\\relation.txt"))));
     }
     return(Relationship.unknown);
 }
示例#3
0
        /// <summary>
        /// Returns all tribes in a guild(discord server)
        /// </summary>
        /// <param name="guildid"></param>
        /// <returns></returns>
        public static List <TribeData> GetTribes(ulong guildid)
        {
            List <TribeData> rg = new List <TribeData>();

            if (Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\"))
            {
                string[] tribes = Directory.GetDirectories(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\Tribes\\");
                foreach (string s in tribes)
                {
                    rg.Add(new TribeData()
                    {
                        GuildID  = guildid,
                        ID       = int.Parse(s.Split("\\/".ToCharArray())[s.Split("\\/".ToCharArray()).Length - 1]),
                        name     = File.ReadAllText(s + "\\name.txt"),
                        relation = Compfort.IntToRelationship(int.Parse(File.ReadAllText(s + "\\relation.txt")))
                    });
                }
            }
            return(rg);
        }
示例#4
0
        /// <summary>
        /// Returns the data for a certain steamid
        /// </summary>
        /// <param name="guilid"></param>
        /// <returns></returns>
        public static SteamIDData GetSteamID(ulong guildid, ulong steamid)
        {
            SteamIDData rg = new SteamIDData {
                SteamID = steamid
            };

            if (Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid))
            {
                if (File.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid + "\\Name.txt"))
                {
                    rg.name = File.ReadAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid + "\\Name.txt");
                }
                if (File.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid + "\\Relationship.txt"))
                {
                    rg.relation = Compfort.IntToRelationship(int.Parse(File.ReadAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid + "\\Relationship.txt")));
                }
                if (File.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid + "\\Tribe.txt"))
                {
                    rg.tribe = Compfort.GetTribeByID(guildid, int.Parse(File.ReadAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid + "\\Tribe.txt")));
                }
            }
            return(rg);
        }
示例#5
0
        /// <summary>
        /// Returns all alerts created for a server
        /// </summary>
        /// <param name="sData"></param>
        /// <returns></returns>
        public static List <AlertData> GetAlerts(ServerData sData)
        {
            List <AlertData> rg = new List <AlertData>();

            if (Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\"))
            {
                foreach (string guilddir in Directory.GetDirectories(AppContext.BaseDirectory + "\\Guilds\\"))
                {
                    if (File.Exists(guilddir + "\\alerts.txt"))
                    {
                        ulong guildid = ulong.Parse(guilddir.Split("\\/".ToCharArray())[guilddir.Split("\\/".ToCharArray()).Length - 1]);
                        foreach (string alert in File.ReadAllLines(guilddir + "\\alerts.txt"))
                        {
                            if (sData.Name.CompareTo(alert.Split(';')[0]) == 0)
                            {
                                rg.Add(new AlertData(guildid, ulong.Parse(alert.Split(';')[2]), Compfort.IntToRelationship(int.Parse(alert.Split(';')[1])), alert.Split(';')[3]));
                            }
                        }
                    }
                }
            }
            return(rg);
        }
示例#6
0
 /// <summary>
 /// Deletes an alert, the alert is already getting removed out of the cache at an other location
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="relation"></param>
 /// <param name="sData"></param>
 public static void DeleteAlert(ulong guildid, ulong channelid, Relationship relation, ServerData sData)
 {
     if (!Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\"))
     {
         Directory.CreateDirectory(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\");
     }
     if (File.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\alerts.txt"))
     {
         string[] alerts  = File.ReadAllLines(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\alerts.txt");
         string   newfile = "";
         foreach (string alert in alerts)
         {
             if (ulong.Parse(alert.Split(':')[2]) != channelid && relation.CompareTo(Compfort.IntToRelationship(int.Parse(alert.Split(':')[1]))) == 0)
             {
                 if (newfile != "")
                 {
                     newfile += ",";
                 }
                 newfile += alert;
             }
         }
         if (newfile.Length > 0)
         {
             File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\alerts.txt", newfile);
         }
         else
         {
             File.Delete(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\alerts.txt");
         }
     }
 }