From 55f8988bbc099b31bda36a666163cb5b806d5b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=BE=D0=BC=D0=B0=20=D0=94=D0=B0=D0=BD=D0=B8=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2?= <35975332+Nekiplay@users.noreply.github.com> Date: Sat, 1 Aug 2020 16:02:58 +0500 Subject: [PATCH] Allow DLLs in scripts, Update VKAPI (#1158) * Update VKAPI * KeyBoard Update * Add Custom Libs * Change add method --- MinecraftClient/CSharpRunner.cs | 6 +++ MinecraftClient/config/ChatBots/VkMessager.cs | 53 +++++++++++++++++-- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/MinecraftClient/CSharpRunner.cs b/MinecraftClient/CSharpRunner.cs index 58c1885a..1c3ee2f2 100644 --- a/MinecraftClient/CSharpRunner.cs +++ b/MinecraftClient/CSharpRunner.cs @@ -51,12 +51,17 @@ namespace MinecraftClient List script = new List(); List extensions = new List(); List libs = new List(); + List dlls = new List(); foreach (string line in lines) { if (line.StartsWith("//using")) { libs.Add(line.Replace("//", "").Trim()); } + else if (line.StartsWith("//dll")) + { + dlls.Add(line.Replace("//dll ", "").Trim()); + } else if (line.StartsWith("//MCCScript")) { if (line.EndsWith("Extensions")) @@ -107,6 +112,7 @@ namespace MinecraftClient .Select(a => a.Location).ToArray()); parameters.CompilerOptions = "/t:library"; parameters.GenerateInMemory = true; + parameters.ReferencedAssemblies.AddRange(dlls.ToArray()); CompilerResults result = compiler.CompileAssemblyFromSource(parameters, code); //Process compile warnings and errors diff --git a/MinecraftClient/config/ChatBots/VkMessager.cs b/MinecraftClient/config/ChatBots/VkMessager.cs index 1d400fa2..53a712e6 100644 --- a/MinecraftClient/config/ChatBots/VkMessager.cs +++ b/MinecraftClient/config/ChatBots/VkMessager.cs @@ -115,15 +115,15 @@ internal class VkLongPoolClient 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) { - random_id = lastrand; - lastrand++; + random_id = 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) @@ -144,6 +144,51 @@ internal class VkLongPoolClient else 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> buttons = new List>(); + 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() { 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() {