diff --git a/Amino.NET/Amino.NET.csproj b/Amino.NET/Amino.NET.csproj index ee80cbc..572d942 100644 --- a/Amino.NET/Amino.NET.csproj +++ b/Amino.NET/Amino.NET.csproj @@ -2,7 +2,7 @@ net5.0 - 1.2.0 + 1.3.0 FabioTheFox FabiDev An unofficial C# wrapper for Aminos REST API for making amino bots and tools @@ -20,6 +20,7 @@ Amino.Net-Logo-V2.png true + FabioTheFox @@ -36,7 +37,7 @@ - + True diff --git a/Amino.NET/Amino.NET.xml b/Amino.NET/Amino.NET.xml index cf4e5d4..5031784 100644 --- a/Amino.NET/Amino.NET.xml +++ b/Amino.NET/Amino.NET.xml @@ -139,6 +139,11 @@ Fires each time an Amino chat title has been changed (only chats where the current Amino account is in) + + + Fires each time an Amino chat content has been changed (only in chats where the currnt Amino account is in) + + Creates an instance of the Amino.Client object and builds headers @@ -724,6 +729,12 @@ string : The signiture. + + + Returns the current Amino compatible Timezone + + + This function allows you to generate an Amino valid signiture for file uploads diff --git a/Amino.NET/Amino.Net-Logo-V2.png b/Amino.NET/Amino.Net-Logo-V2.png new file mode 100644 index 0000000..237dd7e Binary files /dev/null and b/Amino.NET/Amino.Net-Logo-V2.png differ diff --git a/Amino.NET/Client.cs b/Amino.NET/Client.cs index e2de1d5..69e73ad 100644 --- a/Amino.NET/Client.cs +++ b/Amino.NET/Client.cs @@ -83,6 +83,8 @@ public class Client public bool debug { get; set; } = false; + private SubClient subClient = null; + //The value to access the websocket manager private Amino.WebSocketHandler webSocket; @@ -132,20 +134,44 @@ public class Client /// public event Action onChatTitleChanged; /// - /// Fires each time an Amino chat content has been changed (only in chats where the currnt Amino account is in) + /// Fires each time an Amino chat ddescription has been changed (only in chats where the currnt Amino account is in) /// public event Action onChatContentChanged; + /// + /// Fires each time an Amino chat Announcement has been pinned (only in chats where the currnt Amino account is in) + /// public event Action onChatAnnouncementPin; + /// + /// Fires each time an Amino Chat Announcement has been removed from pin (only in chats where the currnt Amino account is in) + /// public event Action onChatAnnouncementUnpin; + /// + /// Fires each time an Amino Chat has been put on View Mode (only in chats where the currnt Amino account is in) + /// public event Action onChatViewModeOn; + /// + /// Fires each time an Amino Chat has been put out of View Mode (only in chats where the currnt Amino account is in) + /// public event Action onChatViewModeOff; + /// + /// Fires each time an Amino Chat has enabled chat tipping (only in chats where the currnt Amino account is in) + /// public event Action onChatTipEnabled; + /// + /// Fires each time an Amino Chat has disabled chat tipping (only in chats where the currnt Amino account is in) + /// public event Action onChatTipDisabled; + /// + /// Fires each time an Amino Chat Message has been removed by a moderator of the current Community (only in chats where the currnt Amino account is in) + /// public event Action onMessageForceRemovedByAdmin; + /// + /// Fires each time someone has tipped coins in an Amino Chat (only in chats where the currnt Amino account is in) + /// public event Action onChatTip; //headers. - private IDictionary headers = new Dictionary(); + public Dictionary headers = new Dictionary(); //Handles the header stuff private Task headerBuilder() @@ -157,7 +183,7 @@ private Task headerBuilder() headers.Add("Host", "service.aminoapps.com"); headers.Add("Accept-Encoding", "gzip"); headers.Add("Connection", "Keep-Alive"); - headers.Add("User-Agent", "Dalvik/2.1.0 (Linux; U; Android 7.1.2; SM-G965N Build/star2ltexx-user 7.1.; com.narvii.amino.master/3.4.33602)"); + headers.Add("User-Agent", "Apple iPhone13,4 iOS v15.6.1 Main/3.12.9"); if(sessionID != null) { headers.Add("NDCAUTH", $"sid={sessionID}"); } return Task.CompletedTask; } @@ -215,13 +241,19 @@ public Task login(string _email, string _password, string _secret = null) { string secret; if (_secret == null) { secret = $"0 {_password}"; } else { secret = _secret; } - var data = new { email = _email, v = 2, secret = secret, deviceID = deviceID, clientType = 100, action = "normal", timestamp = helpers.GetTimestamp() * 1000}; - + JObject data = new JObject(); + data.Add("email", _email); + data.Add("v", 2); + data.Add("secret", secret); + data.Add("deviceID", deviceID); + data.Add("clientType", 100); + data.Add("action", "normal"); + data.Add("timestamp", helpers.GetTimestamp() * 1000); RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest("/g/s/auth/login", Method.Post); request.AddHeaders(headers); - request.AddJsonBody(data); - request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(System.Text.Json.JsonSerializer.Serialize(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if((int)response.StatusCode != 200) { throw new Exception(response.Content); } json = response.Content; @@ -293,6 +325,8 @@ public Task logout() is_Global = false; headerBuilder(); _ = webSocket.disconnect_socket(); + subClient.Dispose(); + subClient = null; return Task.CompletedTask; }catch(Exception e) { throw new Exception(e.Message); } @@ -558,22 +592,23 @@ public Amino.Objects.GlobalProfile get_user_info(string _userId) public bool check_device(string _deviceId) { CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; - var data = new - { - deviceID = _deviceId, - bundleID = "com.narvii.amino.master", - clientType = 100, - systemPushEnabled = true, - timezone = 0, - locale = currentCulture.Name, - timestamp = (Math.Round(helpers.GetTimestamp())) * 1000 - }; + + JObject data = new JObject(); + data.Add("deviceID", _deviceId); + data.Add("bundleID", "com.narvii.amino.master"); + data.Add("clientType", 100); + data.Add("systemPushEnabled", true); + data.Add("timezone", 0); + data.Add("locale", currentCulture.Name); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + try { RestClient client = new RestClient(helpers.BaseUrl); RestRequest request = new RestRequest("/g/s/device"); + request.AddJsonBody(JsonConvert.SerializeObject(data)); request.AddHeaders(headers); - request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(System.Text.Json.JsonSerializer.Serialize(data))); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); var response = client.ExecutePost(request); if ((int)response.StatusCode != 200) { return false; } if (debug) { Trace.WriteLine(response.Content); } @@ -2208,6 +2243,24 @@ public Task claim_new_user_coupon() }catch(Exception e) { throw new Exception(e.Message); } } + + public Objects.AdvancedCommunityInfo get_community_info(string communityId) + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/g/s-x{communityId}/community/info?withInfluencerList=1&withTopicList=true&influencerListOrderStrategy=fansCount"); + request.AddHeaders(headers); + var response = client.ExecuteGet(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); + Objects.AdvancedCommunityInfo community = new Objects.AdvancedCommunityInfo(jsonObj); + return community; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// /// Allows you to accept host / organizer of a chatroom with the current Amino account /// @@ -2328,6 +2381,12 @@ public Task wallet_config(Types.Wallet_Config_Levels walletLevel) }catch(Exception e) { throw new Exception(e.Message); } } + public void SetSubClient(Amino.SubClient subClient) + { + if(subClient == null) { throw new Exception("No SubClient provided!"); } + this.subClient = subClient; + } + /// /// Handles the Event calls, do not manually interact with this Class or its functions! /// diff --git a/Amino.NET/Objects/AdvancedCommunityInfo.cs b/Amino.NET/Objects/AdvancedCommunityInfo.cs new file mode 100644 index 0000000..a08c19b --- /dev/null +++ b/Amino.NET/Objects/AdvancedCommunityInfo.cs @@ -0,0 +1,230 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Amino.Objects +{ + [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + public class AdvancedCommunityInfo + { + public bool isCurrentUserJoined { get; } + public bool searchable { get; } + public bool isStandaloneAppDeprecated { get; } + public int listedStatus { get; } + public int probationStatus { get; } + public string keywords { get; } + public int membersCount { get; } + public string primaryLanguage { get; } + public float communityHeat { get; } + public string content { get; } + public bool isStandaloneAppMonetizationEnabled { get; } + public string tagline { get; } + public int joinType { get; } + public int status { get; } + public string modifiedTime { get; } + public int communityId { get; } + public string link { get; } + public string iconUrl { get; } + public string updatedTime { get; } + public string endpoint { get; } + public string name { get; } + public int templateId { get; } + public string createdTime { get; } + public string json { get; } + public List<_User> communityHeadList { get; } = new List<_User>(); + public _User Agent { get; } + public _ThemePack ThemePack { get; } + public _AdvancedSettings AdvancedSettings { get; } + + + + public AdvancedCommunityInfo(JObject _json) + { + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); + try { isCurrentUserJoined = (bool)jsonObj["isCurrentUserJoined"]; } catch { } + try { searchable = (bool)jsonObj["community"]["searchable"]; } catch { } + try { isStandaloneAppDeprecated = (bool)jsonObj["community"]["isStandaloneAppDeprecated"]; } catch { } + try { listedStatus = (int)jsonObj["community"]["listedStatus"]; } catch { } + try { probationStatus = (int)jsonObj["community"]["probationStatus"]; }catch { } + try { keywords = (string)jsonObj["community"]["keywords"]; }catch { } + try { membersCount = (int)jsonObj["community"]["membersCount"]; }catch { } + try { primaryLanguage = (string)jsonObj["community"]["primaryLanguage"]; } catch { } + try { communityHeat = (float)jsonObj["community"]["communityHeat"]; } catch { } + try { content = (string)jsonObj["community"]["content"]; } catch { } + try { isStandaloneAppMonetizationEnabled = (bool)jsonObj["community"]["isStandaloneAppMonetizationEnabled"]; } catch { } + try { tagline = (string)jsonObj["community"]["tagline"]; } catch { } + try { joinType = (int)jsonObj["community"]["joinType"]; } catch { } + try { status = (int)jsonObj["community"]["status"]; } catch { } + try { modifiedTime = (string)jsonObj["community"]["modifiedTime"]; } catch { } + try { communityId = (int)jsonObj["community"]["ndcId"]; } catch { } + try { link = (string)jsonObj["community"]["link"]; } catch { } + try { iconUrl = (string)jsonObj["community"]["icon"]; } catch { } + try { updatedTime = (string)jsonObj["community"]["updatedTime"]; }catch { } + try { endpoint = (string)jsonObj["community"]["endpoint"]; } catch { } + try { name = (string)jsonObj["community"]["name"]; } catch { } + try { templateId = (int)jsonObj["community"]["templateId"]; }catch { } + try { createdTime = (string)jsonObj["community"]["createdTime"]; } catch { } + try { json = _json.ToString(); } catch { } + try { Agent = new _User(jsonObj["community"]["agent"]); } catch { } + try { ThemePack = new _ThemePack(jsonObj["community"]["themePack"]); } catch { } + try { AdvancedSettings = new _AdvancedSettings(jsonObj["community"]["advancedSettings"]); } catch { } + try + { + JArray userArray = jsonObj["community"]["communityHeadList"]; + foreach (JObject user in userArray) + { + _User _user = new _User(user); + communityHeadList.Add(_user); + } + }catch { } + + } + + [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + public class _User + { + public int status { get; } + public bool isNicknameVerified { get; } + public string userId { get; } + public int level { get; } + public int followingStatus { get; } + public int accountMembershipStatus { get; } + public bool isGlobal { get; } + public int membershipStatus { get; } + public string avatarFrameId { get; } + public int reputation { get; } + public int role { get; } + public int communityId { get; } + public int membersCount { get; } + public string nickname { get; } + public string iconUrl { get; } + + + public _User(JObject _json) + { + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); + try { status = (int)jsonObj["status"]; } catch { } + try { isNicknameVerified = (bool)jsonObj["isNicknameVerified"]; } catch { } + try { userId = (string)jsonObj["uid"]; } catch { } + try { level = (int)jsonObj["level"]; } catch { } + try { followingStatus = (int)jsonObj["followingStatus"]; } catch { } + try { accountMembershipStatus = (int)jsonObj["accountMembershipStatus"]; } catch { } + try { isGlobal = (bool)jsonObj["isGlobal"]; } catch { } + try { membershipStatus = (int)jsonObj["membershipStatus"]; } catch { } + try { avatarFrameId = (string)jsonObj["avatarFrameId"]; } catch { } + try { reputation = (int)jsonObj["reputation"]; } catch { } + try { role = (int)jsonObj["role"]; } catch { } + try { communityId = (int)jsonObj["ndcId"]; } catch { } + try { membersCount = (int)jsonObj["membersCount"]; } catch { } + try { nickname = (string)jsonObj["nickname"]; } catch { } + try { iconUrl = (string)jsonObj["icon"]; } catch { } + + } + + + + } + + [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + public class _ThemePack + { + public string themeColor { get; } + public string themePackHash { get; } + public int themePackRevision { get; } + public string themePackUrl { get; } + + public _ThemePack(JObject _json) + { + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); + try { themeColor = (string)jsonObj["themeColor"]; } catch { } + try { themePackHash = (string)jsonObj["themePackHash"]; } catch { } + try { themePackRevision = (int)jsonObj["themePackRevision"]; } catch { } + try { themePackUrl = (string)jsonObj["themePackUrl"]; } catch { } + } + } + + [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + public class _AdvancedSettings + { + public int defaultRakingTypeInLeaderBoard { get; } + public int frontPageLayout { get; } + public bool hasPendingReviewRequest { get; } + public bool welcomeMessageEnabled { get; } + public string welcomeMessageText { get; } + public int pollMinFullBarCount { get; } + public bool catalogEnabled { get; } + public List<_NewsFeed> NewsFeed { get; } = new List<_NewsFeed>(); + public List<_Ranks> Ranks { get; } = new List<_Ranks>(); + + public _AdvancedSettings(JObject _json) + { + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); + try { defaultRakingTypeInLeaderBoard = (int)jsonObj["defaultRankingTypeInLeaderboard"]; } catch { } + try { frontPageLayout = (int)jsonObj["frontPageLayout"]; } catch { } + try { hasPendingReviewRequest = (bool)jsonObj["hasPendingReviewRequest"]; } catch { } + try { welcomeMessageEnabled = (bool)jsonObj["welcomeMessageEnabled"]; } catch { } + try { pollMinFullBarCount = (int)jsonObj["pollMinFullBarCount"]; } catch { } + try { catalogEnabled = (bool)jsonObj["catalogEnabled"]; } catch { } + try + { + JArray newsFeed = jsonObj["newsfeedPages"]; + foreach (JObject post in newsFeed) + { + _NewsFeed _post = new _NewsFeed(post); + NewsFeed.Add(_post); + } + }catch { } + try + { + JArray ranks = jsonObj["rankingTable"]; + foreach (JObject rank in ranks) + { + _Ranks _rank = new _Ranks(rank); + Ranks.Add(_rank); + } + }catch { } + } + + + + [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + public class _NewsFeed + { + public int status { get; } + public int type { get; } + + public _NewsFeed(JObject _json) + { + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); + try { status = (int)jsonObj["status"]; } catch { } + try { type = (int)jsonObj["type"]; } catch { } + } + } + + [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + public class _Ranks + { + public int level { get; } + public int reputation { get; } + public string id { get; } + public string title { get; } + + public _Ranks(JObject _json) + { + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); + try { level = (int)jsonObj["level"]; } catch { } + try { reputation = (int)jsonObj["reputation"]; } catch { } + try { id = (string)jsonObj["id"]; } catch { } + try { title = (string)jsonObj["title"]; } catch { } + } + } + + } + + + } +} diff --git a/Amino.NET/Objects/Community.cs b/Amino.NET/Objects/Community.cs index ebec55b..5c7d9ed 100644 --- a/Amino.NET/Objects/Community.cs +++ b/Amino.NET/Objects/Community.cs @@ -7,23 +7,23 @@ namespace Amino.Objects [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] public class Community { - public int listedStatus { get; private set; } - public int probationStatus { get; private set; } - public int membersCount { get; private set; } + public int? listedStatus { get; private set; } + public int? probationStatus { get; private set; } + public int? membersCount { get; private set; } public string primaryLanguage { get; private set; } - public float communityHeat { get; private set; } + public float? communityHeat { get; private set; } public string strategyInfo { get; private set; } public string tagline { get; private set; } - public int joinType { get; private set; } - public int status { get; private set; } + public int? joinType { get; private set; } + public int? status { get; private set; } public string modifiedTime { get; private set; } - public int communityId { get; private set; } + public int? communityId { get; private set; } public string communityLink { get; private set; } public string iconUrl { get; private set; } public string updatedTime { get; private set; } public string endpoint { get; private set; } public string communityName { get; private set; } - public int templateId { get; private set; } + public int? templateId { get; private set; } public string createdTime { get; private set; } public string json { get; private set; } public _Agent Agent { get; private set; } @@ -32,24 +32,23 @@ public class Community public Community(JObject _json) { dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - listedStatus = (int)jsonObj["listedStatus"]; - probationStatus = (int)jsonObj["probationStatus"]; - membersCount = (int)jsonObj["membersCount"]; - primaryLanguage = (string)jsonObj["primaryLanguage"]; - communityHeat = (float)jsonObj["communityHeat"]; - strategyInfo = (string)jsonObj["strategyInfo"]; - tagline = (string)jsonObj["tagline"]; - joinType = (int)jsonObj["joinType"]; - status = (int)jsonObj["status"]; - modifiedTime = (string)jsonObj["modifiedTime"]; - communityId = (int)jsonObj["ndcId"]; - communityLink = (string)jsonObj["link"]; - iconUrl = (string)jsonObj["icon"]; - updatedTime = (string)jsonObj["updatedTime"]; - endpoint = (string)jsonObj["endpoint"]; - communityName = (string)jsonObj["name"]; - templateId = (int)jsonObj["templateId"]; - createdTime = (string)jsonObj["createdTime"]; + try { listedStatus = (int)jsonObj["listedStatus"]; } catch { } + try { probationStatus = (int)jsonObj["probationStatus"]; }catch{ } + try { membersCount = (int)jsonObj["membersCount"]; } catch { } + try { joinType = (int)jsonObj["joinType"]; } catch { } + try { status = (int)jsonObj["status"]; } catch { } + try { communityId = (int)jsonObj["ndcId"]; } catch { } + try { communityHeat = (float)jsonObj["communityHeat"]; } catch { } + try { primaryLanguage = (string)jsonObj["primaryLanguage"]; } catch { } + try { strategyInfo = (string)jsonObj["strategyInfo"]; } catch { } + try { tagline = (string)jsonObj["tagline"]; } catch { } + try { modifiedTime = (string)jsonObj["modifiedTime"]; } catch { } + try { communityLink = (string)jsonObj["link"]; } catch { } + try { iconUrl = (string)jsonObj["icon"]; } catch { } + try { updatedTime = (string)jsonObj["updatedTime"]; } catch { } + try { endpoint = (string)jsonObj["endpoint"]; } catch { } + try { communityName = (string)jsonObj["name"]; } catch { } + try { createdTime = (string)jsonObj["createdTime"]; } catch { } json = _json.ToString(); Agent = new _Agent(_json); } @@ -58,24 +57,24 @@ public class _Agent { public bool isNickNameVerified { get; private set; } public string userId { get; private set; } - public int level { get; private set; } - public int followingStatus { get; private set; } - public int membershipStatus { get; private set; } + public int? level { get; private set; } + public int? followingStatus { get; private set; } + public int? membershipStatus { get; private set; } public bool isGlobal { get; private set; } - public int reputation { get; private set; } - public int membersCount { get; private set; } + public int? reputation { get; private set; } + public int? membersCount { get; private set; } public _Agent(JObject _json) { dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - isNickNameVerified = (bool)jsonObj["agent"]["isNicknameVerified"]; - userId = (string)jsonObj["agent"]["uid"]; - level = (int)jsonObj["agent"]["level"]; - followingStatus = (int)jsonObj["agent"]["followingStatus"]; - membershipStatus = (int)jsonObj["agent"]["membershipStatus"]; - isGlobal = (bool)jsonObj["agent"]["isGlobal"]; - reputation = (int)jsonObj["agent"]["reputation"]; - membersCount = (int)jsonObj["agent"]["membersCount"]; + try { isNickNameVerified = (bool)jsonObj["agent"]["isNicknameVerified"]; } catch { } + try { userId = (string)jsonObj["agent"]["uid"]; } catch { } + try { level = (int)jsonObj["agent"]["level"]; } catch { } + try { followingStatus = (int)jsonObj["agent"]["followingStatus"]; } catch { } + try { membershipStatus = (int)jsonObj["agent"]["membershipStatus"]; } catch { } + try { isGlobal = (bool)jsonObj["agent"]["isGlobal"]; } catch { } + try { reputation = (int)jsonObj["agent"]["reputation"]; } catch { } + try { membersCount = (int)jsonObj["agent"]["membersCount"]; } catch { } } } } diff --git a/Amino.NET/Objects/FromCode.cs b/Amino.NET/Objects/FromCode.cs index 3d98aed..23fd901 100644 --- a/Amino.NET/Objects/FromCode.cs +++ b/Amino.NET/Objects/FromCode.cs @@ -15,17 +15,20 @@ public class FromCode public string shortCode { get; } public int objectType { get; } public string json { get; } + public Community Community { get; } = null; public FromCode(JObject _json) { dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - path = (string)jsonObj["linkInfoV2"]["path"]; - objectId = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectId"]; - targetCode = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["targetCode"]; - communityId = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["ndcId"]; - if(jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["fullPath"] != null) { fullPath = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["fullPath"]; } - if(jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shortCode"] != null) { shortCode = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shortCode"]; } - objectType = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectType"]; + try { if (jsonObj["linkInfoV2"]["path"] != null) { path = (string)jsonObj["linkInfoV2"]["path"]; } } catch { } + try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectId"] != null) { objectId = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectId"]; } } catch { } + try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["targetCode"] != null) { targetCode = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["targetCode"]; } } catch { } + try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["ndcId"] != null) { communityId = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["ndcId"]; } } catch { } + try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["fullPath"] != null) { fullPath = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["fullPath"]; } } catch { } + try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shortCode"] != null) { shortCode = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shortCode"]; } } catch { } + try { if (jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectType"] != null) { objectType = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectType"]; } } catch { } + if(jsonObj["linkInfoV2"]["extensions"]["community"] != null) { Community = new Community(jsonObj["linkInfoV2"]["extensions"]["community"]); } + json = _json.ToString(); } } diff --git a/Amino.NET/Objects/FromId.cs b/Amino.NET/Objects/FromId.cs index 80181f4..dc1c67a 100644 --- a/Amino.NET/Objects/FromId.cs +++ b/Amino.NET/Objects/FromId.cs @@ -9,26 +9,26 @@ public class FromId public string path { get; } public string objectId { get; } public string shareURLShortCode { get; } - public int targetCode { get; } - public int communityId { get; } + public int? targetCode { get; } + public int? communityId { get; } public string fullPath { get; } public string shortCode { get; } public string shareURLFullPath { get; } - public int objectType { get; } + public int? objectType { get; } public string json { get; } public FromId(JObject _json) { dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); - path = (string)jsonObj["linkInfoV2"]["path"]; - objectId = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectId"]; - shareURLShortCode = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shareURLShortCode"]; - targetCode = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["targetCode"]; - communityId = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["ndcId"]; - fullPath = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["fullPath"]; - if(jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shortCode"] != null) { shortCode = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shortCode"]; } - shareURLFullPath = (string)jsonObj["linKInfoV2"]["extensions"]["linkInfo"]["shareURLFullPath"]; - objectType = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectType"]; + try { path = (string)jsonObj["linkInfoV2"]["path"]; } catch { } + try { objectId = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectId"]; } catch { } + try { shareURLShortCode = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shareURLShortCode"]; } catch { } + try { targetCode = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["targetCode"]; } catch { } + try { communityId = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["ndcId"]; } catch { } + try { fullPath = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["fullPath"]; } catch { } + try { shortCode = (string)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["shortCode"]; } catch { } + try { shareURLFullPath = (string)jsonObj["linKInfoV2"]["extensions"]["linkInfo"]["shareURLFullPath"]; } catch { } + try { objectType = (int)jsonObj["linkInfoV2"]["extensions"]["linkInfo"]["objectType"]; } catch { } json = _json.ToString(); } diff --git a/Amino.NET/Objects/InviteCode.cs b/Amino.NET/Objects/InviteCode.cs new file mode 100644 index 0000000..181b6ad --- /dev/null +++ b/Amino.NET/Objects/InviteCode.cs @@ -0,0 +1,125 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +namespace Amino.Objects +{ + [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + public class InviteCode + { + public int status { get; } + public int duration { get; } + public string invitationId { get; } + public string inviteUrl { get; } + public string modifiedTime { get; } + public int communityId { get; } + public string createdTime { get; } + public string json { get; } + public _Author Author { get; } + + + public InviteCode(JObject _json) + { + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); + status = (int)jsonObj["status"]; + duration = (int)jsonObj["duration"]; + invitationId = (string)jsonObj["invitationId"]; + inviteUrl = (string)jsonObj["link"]; + modifiedTime = (string)jsonObj["modifiedTime"]; + communityId = (int)jsonObj["ndcId"]; + json = _json.ToString(); + Author = new _Author(_json); + } + + + [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + public class _Author + { + public int status { get; } + public bool isNicknameVerified { get; } + public string userId { get; } + public int level { get; } + public int followingStatus { get; } + public int accountMembershipStatus { get; } + public bool isGlobal { get; } + public int membershipStatus { get; } + public string avatarFrameId { get; } + public int reputation { get; } + public int role { get; } + public int communityId { get; } + public int membersCount { get; } + public string nickname { get; } + public string iconUrl { get; } + public _InfluencerInfo InfluencerInfo { get; } + public _AvatarFrame AvatarFrame { get; } + + + public _Author(JObject _json) + { + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); + status = (int)jsonObj["author"]["status"]; + isNicknameVerified = (bool)jsonObj["author"]["isNicknameVerified"]; + userId = (string)jsonObj["author"]["uid"]; + level = (int)jsonObj["author"]["level"]; + followingStatus = (int)jsonObj["author"]["followingStatus"]; + accountMembershipStatus = (int)jsonObj["author"]["accountMembershipStatus"]; + isGlobal = (bool)jsonObj["author"]["isGlobal"]; + membershipStatus = (int)jsonObj["author"]["membershipStatus"]; + avatarFrameId = (string)jsonObj["author"]["avatarFrameId"]; + reputation = (int)jsonObj["author"]["reputation"]; + role = (int)jsonObj["author"]["role"]; + communityId = (int)jsonObj["author"]["ndcId"]; + membersCount = (int)jsonObj["author"]["membersCount"]; + nickname = (string)jsonObj["author"]["nickname"]; + if (jsonObj["author"]["icon"] != null) { iconUrl = (string)jsonObj["author"]["icon"]; } + if(jsonObj["author"]["influencerInfo"] != null) { InfluencerInfo = new _InfluencerInfo(_json); } + if(jsonObj["author"]["avatarFrame"] != null) { AvatarFrame = new _AvatarFrame(_json); } + + } + + + [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + public class _InfluencerInfo + { + public bool pinned { get; } + public string createdTime { get; } + public int fansCount { get; } + public int monthlyFee { get; } + + public _InfluencerInfo(JObject _json) + { + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); + pinned = (bool)jsonObj["author"]["influencerInfo"]["pinned"]; + createdTime = (string)jsonObj["author"]["influencerInfo"]["createdTime"]; + fansCount = (int)jsonObj["author"]["influencerInfo"]["fansCount"]; + monthlyFee = (int)jsonObj["author"]["influencerInfo"]["monthlyFee"]; + } + } + + + [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] + public class _AvatarFrame + { + public int status { get; } + public string ownershipStatus { get; } + public int version { get; } + public string resourceUrl { get; } + public string name { get; } + public string iconUrl { get; } + public string frameId { get; } + + public _AvatarFrame(JObject _json) + { + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(_json.ToString()); + status = (int)jsonObj["author"]["avatarFrame"]["status"]; + ownershipStatus = (string)jsonObj["author"]["avatarFrame"]["ownershipStatus"]; + version = (int)jsonObj["author"]["avatarFrame"]["version"]; + resourceUrl = (string)jsonObj["author"]["avatarFrame"]["resourceUrl"]; + name = (string)jsonObj["author"]["avatarFrame"]["name"]; + iconUrl = (string)jsonObj["author"]["avatarFrame"]["icon"]; + frameId = (string)jsonObj["author"]["avatarFrame"]["frameId"]; + } + + + } + } + } +} diff --git a/Amino.NET/SubClient.cs b/Amino.NET/SubClient.cs new file mode 100644 index 0000000..e1a02cf --- /dev/null +++ b/Amino.NET/SubClient.cs @@ -0,0 +1,1108 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using RestSharp; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace Amino +{ + public class SubClient + { + + private Amino.Client client; + public bool debug { get; set; } + private string communityId; + + + + //headers. + public Dictionary headers = new Dictionary(); + + //Handles the header stuff + private Task headerBuilder() + { + headers.Clear(); + headers.Add("NDCDEVICEID", client.deviceID); + headers.Add("Accept-Language", "en-US"); + headers.Add("Content-Type", "application/json; charset=utf-8"); + headers.Add("Host", "service.aminoapps.com"); + headers.Add("Accept-Encoding", "gzip"); + headers.Add("Connection", "Keep-Alive"); + headers.Add("User-Agent", "Apple iPhone13,4 iOS v15.6.1 Main/3.12.9"); + if (client.sessionID != null) { headers.Add("NDCAUTH", $"sid={client.sessionID}"); } + return Task.CompletedTask; + } + + /// + /// Creates an instance of the Amino.SubClient object and builds headers + /// + /// + /// + public SubClient(Amino.Client _client, string _communityId) + { + if (_client.sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + client = _client; + debug = client.debug; + communityId = _communityId; + headerBuilder(); + } + + /// + /// Creates an instance of the Amino.SubClient object and builds headers + /// + /// + /// + public SubClient(Amino.Client _client, int _communityId) + { + if (_client.sessionID == null) { throw new Exception("ErrorCode: 0: Client not logged in"); } + client = _client; + debug = client.debug; + communityId = _communityId.ToString(); + headerBuilder(); + } + + + /// + /// Allows you to get inviite codes of the current community (might require staff permissions) + /// + /// + /// + /// + /// + public List get_invite_codes(string status = "normal", int start = 0, int size = 25) + { + try + { + List inviteCodeList = new List(); + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/g/s-x{communityId}/community/invitation?status={status}&start={start}&size={size}"); + request.AddHeaders(headers); + var response = client.ExecuteGet(request); + if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + dynamic jsonObj = (JObject)JsonConvert.DeserializeObject(response.Content); + JArray inviteCodesJson = jsonObj["communityInvitationList"]; + foreach(JObject code in inviteCodesJson) + { + Amino.Objects.InviteCode invCode = new Objects.InviteCode(code); + inviteCodeList.Add(invCode); + } + Console.WriteLine(response.Content); + return inviteCodeList; + + } catch(Exception e) { throw new Exception(e.Message); } + + } + + /// + /// Allows you to generate a Community invite code (might require staff permissions) + /// + /// + /// + /// + public Task generate_invite_code(int duration = 0, bool force = true) + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/g/s-x{communityId}/community/invitation"); + request.AddHeaders(headers); + JObject data = new JObject(); + data.Add("duration", duration); + data.Add("force", force); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + var response = client.ExecuteGet(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) + { + throw new Exception(e.Message); + } + } + + /// + /// Allows you to delete an invite code using its ID + /// + /// + /// + public Task delete_invite_code(string inviteId) + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/g/s-x{communityId}/community/invitation/{inviteId}"); + request.AddHeaders(headers); + var response = client.Delete(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to post a Blog post in the current Community + /// + /// + /// + /// + /// + /// + /// + public Task post_blog(string title, string content, List imageList = null, bool fansOnly = false, string backgroundColor = null) + { + try + { + JArray mediaList = new JArray(); + JObject extensionData = new JObject(); + + if(imageList != null) + { + JArray tempMedia = new JArray(); + foreach(byte[] bytes in imageList) + { + tempMedia = new JArray(); + tempMedia.Add(100); + tempMedia.Add(this.client.upload_media(bytes, Types.upload_File_Types.Image)); + tempMedia.Add(null); + mediaList.Add(tempMedia); + } + } + if(fansOnly) { extensionData.Add("fansOnly", fansOnly); } + if(backgroundColor != null) { JObject color = new JObject(); color.Add("backgroundColor", backgroundColor); extensionData.Add(new JProperty("style", color)); } + + + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/blog"); + request.AddHeaders(headers); + JObject data = new JObject(); + data.Add("address", null); + data.Add("title", title); + data.Add("content", content); + data.Add("mediaList", new JArray(mediaList)); + data.Add(new JProperty("extensions", extensionData)); + data.Add("latitude", 0); + data.Add("longitude", 0); + data.Add("eventSource", "GlobalComposeMenu"); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + + return Task.CompletedTask; + }catch(Exception e) + { + throw new Exception(e.Message); + } + } + + /// + /// Allows you to post a Wiki post on the current Community + /// + /// + /// + /// + /// + /// + /// + public Task post_wiki(string title, string content, List imageList = null, bool fansOnly = false, string backgroundColor = null) + { + try + { + JArray mediaList = new JArray(); + JObject extensionData = new JObject(); + + if (imageList != null) + { + JArray tempMedia = new JArray(); + foreach (byte[] bytes in imageList) + { + tempMedia = new JArray(); + tempMedia.Add(100); + tempMedia.Add(this.client.upload_media(bytes, Types.upload_File_Types.Image)); + tempMedia.Add(null); + mediaList.Add(tempMedia); + } + } + if (fansOnly) { extensionData.Add("fansOnly", fansOnly); } + if (backgroundColor != null) { JObject color = new JObject(); color.Add("backgroundColor", backgroundColor); extensionData.Add(new JProperty("style", color)); } + + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/item"); + request.AddHeaders(headers); + JObject data = new JObject(); + data.Add("label", title); + data.Add("content", content); + data.Add("eventSource", "GlobalComposeMenu"); + data.Add("mediaList", new JArray(mediaList)); + data.Add(new JProperty("extensions", extensionData)); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + + } catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to edit an existing Blog on the current Community + /// + /// + /// + /// + /// + /// + /// + /// + public Task edit_blog(string blogId, string title = null, string content = null, List imageList = null, bool fansOnly = false, string backgroundColor = null) + { + try + { + JArray mediaList = new JArray(); + JObject extensionData = new JObject(); + + if (imageList != null) + { + JArray tempMedia = new JArray(); + foreach (byte[] bytes in imageList) + { + tempMedia = new JArray(); + tempMedia.Add(100); + tempMedia.Add(this.client.upload_media(bytes, Types.upload_File_Types.Image)); + tempMedia.Add(null); + mediaList.Add(tempMedia); + } + } + if (fansOnly) { extensionData.Add("fansOnly", fansOnly); } + if (backgroundColor != null) { JObject color = new JObject(); color.Add("backgroundColor", backgroundColor); extensionData.Add(new JProperty("style", color)); } + + + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/blog"); + request.AddHeaders(headers); + JObject data = new JObject(); + data.Add("address", null); + data.Add("title", title); + data.Add("content", content); + data.Add("mediaList", new JArray(mediaList)); + data.Add(new JProperty("extensions", extensionData)); + data.Add("latitude", 0); + data.Add("longitude", 0); + data.Add("eventSource", "PostDetailView"); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + var response = client.ExecutePost(request); + if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + + return Task.CompletedTask; + } + catch (Exception e) + { + throw new Exception(e.Message); + } + } + + /// + /// Allows you to delete a Blog post + /// + /// + /// + public Task delete_blog(string blogId) + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/blog/{blogId}"); + request.AddHeaders(headers); + var response = client.Delete(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to delete a Wiki post + /// + /// + /// + public Task delete_wiki(string wikiId) + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/item/{wikiId}"); + request.AddHeaders(headers); + var response = client.Delete(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to repost a post + /// + /// + /// + /// + /// + public Task repost_blog(string postId, Types.Repost_Types type, string content = null) + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/blog"); + request.AddHeaders(headers); + JObject data = new JObject(); + data.Add("content", content); + data.Add("refObjectId", postId); + data.Add("refObjectType", (int)type); + data.Add("type", 2); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to check in on the current Community + /// + /// + /// + public Task check_in(int? timezone = null) + { + try + { + int? tz; + if (timezone != null) { tz = timezone; } else { tz = helpers.getTimezone(); } + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/check-in"); + request.AddHeaders(headers); + JObject data = new JObject(); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + data.Add("timezone", tz); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to repair your check in streak using either Amino Coins or Amino+ + /// + /// + /// + public Task repair_check_in(Types.Repair_Types repairType) + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/check-in/repair"); + request.AddHeaders(headers); + JObject data = new JObject(); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + data.Add("repairMethod", Convert.ToString((int)repairType)); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to claim the check in lottery + /// + /// + /// + public Task lottery(int? timezone = null) + { + try + { + int? tz; + if (timezone != null) { tz = timezone; } else { tz = helpers.getTimezone(); } + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/check-in"); + request.AddHeaders(headers); + JObject data = new JObject(); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + data.Add("timezone", tz); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + catch (Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you edit your community profile + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Task edit_profile(string nickname = null, string content = null, byte[] icon = null, List imageList = null, List captionList = null, string backgroundColor = null, byte[] backgroundImage = null, string defaultChatBubbleId = null) + { + try + { + JObject data = new JObject(); + + JArray mediaList = new JArray(); + JObject extensionData = new JObject(); + + if (imageList != null) + { + JArray tempMedia = new JArray(); + for(int i = 0; i != imageList.Count; i++) + { + tempMedia = new JArray(); + tempMedia.Add(100); + tempMedia.Add(this.client.upload_media(imageList[i], Types.upload_File_Types.Image)); + tempMedia.Add(captionList[i]); + mediaList.Add(tempMedia); + } + } + if (backgroundColor != null) { JObject color = new JObject(); color.Add("backgroundColor", backgroundColor); extensionData.Add(new JProperty("style", color)); } + if(backgroundImage != null) { JObject bgImg = new JObject(); JArray bgArr = new JArray(); bgArr.Add(100);bgArr.Add(this.client.upload_media(backgroundImage, Types.upload_File_Types.Image));bgArr.Add(null); bgArr.Add(null); bgArr.Add(null); bgImg.Add("backgroundMediaList", new JArray(bgArr)); extensionData.Add(new JProperty("style", bgImg)); } + if(defaultChatBubbleId != null) { JObject dchtbl = new JObject(); dchtbl.Add("defaultBubbleId", defaultChatBubbleId); extensionData.Add(dchtbl); } + + + data.Add("timestamp", helpers.GetTimestamp() * 1000); + data.Add(new JProperty("extensions", extensionData)); + if(nickname != null) { data.Add("nickname", nickname); } + if(content != null) { data.Add("content", content); } + if(icon != null) { data.Add("icon", this.client.upload_media(icon, Types.upload_File_Types.Image)); } + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{this.client.userID}"); + request.AddHeaders(headers); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if ((int)response.StatusCode != 200) throw new Exception(response.Content); + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to vote on a poll + /// + /// + /// + /// + public Task vote_poll(string postId, string optionId) + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/blog/{postId}/poll/option/{optionId}/vote"); + JObject data = new JObject(); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + data.Add("eventSource", "PostDetailView"); + data.Add("value", 1); + request.AddHeaders(headers); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to comment on a Blog, Wiki, Reply, Wall + /// + /// + /// + /// + /// + /// + public Task comment(string message, Amino.Types.Comment_Types type, string targetId, bool isGuest = false) + { + try + { + string endPoint = null; + JObject data = new JObject(); + data.Add("content", message); + data.Add("strickerId", null); + data.Add("type", 0); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + string comType; + if (isGuest) { comType = "g-comment"; } else { comType = "comment"; } + switch(type) + { + case Types.Comment_Types.Blog: + data.Add("eventSource", "PostDetailView"); + endPoint = $"/x{communityId}/s/blog/{targetId}/{comType}"; + break; + case Types.Comment_Types.Wiki: + data.Add("eventSource", "PostDetailView"); + break; + case Types.Comment_Types.Reply: + data.Add("respondTo", targetId); + endPoint = $"/x{communityId}/s/item/{targetId}/{comType}"; + break; + case Types.Comment_Types.User: + data.Add("eventSource", "UserProfileView"); + endPoint = $"/x{communityId}/s/user-profile/{targetId}/{comType}"; + break; + } + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest(endPoint); + request.AddHeaders(headers); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to delete a comment + /// + /// + /// + /// + /// + public Task delete_comment(string commentId, Amino.Types.Comment_Types type, string targetId) + { + try + { + string endPoint = null; + switch(type) + { + case Types.Comment_Types.Blog: + endPoint = $"/x{communityId}/s/blog/{targetId}/comment/{commentId}"; + break; + case Types.Comment_Types.Wiki: + endPoint = $"/x{communityId}/s/item/{targetId}/comment/{commentId}"; + break; + case Types.Comment_Types.Reply: + break; + case Types.Comment_Types.User: + endPoint = $"/x{communityId}/s/user-profile/{targetId}/comment/{commentId}"; + break; + } + + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest(endPoint); + request.AddHeaders(headers); + var response = client.Delete(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to like a Post + /// + /// + /// + /// + public Task like_post(string postId, bool isWiki = false) + { + try + { + string endPoint = null; + + JObject data = new JObject(); + data.Add("value", 4); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + if(!isWiki) { data.Add("eventSource", "UserProfileView"); endPoint = $"/x{communityId}/s/blog/{postId}/vote?cv=1.2"; } else { data.Add("eventSource", "PostDetailView"); endPoint = $"/x{communityId}/s/item/{postId}/vote?cv=1.2"; } + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest(endPoint); + request.AddHeaders(headers); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to unlike a Post + /// + /// + /// + /// + public Task unlike_post(string postId, bool isWiki = false) + { + try + { + string endPoint = null; + if(!isWiki) { endPoint = $"/x{communityId}/s/blog/{postId}/vote?eventSource=UserProfileView"; } else { endPoint = $"/x{communityId}/s/item/{postId}/vote?eventSource=PostDetailView"; } + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest(endPoint); + request.AddHeaders(headers); + var response = client.Delete(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to like a comment + /// + /// + /// + /// + /// + public Task like_comment(string commentId, string targetId,Types.Comment_Types targetType) + { + try + { + string _targetType = null; + string voteType = null; + string targetValue = null; + if(targetType == Types.Comment_Types.User) { _targetType = "UserProfileView"; targetValue = "user-profile"; } else { _targetType = "PostDetailView"; targetValue = "blog"; } + if(targetType == Types.Comment_Types.Wiki) { voteType = "g-vote"; targetValue = "item"; } else { voteType = "vote"; } + JObject data = new JObject(); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + data.Add("value", 1); + data.Add("EventSource", _targetType); + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/{targetValue}/{targetId}/comment/{commentId}/{voteType}?cv=1.2&value=1"); + request.AddHeaders(headers); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + + }catch(Exception e) { throw new Exception(e.Message); } + } + + + /// + /// Allows you to unlike a comment + /// + /// + /// + /// + /// + public Task unlike_comment(string commentId, string targetId, Amino.Types.Comment_Types targetType) + { + try + { + string _targetType = null; + string _eventSource = "PostDetailView"; + if (targetType == Types.Comment_Types.User) { _targetType = "user-profile"; _eventSource = "UserProfileView"; } else if (targetType == Types.Comment_Types.Wiki) { _targetType = "item"; } else { _targetType = "blog"; } + + + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/{_targetType}/{targetId}/comment/{commentId}/g-vote?eventSource={_eventSource}"); + request.AddHeaders(headers); + var response = client.Delete(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to upvote a comment + /// + /// + /// + /// + public Task upvote_comment(string commentId, string postId) + { + try + { + JObject data = new JObject(); + data.Add("value", 1); + data.Add("eventSource", "PostDetailView"); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/blog/{postId}/comment/{commentId}/vote?cv=1.2&value=1"); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddHeaders(headers); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to downvote a comment + /// + /// + /// + /// + public Task downvote_comment(string commentId, string postId) + { + try + { + JObject data = new JObject(); + data.Add("value", -1); + data.Add("eventSource", "PostDetailView"); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/blog/{postId}/comment/{commentId}/vote?cv=1.2&value=1"); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddHeaders(headers); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.Delete(request); + if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + catch (Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to remove your vote from a comment + /// + /// + /// + /// + public Task unvote_comment(string commentId, string postId) + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/blog/{postId}/comment/{commentId}/vote?eventSource=PostDetailView"); + var response = client.Delete(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to reply to a wall comment + /// + /// + /// + /// + /// + public Task reply_wall(string userId, string commentId, string message) + { + try + { + JObject data = new JObject(); + data.Add("content", message); + data.Add("stackId", null); + data.Add("respondTo", commentId); + data.Add("type", 0); + data.Add("eventSource", "UserProfileView"); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{userId}/comment"); + request.AddHeaders(headers); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + + } + + /// + /// Allows you to set if youre online or offline on the community + /// + /// + /// + public Task set_activity_status(Types.Activity_Status_Types status) + { + try + { + JObject data = new JObject(); + if (status == Types.Activity_Status_Types.On) { data.Add("onlineStatus", "on"); } else { data.Add("onlineStatus", "off"); } + data.Add("duration", 86400); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/user-profile/{this.client.userID}/online-status"); + request.AddHeaders(headers); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to check your notifications on the current Community + /// + /// + public Task check_notification() + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/notification/checked"); + request.AddHeaders(headers); + var response = client.ExecutePost(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to delete a specific notification on the current Community + /// + /// + /// + public Task delete_notification(string notificationId) + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/notification/{notificationId}"); + request.AddHeaders(headers); + var response = client.Delete(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to clear all notifications on the current Community + /// + /// + public Task clear_notifications() + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/notification"); + request.AddHeaders(headers); + var response = client.Delete(request); + if((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if(debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + }catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to send activity time (farm coins) on the current community (NO ARGUMENTS REQUIRED) + /// + /// + public Task send_activity_time() + { + try + { + JObject data = new JObject(); + JArray timeData = new JArray(); + + foreach (Dictionary timer in helpers.getTimeData()) + { + JObject subData = new JObject(); + + subData.Add("start", timer["start"]); + subData.Add("end", timer["end"]); + + timeData.Add(subData); + } + int optInAdsFlags = 2147483647; + int tzf = helpers.TzFilter(); + data.Add("userActiveTimeChunkList", timeData); + data.Add("OptInAdsFlags", optInAdsFlags); + data.Add("timestamp", (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds); + data.Add("timezone", tzf); + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/community/stats/user-active-time"); + request.AddHeaders(headers); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + + } + catch(Exception e) { throw new Exception(e.Message); } + } + + + /// + /// Allows you to start a chat with multiple people on the current Community + /// + /// + /// + /// + /// + /// + /// + /// + public Task start_chat(List userIds, string message, string title = null, string content = null, bool isGlobal = false, bool publishToGlobal = false) + { + try + { + JObject data = new JObject(); + data.Add("title", title); + data.Add("inviteeUids", new JArray(userIds)); + data.Add("initialMessageContent", message); + data.Add("content", content); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + if(isGlobal) { data.Add("type", 2); data.Add("eventSource", "GlobalComposeMenu"); } else { data.Add("type", 0); } + if(publishToGlobal) { data.Add("publishToGlobal", 1); } else { data.Add("publishToGlobal", 0); } + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/chat/thread"); + request.AddHeaders(headers); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + } + catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to start a chat with a single person on the current Community + /// + /// + /// + /// + /// + /// + /// + /// + public Task start_chat(string userId, string message, string title = null, string content = null, bool isGlobal = false, bool publishToGlobal = false) + { + start_chat(new List() { userId }, message, title, content, isGlobal, publishToGlobal); + return Task.CompletedTask; + } + + /// + /// Allows you to invite multiple people to a chat in the current Community + /// + /// + /// + /// + public Task invite_to_chat(List userIds, string chatId) + { + try + { + JObject data = new JObject(); + data.Add("uids", new JArray(userIds)); + data.Add("timestamp", helpers.GetTimestamp() * 1000); + + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/chat/thread/{chatId}/member/invite"); + request.AddHeaders(headers); + request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data))); + request.AddJsonBody(JsonConvert.SerializeObject(data)); + var response = client.ExecutePost(request); + if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + + } + catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Allows you to invite a single person to a chat in the current Community + /// + /// + /// + /// + public Task invite_to_chat(string userId, string chatId) + { + invite_to_chat(new List() { userId }, chatId); + return Task.CompletedTask; + } + + /// + /// Allows you to add a user to your favorites + /// + /// + /// + public Task add_to_favorites(string userId) + { + try + { + RestClient client = new RestClient(helpers.BaseUrl); + RestRequest request = new RestRequest($"/x{communityId}/s/user-group/quick-access/{userId}"); + request.AddHeaders(headers); + var response = client.ExecutePost(request); + if ((int)response.StatusCode != 200) { throw new Exception(response.Content); } + if (debug) { Trace.WriteLine(response.Content); } + return Task.CompletedTask; + + } + catch(Exception e) { throw new Exception(e.Message); } + } + + /// + /// Not to be used in general use (THIS FUNCTION WILL DISPOSE THE SUBCLIENT) + /// + public void Dispose() + { + this.communityId = null; + this.client = null; + this.headers = null; + } + + + } + + +} diff --git a/Amino.NET/Types.cs b/Amino.NET/Types.cs index a7199ae..54657e6 100644 --- a/Amino.NET/Types.cs +++ b/Amino.NET/Types.cs @@ -81,8 +81,8 @@ public enum Sorting_Types /// public enum Repair_Types { - Coins, - Membeership + Coins = 1, + Membeership = 2 } /// @@ -254,5 +254,11 @@ public enum Wallet_Config_Levels lvl_1, lvl_2 } + + public enum Repost_Types + { + Blog = 1, + Wiki = 2 + } } } diff --git a/Amino.NET/helpers.cs b/Amino.NET/helpers.cs index aa160d0..fc5b484 100644 --- a/Amino.NET/helpers.cs +++ b/Amino.NET/helpers.cs @@ -48,6 +48,15 @@ public static string generate_signiture(string data) return Convert.ToBase64String(CombineTwoArrays(StringToByteArray(prefix), result)); } + /// + /// Returns the current Amino compatible Timezone + /// + /// + public static int getTimezone() + { + return TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Divide(1000).Seconds; + } + /// /// This function allows you to generate an Amino valid signiture for file uploads /// @@ -204,5 +213,112 @@ public static int get_ObjectTypeID(Types.Object_Types type) return _type; } + + public static int TzFilter() + { + string localhour = DateTime.UtcNow.ToString("HH"); + string localminute = DateTime.UtcNow.ToString("mm"); + Dictionary UTC = new Dictionary { + { "GMT0", "+0" }, + { "GMT1", "+60" }, + { "GMT2", "+120" }, + { "GMT3", "+180" }, + { "GMT4", "+240" }, + { "GMT5", "+300" }, + { "GMT6", "+360" }, + { "GMT7", "+420" }, + { "GMT8", "+480" }, + { "GMT9", "+540" }, + { "GMT10", "+600" }, + { "GMT11", "+660" }, + { "GMT12", "+720" }, + { "GMT13", "+780" }, + { "GMT-1", "-60" }, + { "GMT-2", "-120" }, + { "GMT-3", "-180" }, + { "GMT-4", "-240" }, + { "GMT-5", "-300" }, + { "GMT-6", "-360" }, + { "GMT-7", "-420" }, + { "GMT-8", "-480" }, + { "GMT-9", "-540" }, + { "GMT-10", "-600" }, + { "GMT-11", "-660" } + }; + string[] hour = new string[] { localhour, localminute }; + switch (hour[0]) + { + case "00": + return int.Parse(UTC["GMT-1"]); + case "01": + return int.Parse(UTC["GMT-2"]); + case "02": + return int.Parse(UTC["GMT-3"]); + case "03": + return int.Parse(UTC["GMT-4"]); + case "04": + return int.Parse(UTC["GMT-5"]); + case "05": + return int.Parse(UTC["GMT-6"]); + case "06": + return int.Parse(UTC["GMT-7"]); + case "07": + return int.Parse(UTC["GMT-8"]); + case "08": + return int.Parse(UTC["GMT-9"]); + case "09": + return int.Parse(UTC["GMT-10"]); + case "10": + return int.Parse(UTC["GMT13"]); + case "11": + return int.Parse(UTC["GMT12"]); + case "12": + return int.Parse(UTC["GMT11"]); + case "13": + return int.Parse(UTC["GMT10"]); + case "14": + return int.Parse(UTC["GMT9"]); + case "15": + return int.Parse(UTC["GMT8"]); + case "16": + return int.Parse(UTC["GMT7"]); + case "17": + return int.Parse(UTC["GMT6"]); + case "18": + return int.Parse(UTC["GMT5"]); + case "19": + return int.Parse(UTC["GMT4"]); + case "20": + return int.Parse(UTC["GMT3"]); + case "21": + return int.Parse(UTC["GMT2"]); + case "22": + return int.Parse(UTC["GMT1"]); + case "23": + return int.Parse(UTC["GMT0"]); + default: + return int.Parse(UTC["GMT-1"]); + + } + } + + public static List> getTimeData() + { + long t = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds; + List> timers = new List>(); + for (int i = 0; i < 50; i++) + { + long start = t + (i * 300); + long end = start + 300; + Dictionary timer = new Dictionary + { + {"start", start}, + {"end", end} + }; + timers.Add(timer); + } + return timers; + } + } } diff --git a/Events.md b/Events.md index a22a652..e2cfd24 100644 --- a/Events.md +++ b/Events.md @@ -318,6 +318,258 @@ static void main(string[] args) - Amino.Objects.ChatEvent + +
+onChatContentChanged +

