public static ServerSetting Create()
        {
            ServerSetting ss = new ServerSetting();

            ss.URL = "https://www.discordapp.com/";

            ss.SendGlobalMessages = true;
            ss.SendLocalMessages  = false;
            ss.SendGroupMessages  = false;
            ss.SendJoinLeave      = true;
            ss.SendArenaUpdates   = true;
            ss.SendVoting         = true;
            ss.SendLoadShutdown   = true;
            ss.SendCommands       = false;
            ss.SendPotentialAbuse = true;
            ss.SendDeaths         = true;
            ss.LinkSenderProfile  = true;
            ss.LinkServer         = false;
            ss.ServerLink         = "https://www.google.com/";
            ss.ShowPlayerCount    = true;
            ss.AbuseTeleport      = true;

            ss.ColorChat         = "FFFF00";
            ss.ColorJoinLeave    = "00FF00";
            ss.ColorVoting       = "FF7700";
            ss.ColorServerStatus = "00FFFF";
            ss.ColorCommands     = "0000FF";
            ss.ColorDeath        = "BD00FF";
            ss.ColorAbuse        = "FF0000";

            return(ss);
        }
Beispiel #2
0
        public static JObject Generate_Abuse(string message, SteamPlayer admin, ServerSetting bot)
        {
            if (admin == null)
            {
                return(null);
            }

            JObject obj       = new JObject();
            JArray  arrEmbeds = new JArray();
            JObject objEmbed  = new JObject();
            JObject objAuthor = new JObject();

            objAuthor.Add("name", admin.playerID.playerName);
            if (bot.LinkSenderProfile)
            {
                objAuthor.Add("url", "http://steamcommunity.com/profiles/" + admin.playerID.steamID.ToString());
            }
            objAuthor.Add("icon_url", UnturnedPlayer.FromSteamPlayer(admin).SteamProfile.AvatarFull.AbsoluteUri);

            objEmbed.Add("title", DiscordHook.Instance.Translations.Instance["abuse_title"]);
            objEmbed.Add("description", message);
            objEmbed.Add("color", int.Parse(bot.ColorAbuse, NumberStyles.HexNumber));
            objEmbed.Add("author", objAuthor);
            arrEmbeds.Add(objEmbed);

            obj.Add("username", DiscordHook.Instance.Configuration.Instance.ServerName);
            obj.Add("tts", false);
            obj.Add("embeds", arrEmbeds);

            return(obj);
        }
Beispiel #3
0
        public static JObject Generate_ServerStatus(string message, ServerSetting bot)
        {
            JObject obj       = new JObject();
            JArray  arrEmbeds = new JArray();
            JObject objEmbed  = new JObject();
            JObject objAuthor = new JObject();

            objAuthor.Add("name", Provider.serverName);
            if (bot.LinkServer)
            {
                objAuthor.Add("url", bot.ServerLink);
            }

            objEmbed.Add("title", DiscordHook.Instance.Translations.Instance["server_status_title"]);
            objEmbed.Add("description", message);
            objEmbed.Add("color", int.Parse(bot.ColorServerStatus, NumberStyles.HexNumber));
            objEmbed.Add("author", objAuthor);
            arrEmbeds.Add(objEmbed);

            obj.Add("username", DiscordHook.Instance.Configuration.Instance.ServerName);
            obj.Add("tts", false);
            obj.Add("embeds", arrEmbeds);

            return(obj);
        }
Beispiel #4
0
        public static JObject Generate_Command(string message, SteamPlayer player, ServerSetting bot)
        {
            JObject obj       = new JObject();
            JArray  arrEmbeds = new JArray();
            JObject objEmbed  = new JObject();
            JObject objAuthor = new JObject();
            JObject objFooter = new JObject();

            objAuthor.Add("name", player.playerID.playerName);
            if (bot.LinkSenderProfile)
            {
                objAuthor.Add("url", "http://steamcommunity.com/profiles/" + player.playerID.steamID.ToString());
            }
            objAuthor.Add("icon_url", UnturnedPlayer.FromSteamPlayer(player).SteamProfile.AvatarFull.AbsoluteUri);

            objFooter.Add("text", string.Format(DiscordHook.Instance.Translations.Instance["player_nick"], player.playerID.nickName));

            objEmbed.Add("title", DiscordHook.Instance.Translations.Instance["player_command_title"]);
            objEmbed.Add("description", message);
            objEmbed.Add("color", int.Parse(bot.ColorCommands, NumberStyles.HexNumber));
            objEmbed.Add("footer", objFooter);
            objEmbed.Add("author", objAuthor);
            arrEmbeds.Add(objEmbed);

            obj.Add("username", DiscordHook.Instance.Configuration.Instance.ServerName);
            obj.Add("tts", false);
            obj.Add("embeds", arrEmbeds);

            return(obj);
        }
 public void LoadDefaults()
 {
     Bots = new List <ServerSetting>()
     {
         ServerSetting.Create()
     };
     ServerName = Provider.serverName;
     AbuseTeleportKillTimeoutSeconds = 5;
 }
