Exemplo n.º 1
0
        private static void MessageProcessing(TorchChatMessage msg, ref bool consumed)
        {
            var infoCommands = EssentialsPlugin.Instance.Config.InfoCommands;

            if (infoCommands == null)
            {
                return;
            }

            var c = infoCommands.FirstOrDefault(i => i.Command?.Equals(msg.Message) == true);

            if (c == null)
            {
                return;
            }

            consumed = true;
            long playerId = MySession.Static.Players.TryGetIdentityId(msg.AuthorSteamId.Value);

            if (!string.IsNullOrEmpty(c.ChatResponse))
            {
                EssentialsPlugin.Instance.Torch.CurrentSession?.Managers?.GetManager <IChatManagerServer>()?.SendMessageAsOther("Server", c.ChatResponse, MyFontEnum.Blue, msg.AuthorSteamId.Value);
            }
            if (!string.IsNullOrEmpty(c.DialogResponse))
            {
                ModCommunication.SendMessageTo(new DialogMessage(c.Command, content: c.DialogResponse), msg.AuthorSteamId.Value);
            }
            if (!string.IsNullOrEmpty(c.URL))
            {
                MyVisualScriptLogicProvider.OpenSteamOverlay($"https://steamcommunity.com/linkfilter/?url={c.URL}", playerId);
            }
        }
Exemplo n.º 2
0
        public async void Link()
        {
            IMyPlayer player = Context.Player;

            if (player == null)
            {
                Context.Respond("Command cannot be ran from console");
                return;
            }

            HttpResponseMessage response;

            using (HttpClient clients = new HttpClient()) {
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("steamid", Context.Player.SteamUserId.ToString()),
                };
                FormUrlEncodedContent content = new FormUrlEncodedContent(pairs);
                response = await clients.PostAsync("http://sedb.uk/discord/guid-manager.php", content);
            }

            string texts = await response.Content.ReadAsStringAsync();

            Dictionary <string, string> kvp = Utils.ParseQueryString(texts);

            if (kvp["existance"] == "false")
            {
                MyVisualScriptLogicProvider.OpenSteamOverlay($"https://steamcommunity.com/linkfilter/?url=http://sedb.uk/?guid={kvp["guid"]}&steamid={Context.Player.SteamUserId}", Context.Player.IdentityId);
                Context.Respond("A browser window has been opened... Please continue there.");
            }
            else
            {
                Context.Respond("Your SteamId has already been linked to discord, if this has not been authenticated by yourself... Please contact your admin");
            }
        }
Exemplo n.º 3
0
 public void TebexDonate()
 {
     if (Context.Player != null)
     {
         MyVisualScriptLogicProvider.OpenSteamOverlay("https://steamcommunity.com/linkfilter/?url=" + System.Uri.EscapeUriString(Tebex.Instance.information.domain), Context.Player.IdentityId);
     }
     Context.Respond("To donate, please visit our webstore: " + Tebex.Instance.information.domain);
 }
Exemplo n.º 4
0
        public void SendMotd(MyPlayer player, bool onSessionChanged)
        {
            long playerId = player.Identity.IdentityId;

            if (!string.IsNullOrEmpty(Config.MotdUrl) && !Config.NewUserMotdUrl)
            {
                var url = MakeUrl(Config.MotdUrl);
                MyVisualScriptLogicProvider.OpenSteamOverlay(url, playerId);
                return;
            }

            var id = player.Client.SteamUserId;

            if (id <= 0)
            {
                return;
            }

            string name = player.Identity?.DisplayName ?? "player";

            bool isNewUser = !_knownIds.Contains(id);

            if (isNewUser)
            {
                _knownIds.Add(id);
            }

            if (!string.IsNullOrEmpty(Config.MotdUrl) && isNewUser && Config.NewUserMotdUrl)
            {
                var url = MakeUrl(Config.MotdUrl);
                MyVisualScriptLogicProvider.OpenSteamOverlay(url, playerId);
                return;
            }

            if (isNewUser && !string.IsNullOrEmpty(Config.NewUserMotd))
            {
                var msg = new DialogMessage(MySession.Static.Name, "New User Message Of The Day", Config.NewUserMotd.Replace("%player%", name));
                ModCommunication.SendMessageTo(msg, id);
                return;
            }

            if (!string.IsNullOrEmpty(Config.Motd))
            {
                var msg = new DialogMessage(MySession.Static.Name, "Message Of The Day", Config.Motd.Replace("%player%", name));
                ModCommunication.SendMessageTo(msg, id);
                return;
            }

            if (!onSessionChanged) // otherwise default motd shows up twice on connection
            {
                var txt = GetDefaultMotdText();
                var msg = new DialogMessage(MySession.Static.Name, "Message Of The Day", txt);
                ModCommunication.SendMessageTo(msg, id);
            }
        }
