void OnPlayerConnected(Player player)
        {
            if (ApiKey == DefaultApiKey || ApiKey == "")
            {
                Log("Error! No Steam API key found.");
                Log("You need to set your API key in the configuration file for this plugin to work!");
                Log("To obtain an API key browse to http://steamcommunity.com/dev/apikey");
                return;
            }

            var playerName = player.DisplayName;
            var steamId = player.Id.ToString();

            if (playerName == "Server" && steamId == "9999999999") return;

            if (Whitelist != null && Whitelist.Contains(steamId))
            {
                if (LogToConsole)
                    Log($"{playerName} with Steam Id {steamId} is whitelisted, allowing the player to join.");
                return;
            }

            string vacbanurl = $"http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key={ApiKey}&steamids={steamId}";
            string familyshareurl = $"http://api.steampowered.com/IPlayerService/IsPlayingSharedGame/v0001/?key={ApiKey}&steamid={steamId}&appid_playing=344760";
            string profileurl = $"http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={ApiKey}&steamids={steamId}";

            if (VacEnabled)
                webRequests.EnqueueGet(vacbanurl, (code, response) => IsVacBanned(code, response, player), this);
            if (ShareEnabled)
                webRequests.EnqueueGet(familyshareurl, (code, response) => IsFamilySharing(code, response, player), this);
            if (PrivateEnabled)
                webRequests.EnqueueGet(profileurl, (code, response) => HasPrivateProfile(code, response, player), this);
        }
Beispiel #2
0
        void GetRewardsForThisPlayer(PlayerSession player)
        {
            if (player.Name.ToLower() == "server")
            {
                return;
            }
            var playerId = player.SteamId;

            timesVoted = 0;
            //Game-Servers.top
            //Puts("http://game-servers.top/api/query.php?apikey=" + Config["tgsApi"] + "&interval=" + Config["trackingInterval"] + "&period=" + Config["trackingType"] + "&steamid=" + playerId + "&app");
            if ((string)Config["tgsApi"] != "" && Config["tgsApi"] != null)
            {
                webRequests.EnqueueGet("http://game-servers.top/api/query.php?apikey=" + Config["tgsApi"] + "&interval=" + Config["trackingInterval"] + "&period=" + Config["trackingType"] + "&steamid=" + playerId + "&app", (code, response) => WebRequestCallbackApi(code, response, player), this);
                Debug(1, "TGS Passing: http://game-servers.top/api/query.php?apikey=" + Config["tgsApi"] + "&interval=" + Config["trackingInterval"] + "&period=" + Config["trackingType"] + "&steamid=" + playerId + "&app");
            }
            //listforge
            if ((string)Config["serverApi"] != "" && Config["serverApi"] != null)
            {
                Puts("http://api.cyberscene.co.za/listforge/votechecker.php?steamid=" + playerId + "&ver=" + this.Version + "&api=" + Config["serverApi"] + "&mode=" + Config["trackingType"] + "&interval=" + Config["trackingInterval"] + "&platform=" + Constants.PLATFORM);
                webRequests.EnqueueGet("http://api.cyberscene.co.za/listforge/votechecker.php?steamid=" + playerId + "&ver=" + this.Version + "&api=" + Config["serverApi"] + "&mode=" + Config["trackingType"] + "&interval=" + Config["trackingInterval"] + "&platform=" + Constants.PLATFORM, (code, response) => WebRequestCallback(code, response, player), this);
                Debug(1, "LF Passing: http://api.cyberscene.co.za/listforge/votechecker.php?steamid=" + playerId + "&ver=" + this.Version + "&api=" + Config["serverApi"] + "&mode=" + Config["trackingType"] + "&interval=" + Config["trackingInterval"] + "&platform=" + Constants.PLATFORM);
            }
            //Puts("http://api.cyberscene.co.za/listforge/votechecker.php?steamid=" + playerId + "&ver=" + this.Version + "&api=" + Config["serverApi"] + "&mode=" + Config["trackingType"] + "&interval=" + Config["trackingInterval"] + "&platform=" + Constants.PLATFORM);
        }