This event fires each time an Amino chat thread Content (Description) has been changed (only for chats where the current Amino account is in)

+ +### Event: +- This event returns an Amino.Objects.ChatEvent Object +### Example: +```CSharp +static void onChatContentChangedEvent(Amino.Objects.ChatEvent chatEvent) +{ + Console.WriteLine($"Content of Chat thread {chatEvent.chatId} has changed."); +} + + +[...] + +static void main(string[] args) +{ + [...] + client.onChatContentChanged += onChatContentChangedEvent; +} +``` + +### Returns: +- Amino.Objects.ChatEvent +
+ + + +
+onChatAnnouncementPin +

This event fires each time an Amino chat Announcement has been pinned / changed (only for chats where the current Amino account is in)

+ +### Event: +- This event returns an Amino.Objects.ChatAnnouncement Object +### Example: +```CSharp +static void onChatAnnouncementChangedEvent(Amino.Objects.ChatAnnouncement chatAnnouncement) +{ + Console.WriteLine($"Chat Announcement of Chat thread {chatAnnouncement.chatId} has changed to {chatAnnouncement.content}."); +} + + +[...] + +static void main(string[] args) +{ + [...] + client.onChatAnnouncementPin += onChatAnnouncementChangedEvent; +} +``` + +### Returns: +- Amino.Objects.ChatAnnouncement +
+ + +
+onChatAnnouncementUnPin +