Exemplo n.º 5
0
        public void SendMotd(MyPlayer player)
        {
            long playerId = player.Identity.IdentityId;

            if (!string.IsNullOrEmpty(Config.MotdUrl) && !Config.NewUserMotdUrl)
            {
                if (MyGuiSandbox.IsUrlWhitelisted(Config.MotdUrl))
                {
                    MyVisualScriptLogicProvider.OpenSteamOverlay(Config.MotdUrl, playerId);
                }
                else
                {
                    MyVisualScriptLogicProvider.OpenSteamOverlay($"https://steamcommunity.com/linkfilter/?url={Config.MotdUrl}", playerId);
                }
            }

            var id = player.Client.SteamUserId;

            if (id <= 0) //can't remember if this returns 0 or -1 on error.
            {
                return;
            }

            string name = player.Identity?.DisplayName ?? "player";

            bool newUser = !Config.KnownSteamIds.Contains(id);

            if (newUser)
            {
                Config.KnownSteamIds.Add(id);
            }
            if (!string.IsNullOrEmpty(Config.MotdUrl) && newUser && Config.NewUserMotdUrl)
            {
                if (MyGuiSandbox.IsUrlWhitelisted(Config.MotdUrl))
                {
                    MyVisualScriptLogicProvider.OpenSteamOverlay(Config.MotdUrl, playerId);
                }
                else
                {
                    MyVisualScriptLogicProvider.OpenSteamOverlay($"https://steamcommunity.com/linkfilter/?url={Config.MotdUrl}", playerId);
                }
            }

            if (newUser && !string.IsNullOrEmpty(Config.NewUserMotd))
            {
                ModCommunication.SendMessageTo(new DialogMessage(MySession.Static.Name, "New User Message Of The Day", Config.NewUserMotd.Replace("%player%", name)), id);
            }
            else if (!string.IsNullOrEmpty(Config.Motd))
            {
                ModCommunication.SendMessageTo(new DialogMessage(MySession.Static.Name, "Message Of The Day", Config.Motd.Replace("%player%", name)), id);
            }
        }
Exemplo n.º 6
0
        private void HandleMessageEntered(string messageText, ref bool sendToOthers)
        {
            string messageLower = messageText.ToLower();

            if (!messageLower.StartsWith("/shipyard"))
            {
                return;
            }

            if (DateTime.Now - _lastMessageTime < TimeSpan.FromMilliseconds(200))
            {
                return;
            }

            if (messageLower.Equals("/shipyard debug on"))
            {
                Logging.Instance.WriteLine("Debug turned on");
                Debug = true;
            }
            else if (messageLower.Equals("/shipyard debug off"))
            {
                Logging.Instance.WriteLine("Debug turned off");
                Debug = false;
            }
            else if (messageLower.Equals("/shipyard new"))
            {
                sendToOthers = false;
                ShowLog();
                return;
            }
            else if (messageLower.Equals("/shipyard workshop"))
            {
                MyVisualScriptLogicProvider.OpenSteamOverlay(@"http://steamcommunity.com/sharedfiles/filedetails/?id=684618597");
                sendToOthers = false;
                return;
            }
            _lastMessageTime = DateTime.Now;

            sendToOthers = false;

            byte[] commandBytes = Encoding.UTF8.GetBytes(messageLower);
            byte[] idBytes      = BitConverter.GetBytes(MyAPIGateway.Session.Player.SteamUserId);

            var message = new byte[commandBytes.Length + sizeof(ulong)];

            idBytes.CopyTo(message, 0);
            commandBytes.CopyTo(message, idBytes.Length);

            Communication.SendMessageToServer(Communication.MessageTypeEnum.ClientChat, message);
        }
Exemplo n.º 7
0
        public void SendMotd(long playerId = 0)
        {
            if (!string.IsNullOrEmpty(Config.MotdUrl))
            {
                if (MyGuiSandbox.IsUrlWhitelisted(Config.MotdUrl))
                {
                    MyVisualScriptLogicProvider.OpenSteamOverlay(Config.MotdUrl, playerId);
                }
                else
                {
                    MyVisualScriptLogicProvider.OpenSteamOverlay($"https://steamcommunity.com/linkfilter/?url={Config.MotdUrl}", playerId);
                }
            }

            if (!string.IsNullOrEmpty(Config.Motd))
            {
                if (MySession.Static.Players.TryGetPlayerId(playerId, out MyPlayer.PlayerId info))
                {
                    Torch.CurrentSession?.Managers?.GetManager <IChatManagerServer>()
                    .SendMessageAsOther("MOTD", Config.Motd, MyFontEnum.Blue, info.SteamId);
                }
            }
        }