Beispiel #3
0
 private void ExampleGetRequest()
 {
     if ((Boolean)Config["UseVoteSystem"])
     {
         foreach (BasePlayer ply in BasePlayer.activePlayerList)
         {
             webRequests.EnqueueGet("http://rust-servers.net/api/?object=votes&element=claim&key=" + Config["ApiKeyFromRustServers"] + "&format=json", (code, response) => WebRequestCallback(code, response, ply), this);
         }
     }
 }
Beispiel #4
0
        void UpdateLocationData()
        {
            var check_url    = "https://api.github.com/repos/lukespragg/geoip-csv/contents/geoip-locations-en.csv" + auth;
            var download_url = "https://raw.githubusercontent.com/lukespragg/geoip-csv/master/geoip-locations-en.csv";
            var headers      = new Dictionary <string, string> {
                ["User-Agent"] = "Oxide-Awesomesauce"
            };

            web.EnqueueGet(check_url, (api_code, api_response) =>
            {
                if (api_code != 200 || api_response == null)
                {
                    Puts("Checking for locations EN update failed! (" + api_code + ")");
                    if (debug)
                    {
                        Puts(api_response);
                    }
                    return;
                }

                var json           = JsonConvert.DeserializeObject <Dictionary <string, object> >(api_response, jsonSettings);
                string latest_sha  = (string)json["sha"];
                string current_sha = locationData.hash;

                if (latest_sha == current_sha)
                {
                    Puts("Using latest locations EN data, commit: " + current_sha.Substring(0, 7));
                    return;
                }

                Puts("Updating locations EN data to commit " + latest_sha.Substring(0, 7) + "...");
                locationData.hash = latest_sha;

                web.EnqueueGet(download_url, (code, response) =>
                {
                    if (code != 200 || response == null)
                    {
                        timer.Once(30f, UpdateLocationData);
                        return;
                    }

                    locationData.locations = JsonConvert.DeserializeObject <List <LocationEntry> >(CsvToJson(response));
                    locationConfig.WriteObject(locationData);

                    Puts("Locations EN data updated successfully!");
                }, this, null, 300f);
            }, this, headers);
        }
Beispiel #5
0
        void GetEventInfo()
        {
            var url = $"https://donate.childsplaycharity.org/api/event/{EventId}/json/";

            request.EnqueueGet(url, (code, response) =>
            {
                if (code != 200 || response == null)
                {
                    Puts("Checking for event info failed! (" + code + ")");
                    return;
                }

                // Extract the event information
                var json                = JObject.Parse(response);
                eventData.EventId       = EventId;
                eventData.Prefix        = (string)json["prefix"];
                eventData.Title         = (string)json["title"];
                eventData.Description   = (string)json["description"];
                eventData.StartDate     = (string)json["start_date"]; // TODO: Convert to DateTime?
                eventData.EndDate       = (string)json["end_date"];   // TODO: Convert to DateTime?
                eventData.Currency      = (string)json["currency"];
                eventData.Symbol        = ((string)json["symbol"]).Split(' ').Last();
                eventData.Contributions = (int)json["contributions"];
                eventData.Total         = Math.Floor((double)json["total"]);
                eventData.Goal          = (string)json["goal"]; // TODO: Somehow handle "" string if not set
                eventData.Percentage    = (int)json["percentage"];

                // Store updated data
                Interface.Oxide.DataFileSystem.WriteObject(Name, eventData);

                // Update signs
                UpdateSigns();
            }, this);
        }
