Allow DLLs in scripts, Update VKAPI (#1158)

* Update VKAPI
* KeyBoard Update
* Add Custom Libs
* Change add method
This commit is contained in:
Рома Данилов 2020-08-01 16:02:58 +05:00 committed by GitHub
parent beebe506d1
commit 55f8988bbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 4 deletions

View file

@ -51,12 +51,17 @@ namespace MinecraftClient
List<string> script = new List<string>(); List<string> script = new List<string>();
List<string> extensions = new List<string>(); List<string> extensions = new List<string>();
List<string> libs = new List<string>(); List<string> libs = new List<string>();
List<string> dlls = new List<string>();
foreach (string line in lines) foreach (string line in lines)
{ {
if (line.StartsWith("//using")) if (line.StartsWith("//using"))
{ {
libs.Add(line.Replace("//", "").Trim()); libs.Add(line.Replace("//", "").Trim());
} }
else if (line.StartsWith("//dll"))
{
dlls.Add(line.Replace("//dll ", "").Trim());
}
else if (line.StartsWith("//MCCScript")) else if (line.StartsWith("//MCCScript"))
{ {
if (line.EndsWith("Extensions")) if (line.EndsWith("Extensions"))
@ -107,6 +112,7 @@ namespace MinecraftClient
.Select(a => a.Location).ToArray()); .Select(a => a.Location).ToArray());
parameters.CompilerOptions = "/t:library"; parameters.CompilerOptions = "/t:library";
parameters.GenerateInMemory = true; parameters.GenerateInMemory = true;
parameters.ReferencedAssemblies.AddRange(dlls.ToArray());
CompilerResults result = compiler.CompileAssemblyFromSource(parameters, code); CompilerResults result = compiler.CompileAssemblyFromSource(parameters, code);
//Process compile warnings and errors //Process compile warnings and errors

View file

@ -115,15 +115,15 @@ internal class VkLongPoolClient
lastrand = LastTs + 1; lastrand = LastTs + 1;
} }
public void SendMessage(string chatId, string text, int random_id = 0) public void SendMessage(string chatId, string text, string keyboard = "", int random_id = 0)
{ {
if (random_id == 0) if (random_id == 0)
{ {
random_id = lastrand; random_id = lastrand;
lastrand++; lastrand++;
} }
CallVkMethod("messages.send", "peer_id=" + chatId + "&random_id=" + random_id + "&message=" + text); CallVkMethod("messages.send", "peer_id=" + chatId + "&random_id=" + random_id + "&message=" + text + "&keyboard=" + keyboard);
} }
public void SendSticker(string chatId, int sticker_id, int random_id = 0) public void SendSticker(string chatId, int sticker_id, int random_id = 0)
@ -144,6 +144,51 @@ internal class VkLongPoolClient
else else
CallVkMethod("groups.disableOnline", "group_id=" + BotCommunityId); CallVkMethod("groups.disableOnline", "group_id=" + BotCommunityId);
} }
public void KickChatUser(string chat_id, string user_id)
{
CallVkMethod("messages.removeChatUser", "chat_id=" + chat_id + "&user_id=" + user_id + "&member_id=" + user_id);
}
public class Keyboard
{
public bool one_time = false;
public List<List<object>> buttons = new List<List<object>>();
public Keyboard(bool one_time2)
{
one_time = one_time2;
}
public void AddButton(string label, string payload, string color)
{
buttons button = new Buttons(label, payload, color);
buttons.Add( new List<object>() { button });
}
public class Buttons
{
public Action action;
public string color;
public Buttons(string labe11, string payload1, string color2)
{
action = new Action(labe11, payload1);
color = color2;
}
public class Action
{
public string type;
public string payload;
public string label;
public Action(string label3, string payload3)
{
type = "text";
payload = "{\"button\": \"" + payload3 + "\"}";
label = label3;
}
}
}
}
private void StartLongPoolAsync() private void StartLongPoolAsync()
{ {