This event fires each time an Amino chat Announcement has been unpinned / removed (only for chats where the current Amino account is in)

+ +### Event: +- This event returns an Amino.Objects.ChatEvent Object +### Example: +```CSharp +static void onChatAnnouncementRemovedEvent(Amino.Objects.ChatEvent chatEvent) +{ + Console.WriteLine($"Chat Announcement of Chat thread {chatEvent.chatId} has been removed."); +} + + +[...] + +static void main(string[] args) +{ + [...] + client.onChatAnnouncementUnPin += onChatAnnouncementRemovedEvent; +} +``` + +### Returns: +- Amino.Objects.ChatEvent +
+ + +
+onChatViewModeOn +

This event fires each time an Amino chat has been put on ViewMode (only for chats where the current Amino account is in)

+ +### Event: +- This event returns an Amino.Objects.ViewMode Object +### Example: +```CSharp +static void onChatViewModeToggle(Amino.Objects.ViewMode viewMode) +{ + Console.WriteLine($"Chat {viewMode.chatId} got put into ViewMode by {viewMode.Author.nickname}"); +} + + +[...] + +static void main(string[] args) +{ + [...] + client.onChatViewModeOn += onChatViewModeToggle; +} +``` + +### Returns: +- Amino.Objects.ViewMode +
+ + +
+onChatViewModeOff +

