sharp-chat/SharpChat/Flashii/FlashiiUrls.cs

46 lines
1.7 KiB
C#

using System.IO;
namespace SharpChat.Flashii {
public static class FlashiiUrls {
private const string BASE_URL_FILE = "msz_url.txt";
private const string BASE_URL_FALLBACK = "https://flashii.net";
private const string VERIFY = "/_sockchat/verify";
private const string BUMP = "/_sockchat/bump";
private const string BANS_CHECK = "/_sockchat/bans/check?u={0}&a={1}&x={2}&n={3}";
private const string BANS_CREATE = "/_sockchat/bans/create";
private const string BANS_REVOKE = "/_sockchat/bans/revoke?t={0}&s={1}&x={2}";
private const string BANS_LIST = "/_sockchat/bans/list?x={0}";
public static string BumpURL { get; }
public static string VerifyURL { get; }
public static string BansCheckURL { get; }
public static string BansCreateURL { get; }
public static string BansRevokeURL { get; }
public static string BansListURL { get; }
static FlashiiUrls() {
BumpURL = GetURL(BUMP);
VerifyURL = GetURL(VERIFY);
BansCheckURL = GetURL(BANS_CHECK);
BansCreateURL = GetURL(BANS_CREATE);
BansRevokeURL = GetURL(BANS_REVOKE);
BansListURL = GetURL(BANS_LIST);
}
public static string GetBaseURL() {
if(!File.Exists(BASE_URL_FILE))
return BASE_URL_FALLBACK;
string url = File.ReadAllText(BASE_URL_FILE).Trim().Trim('/');
if(string.IsNullOrEmpty(url))
return BASE_URL_FALLBACK;
return url;
}
public static string GetURL(string path) {
return GetBaseURL() + path;
}
}
}