Beispiel #6
0
        private void PopulateImageList()
        {
            INIT = false;
            ScrapedImages.Clear();
            string type          = "q_type=png"; // Temporary png tag to prevent animated jpg
            string search_string = "http://imgur.com/search/time?" + type + "&q=" + System.Uri.EscapeDataString(Config["Image", "Tags"].ToString());

            scrapeQueue.EnqueueGet(search_string, (code, response) => ParseScrapeResponse(code, response), this);
        }
        private void CheckVote(PlayerSession session)
        {
            Action <int, string> callback = (code, response) =>
            {
                if (string.IsNullOrEmpty(response) || code != 200)
                {
                    hurt.SendChatMessage(session,
                                         lang.GetMessage("Vote - Unknown Error", this, _helpers.GetPlayerId(session)));
                    Log(ELogType.Warning,
                        $"{code}: An error occured while waiting for an response from hurtworld-servers.net for {session.Name}");
                    return;
                }
                int voteState;
                if (!int.TryParse(response, out voteState))
                {
                    hurt.SendChatMessage(session,
                                         lang.GetMessage("Vote - Unknown Error", this, _helpers.GetPlayerId(session)));
                    Log(ELogType.Warning, $"Couldn't parse the response from hurtworld-servers.net for {session.Name}");
                    return;
                }
                switch (voteState)
                {
                case 0:
                    hurt.SendChatMessage(session,
                                         lang.GetMessage("Vote - None", this, _helpers.GetPlayerId(session)));
                    return;

                case 2:
                    hurt.SendChatMessage(session,
                                         lang.GetMessage("Vote - Already Claimed", this, _helpers.GetPlayerId(session)));
                    return;

                case 1:
                    ClaimVote(session);
                    break;
                }
            };

            _webRequests.EnqueueGet(
                $"http://hurtworld-servers.net/api/?object=votes&element=claim&key={_apiKey}&steamid={session.SteamId}",
                callback, this);
        }
Beispiel #8
0
        private void AnnouncePlugins()
        {
            if ((string)Config["tgsApi"] == "" || Config["tgsApi"] == null)
            {
                return;
            }

            foreach (Plugin plugin in plugins.GetAll())
            {
                wrAnnoucePlugin.EnqueueGet("http://game-servers.top/api/query.php?apikey=" + Config["tgsApi"] + "&annoucePlugins&pn=" + plugin.Name + "&pt=" + plugin.Title + "&prid=" + plugin.ResourceId + "&pv=" + plugin.Version
                                           , (code, response) => AnnoucePluginCallback(code, response, plugin.Title), this);
            }
        }
Beispiel #9
0
        void AddDevelopers()
        {
            var url = $"http://steamcommunity.com/groups/{Group}/memberslistxml/?xml=1";

            // Get Steam group members
            request.EnqueueGet(url, (code, response) =>
            {
                if (code != 200 || response == null)
                {
                    Puts("Checking for Steam group members failed! (" + code + ")");
                    Puts("Retrying in 5 seconds...");
                    timer.Once(5f, AddDevelopers);
                    return;
                }

                if (Regex.Matches(response).Count == 0)
                {
                    timer.Once(10f, AddDevelopers);
                }

                foreach (Match match in Regex.Matches(response))
                {
                    // Convert Steam ID to ulong format
                    var steamid = ulong.Parse(match.Groups["steamid"].ToString());

                    // Check if list contains Steam ID
                    if (developerIds.Contains(steamid))
                    {
                        continue;
                    }

                    // Add Steam ID to list
                    Puts($"Added {steamid} to developers list");
                    list.Add(steamid);
                    developers.SetValue(null, list.ToArray());
                    Puts($"{list.Count.ToString()} developers listed");
                }
            }, this);
        }
Beispiel #10
0
        void GiveThisPlayerSomeRewards(Player player)
        {
            if (player.Name.ToLower() == "server")
            {
                return;
            }
            WebRequests webRequests = Interface.GetMod().GetLibrary <WebRequests>("WebRequests");

            var playerId = player.Id;

            PrintToChat(player.Id.ToString());
            var rewardUrl = "http://www.dannyjeffery.com/rokmods/rok-api.php?steamid=" + playerId + "&api=" + rokDotNet_api;

            //rewardUrl = "http://www.dannyjeffery.com/rok-api.php?steamid=" + playerId + "&api=" + rokDotNet_api;
            rewardUrl = "http://arqubus.com/rok-api2.php?steamid=" + playerId + "&api=" + rokDotNet_api;

            PrintToChat("URL = " + rewardUrl);
            Puts("URL = " + rewardUrl);

            webRequests.EnqueueGet(rewardUrl, (code, response) => WebRequestCallback(code, response, player), this);
        }
