Skip to content

Commit aca9019

Browse files
committed
add ACM Base
[ + ] Added Types.Join_Types [ + ] Added SubClient.GetClient() [ + ] Added SubClient.GetCurrentCommunityId() [ # ] Changed version from 1.5.2 to 1.6.0 [ + ] Added ACMClient [ + ] Added ACMClient.create_community(string, string, byte[], string, Types.Join_Types, Types.Supported_Languages) [ + ] Added (unfinsihed) ACMClient.delete_community(string, string, string)
1 parent 72e8e05 commit aca9019

3 files changed

Lines changed: 117 additions & 0 deletions

File tree

Amino.NET/ACMClient.cs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
3+
using RestSharp;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Diagnostics;
7+
using System.Linq;
8+
using System.Runtime.InteropServices;
9+
using System.Text;
10+
using System.Text.Json;
11+
using System.Threading.Tasks;
12+
13+
namespace Amino
14+
{
15+
public class ACMClient
16+
{
17+
18+
public Amino.Client Client { get; }
19+
public int CommunityId { get; }
20+
21+
private RestClient RClient { get; }
22+
23+
public ACMClient(Amino.Client client, string communityId)
24+
{
25+
this.Client = client;
26+
this.CommunityId = Convert.ToInt32(communityId);
27+
RClient = new RestClient(helpers.BaseUrl);
28+
RClient.AddDefaultHeaders(Client.headers);
29+
}
30+
public ACMClient(Amino.Client client, int communityId)
31+
{
32+
this.Client = client;
33+
this.CommunityId = communityId;
34+
RClient = new RestClient(helpers.BaseUrl);
35+
RClient.AddDefaultHeaders(Client.headers);
36+
}
37+
38+
public ACMClient(Amino.SubClient client)
39+
{
40+
this.Client = client.GetClient();
41+
this.CommunityId = Convert.ToInt32(client.GetCurrentCommunityId());
42+
RClient = new RestClient(helpers.BaseUrl);
43+
RClient.AddDefaultHeaders(Client.headers);
44+
}
45+
46+
public Task create_community(string name, string tagline, byte[] icon, string themeColor, Types.Join_Types joinType = Types.Join_Types.Open, Types.Supported_Languages primaryLanguage = Types.Supported_Languages.english)
47+
{
48+
string _lang = "en";
49+
switch(primaryLanguage)
50+
{
51+
case Types.Supported_Languages.english:
52+
_lang = "en";
53+
break;
54+
case Types.Supported_Languages.spanish:
55+
_lang = "es";
56+
break;
57+
case Types.Supported_Languages.portuguese:
58+
_lang = "pt";
59+
break;
60+
case Types.Supported_Languages.arabic:
61+
_lang = "ar";
62+
break;
63+
case Types.Supported_Languages.russian:
64+
_lang = "ru";
65+
break;
66+
case Types.Supported_Languages.french:
67+
_lang = "fr";
68+
break;
69+
case Types.Supported_Languages.german:
70+
_lang = "de";
71+
break;
72+
}
73+
JObject data = new JObject()
74+
{
75+
{ "icon", new JObject() {
76+
{ "height", 512.0 },
77+
{ "path", this.Client.upload_media(icon, Types.upload_File_Types.Image) },
78+
{ "width", 512.0 },
79+
{ "x", 0.0 },
80+
{ "y", 0.0 },
81+
{ "imageMatrix", new JArray() { 1.6875, 0.0, 108.0, 0.0, 1.6875, 497.0, 0.0, 0.0, 1.0} }
82+
} },
83+
{ "joinType", (int)joinType },
84+
{ "name", name },
85+
{ "primaryLanguage", _lang },
86+
{ "tagline", tagline },
87+
{ "templateId", 9 },
88+
{ "themeColor", themeColor },
89+
{ "timestamp", helpers.GetTimestamp() * 1000 }
90+
};
91+
RestRequest request = new RestRequest("/g/s/community");
92+
request.AddHeader("NDC-MSG-SIG", helpers.generate_signiture(JsonConvert.SerializeObject(data)));
93+
request.AddJsonBody(JsonConvert.SerializeObject(data));
94+
95+
var response = RClient.ExecutePost(request);
96+
if(!response.IsSuccessStatusCode) { throw new Exception(response.Content); }
97+
if(Client.debug) { Trace.WriteLine(response.Content); }
98+
return Task.CompletedTask;
99+
100+
}
101+
102+
public Task delete_community(string email, string password, string verificationCode)
103+
{
104+
105+
}
106+
107+
}
108+
}

Amino.NET/SubClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,8 @@ public Task play_quiz(string quizId, List<string> questionIdList, List<string> a
17001700
}
17011701

17021702

1703+
public Amino.Client GetClient() => this.client;
1704+
public string GetCurrentCommunityId() => this.communityId;
17031705

17041706
/// <summary>
17051707
/// Not to be used in general use (THIS FUNCTION WILL DISPOSE THE SUBCLIENT)

Amino.NET/Types.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ public enum Featured_Types
133133
Wiki,
134134
Chat
135135
}
136+
137+
public enum Join_Types
138+
{
139+
Open = 0,
140+
Request = 1,
141+
Private = 2
142+
}
136143
public enum Object_Types
137144
{
138145
User = 0,

0 commit comments

Comments
 (0)