Beispiel #6
0
        public static bool SendSingle(JObject WebHook, ServerSetting bot)
        {
            if (WebHook == null)
            {
                return(false);
            }

            try
            {
                using (WebClient weebClient = new WebClient())
                {
                    ServicePointManager.ServerCertificateValidationCallback = (o, certificate, chain, errors) => true;
                    weebClient.Headers[HttpRequestHeader.ContentType]       = "application/json";
                    weebClient.UploadStringAsync(new Uri(bot.URL), WebHook.ToString(Formatting.None));
                }

                return(true);
            }
            catch (Exception) { return(false); }
        }
Beispiel #7
0
        public static JObject Generate_VoteStatus(string message, bool fld, int yes, int no, int needed, string voter, string voted, ServerSetting bot)
        {
            JObject obj       = new JObject();
            JArray  arrEmbeds = new JArray();
            JObject objEmbed  = new JObject();
            JObject objAuthor = new JObject();
            JArray  arrFields = new JArray();
            JObject objData   = new JObject();

            objAuthor.Add("name", Provider.serverName);
            if (bot.LinkServer)
            {
                objAuthor.Add("url", bot.ServerLink);
            }

            objData.Add("name", DiscordHook.Instance.Translations.Instance["vote_status_data"]);
            objData.Add("value", string.Format(DiscordHook.Instance.Translations.Instance["vote_status_yes"], yes) + "\n" +
                        string.Format(DiscordHook.Instance.Translations.Instance["vote_status_no"], no) + "\n" +
                        string.Format(DiscordHook.Instance.Translations.Instance["vote_status_needed"], needed) + "\n" +
                        string.Format(DiscordHook.Instance.Translations.Instance["vote_status_origin"], voter) + "\n" +
                        string.Format(DiscordHook.Instance.Translations.Instance["vote_status_target"], voted));
            objData.Add("inline", true);
            arrFields.Add(objData);

            objEmbed.Add("title", DiscordHook.Instance.Translations.Instance["vote_status_title"]);
            objEmbed.Add("description", message);
            objEmbed.Add("color", int.Parse(bot.ColorVoting, NumberStyles.HexNumber));
            objEmbed.Add("author", objAuthor);
            if (fld)
            {
                objEmbed.Add("fields", arrFields);
            }
            arrEmbeds.Add(objEmbed);

            obj.Add("username", DiscordHook.Instance.Configuration.Instance.ServerName);
            obj.Add("tts", false);
            obj.Add("embeds", arrEmbeds);

            return(obj);
        }
Beispiel #8
0
        public static JObject Generate_Death(string message, SteamPlayer victim, SteamPlayer killer, ServerSetting bot)
        {
            if (killer == null)
            {
                return(null);
            }

            JObject obj       = new JObject();
            JArray  arrEmbeds = new JArray();
            JObject objEmbed  = new JObject();
            JObject objAuthor = new JObject();
            JArray  arrFields = new JArray();
            JObject objKiller = new JObject();

            objAuthor.Add("name", victim.playerID.playerName);
            if (bot.LinkSenderProfile)
            {
                objAuthor.Add("url", "http://steamcommunity.com/profiles/" + victim.playerID.steamID.ToString());
            }
            objAuthor.Add("icon_url", UnturnedPlayer.FromSteamPlayer(victim).SteamProfile.AvatarFull.AbsoluteUri);

            objKiller.Add("name", DiscordHook.Instance.Translations.Instance["player_death_killer"]);
            objKiller.Add("value", string.Format(DiscordHook.Instance.Translations.Instance["player_death_killername"], killer.playerID.playerName) + "\n" +
                          string.Format(DiscordHook.Instance.Translations.Instance["player_death_killernick"], killer.playerID.nickName) + "\n" +
                          string.Format(DiscordHook.Instance.Translations.Instance["player_death_killer64"], killer.playerID.steamID));
            objKiller.Add("inline", true);
            arrFields.Add(objKiller);

            objEmbed.Add("title", DiscordHook.Instance.Translations.Instance["player_death_title"]);
            objEmbed.Add("description", message);
            objEmbed.Add("color", int.Parse(bot.ColorDeath, NumberStyles.HexNumber));
            objEmbed.Add("author", objAuthor);
            objEmbed.Add("fields", arrFields);
            arrEmbeds.Add(objEmbed);

            obj.Add("username", DiscordHook.Instance.Configuration.Instance.ServerName);
            obj.Add("tts", false);
            obj.Add("embeds", arrEmbeds);

            return(obj);
        }