Beispiel #11
0
 void CheckForBlogs()
 {
     webRequests.EnqueueGet("http://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid=252490&count=1&maxlength=300&format=json", (code, response) => DataRecieved(code, response), this);
 }
Beispiel #12
0
        private void ChatCmd_Config(BasePlayer player, string command, string[] args)
        {
            if (player.net.connection.authLevel < 2)
            {
                PrintToChat(player, "Only admins are allowed to use this function"); return;
            }
            if (args == null || args.Length == 0)
            {
                PrintToChat(player, "TGS API: " + ((string)Config["tgsApi"] == "" ? "No api set, please set ASAP" : (string)Config["tgsApi"]));
                PrintToChat(player, "Listforge API: " + ((string)Config["serverApi"] == "" ? "No api set, please set ASAP" : (string)Config["serverApi"]));
                PrintToChat(player, "ServerID: " + Config["serverId"]);
                PrintToChat(player, "Reward Type: " + Config["trackingInterval"] + Config["trackingType"] + "");
                return;
            }
            if (args[0].Length < 1 || args[1].Length < 1)
            {
                PrintToChat(player, "/rewardconf [api/serverid/tracking/autogive] configValue"); return;
            }

            switch (args[0])
            {
            case "api":
                if (args[1].Equals("listforge"))
                {
                    Config["serverApi"] = args[2];
                    PrintToChat(player, "ServerApi set to " + args[2]);
                }
                else if (args[1].Equals("tgs"))
                {
                    Config["tgsApi"] = args[2];

                    PrintToChat(player, "Game-Server ServerApi set to " + args[2]);

                    //NOW LETS FETCH SOME DETAILS FOR THE SERVER

                    if (player.displayName.ToLower() == "server")
                    {
                        return;
                    }
                    var playerId = player.userID;
                    webRequestsAddress.EnqueueGet("http://game-servers.top/api/query.php?apikey=" + Config["tgsApi"] + "&getAddress", (code, response) => WebRequestCallbackAddress(code, response, player), this);
                    /////////////////////////////////////////////
                }
                break;

            case "serverid":
                Config["serverId"] = args[1];
                PrintToChat(player, "ServerID set to " + args[1]);
                break;

            case "tracking":
                int interval;
                if (int.TryParse(args[1], out interval))
                {
                    Config["trackingInterval"] = args[1];
                    PrintToChat(player, "Interval set to " + args[1]);
                }
                else
                {
                    PrintToChat(player, "Syntax Error: Interval must be an Integer (Number)");
                }

                if (args[2].Equals("month", StringComparison.CurrentCultureIgnoreCase) ||
                    args[2].Equals("week", StringComparison.CurrentCultureIgnoreCase) ||
                    args[2].Equals("day", StringComparison.CurrentCultureIgnoreCase))
                {
                    Config["trackingType"] = args[2];
                    PrintToChat(player, "Tracking set to " + args[2]);
                }
                else
                {
                    PrintToChat(player, "Syntax Error: Tracking must be either month/day/week");
                }
                break;

            case "autoreward":
                bool val;
                if (!bool.TryParse(args[1], out val))
                {
                    PrintToChat(player, "Please enter either true or false.");
                }
                ;
                Config["autoGive"] = val;
                PrintToChat(player, "AutoGive set to " + val);
                break;
            }

            SaveConfig();
        }
Beispiel #13
0
        //---------------------------->   WebRequests   <----------------------------//

        void ShowInfo(BasePlayer player)
        {
            webRequests.EnqueueGet("http://oxidemod.org/plugins/death-notes.819/", (code, response) => VersionRecieved(code, response, player), this);
        }