This event fires each time an Amino chat has been put out of ViewMode (only for chats where the current Amino account is in)

+ +### Event: +- This event returns an Amino.Objects.ViewMode Object +### Example: +```CSharp +static void onChatViewModeToggle(Amino.Objects.ViewMode viewMode) +{ + Console.WriteLine($"Chat {viewMode.chatId} got put out of ViewMode by {viewMode.Author.nickname}"); +} + + +[...] + +static void main(string[] args) +{ + [...] + client.onChatViewModeOff += onChatViewModeToggle; +} +``` +### Returns: +- Amino.Objects.ViewMode +
+ + +
+onChatTipEnabled +

This event fires each time an Amino chat has enabled Chat Tipping (only for chats where the current Amino account is in)

+ +### Event: +- This event returns an Amino.Objects.chatTipToggle Object +### Example: +```CSharp +static void onChatTipToggle(Amino.Objects.ChatTipToggle chatTipToggle) +{ + Console.WriteLine($"Chat {chatTipToggle.chatId} has enabled tipping"); +} + + +[...] + +static void main(string[] args) +{ + [...] + client.onChatTipEnabled += onChatTipToggle; +} +``` +### Returns: +- Amino.Objects.ChatTipToggle +
+ + +
+onChatTipDisabled +

This event fires each time an Amino chat has disabled Chat Tipping (only for chats where the current Amino account is in)

