Exemplo n.º 1
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");
         }
     }
 }
Exemplo n.º 2
0
 public bool HasRelation()
 {
     if (relation.CompareTo(Relationship.invalid) != 0)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Sets the relationship of a steamid
 /// </summary>
 /// <param name="guildid"></param>
 /// <param name="tribe"></param>
 /// <param name="relation"></param>
 public static void SetRelationship(ulong guildid, SteamIDData steamid, Relationship relation)
 {
     if (!Directory.Exists(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID))
     {
         Directory.CreateDirectory(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID);
     }
     if (relation.CompareTo(Relationship.invalid) != 0 && relation.CompareTo(Relationship.unknown) != 0)
     {
         File.WriteAllText(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID + "\\Relationship.txt", ((int)relation).ToString());
     }
     else
     {
         File.Delete(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID + "\\Relationship.txt");
         if (Directory.GetFiles(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID).Length == 0)
         {
             Directory.Delete(AppContext.BaseDirectory + "\\Guilds\\" + guildid + "\\SteamIDs\\" + steamid.SteamID);
         }
     }
 }