+ +### Event: +- This event returns an Amino.Objects.chatTipToggle Object +### Example: +```CSharp +static void onChatTipToggle(Amino.Objects.ChatTipToggle chatTipToggle) +{ + Console.WriteLine($"Chat {chatTipToggle.chatId} has disabled tipping"); +} + + +[...] + +static void main(string[] args) +{ + [...] + client.onChatTipDisabled += onChatTipToggle; +} +``` +### Returns: +- Amino.Objects.ChatTipToggle +
+ + +
+onMessageForceRemovedByAdmin +

This event fires each time an Amino chat message has been removed by an admin (only for chats where the current Amino account is in)

+ +### Event: +- This event returns an Amino.Objects.SpecialChatEvent Object +### Example: +```CSharp +static void onMesssageRemoved(Amino.Objects.SpecialChatEvent specialChatEvent) +{ + Console.WriteLine($"Message {specialChatEvent.messageId} has been removed on chat {specialChatEvent.chatId} by {specialChatEvent.Author.nickname}"); +} + + +[...] + +static void main(string[] args) +{ + [...] + client.onMessageForceRemovedByAdmins += onChatMessageRemoved; +} +``` +### Returns: +- Amino.Objects.SpecialChatEvent +
+ + +
+onChatTip +

This event fires each time an Amino user has given a chat tip(only for chats where the current Amino account is in)

+ +### Event: +- This event returns an Amino.Objects.ChatTip Object +### Example: +```CSharp +static void chatTip(Amino.Objects.ChatTip tip) +{ + Console.WriteLine($"User {tip.Author.nickname} has tipped {tip.Extensions.tippedCoins} Coins in chat {tip.chatId}"); +} + + +[...] + +static void main(string[] args) +{ + [...] + client.onChatTip += chatTip; +} +``` +### Returns: +- Amino.Objects.ChatTip +
+ + + + +