commit
19bd02dbbb
@ -611,162 +611,6 @@ namespace NadekoBot.Modules.Searches
|
||||
}
|
||||
}
|
||||
|
||||
public enum BfGame
|
||||
{
|
||||
Bf3, Bf4
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task BFO(IUserMessage umsg, [Remainder] BfGame game)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
http.DefaultRequestHeaders.Clear();
|
||||
try
|
||||
{
|
||||
if (game == BfGame.Bf3)
|
||||
{
|
||||
var res = await http.GetStringAsync($"http://api.bf3stats.com/global/onlinestats/").ConfigureAwait(false);
|
||||
var items = JObject.Parse(res);
|
||||
var sb = new StringBuilder();
|
||||
var status = items["status"];
|
||||
var x360 = items["360"];
|
||||
var ps3 = items["ps3"];
|
||||
var pc = items["pc"];
|
||||
|
||||
var response = $@"```css
|
||||
[☕ BF3 Status: {status.ToString().ToUpper()}]
|
||||
XBOX360: ✔[{x360.ToString()}]
|
||||
PS3: ✔[{ps3.ToString()}]
|
||||
PC: ✔[{pc.ToString()}]
|
||||
```";
|
||||
await channel.SendMessageAsync(response);
|
||||
}
|
||||
else if (game == BfGame.Bf4)
|
||||
{
|
||||
var res = await http.GetStringAsync($"http://api.bf4stats.com/api/onlinePlayers?output=json").ConfigureAwait(false);
|
||||
var items = JObject.Parse(res);
|
||||
var sb = new StringBuilder();
|
||||
var status = !string.IsNullOrEmpty(items.ToString()) ? "OK" : "BAD";
|
||||
var pc = items["pc"];
|
||||
var ps3 = items["ps3"];
|
||||
var ps4 = items["ps4"];
|
||||
var xbox = items["xbox"];
|
||||
var xone = items["xone"];
|
||||
|
||||
sb.AppendLine("```css");
|
||||
sb.AppendLine($"[☕ BF4 Status: {status}]");
|
||||
|
||||
foreach (var i in items)
|
||||
{
|
||||
var plat = items[i.Key];
|
||||
sb.AppendLine($"{plat["label"]}: ✔[{plat["count"]}] / ↑[{plat["peak24"]}]");
|
||||
}
|
||||
|
||||
sb.Append("```");
|
||||
await channel.SendConfirmAsync(sb.ToString());
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
await channel.SendErrorAsync($"BF3/BF4 API is most likely not working at the moment or could not find {game}.").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task BFU(IUserMessage umsg, string platform, BfGame game, [Remainder] string query = null)
|
||||
{
|
||||
var channel = (ITextChannel)umsg.Channel;
|
||||
if (string.IsNullOrWhiteSpace(platform) || string.IsNullOrWhiteSpace(query))
|
||||
{
|
||||
await channel.SendErrorAsync("Please enter a platform `(pc, xbox, ps3, xone, ps4)`, game `(bf3, bf4)`, followed by a search query.").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await umsg.Channel.TriggerTypingAsync().ConfigureAwait(false);
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
http.DefaultRequestHeaders.Clear();
|
||||
try
|
||||
{
|
||||
if (game == BfGame.Bf3)
|
||||
{
|
||||
var res = await http.GetStringAsync($"http://api.bf3stats.com/{Uri.EscapeUriString(platform)}/playerlist/players={Uri.EscapeUriString(query)}?output=json").ConfigureAwait(false);
|
||||
var items = JObject.Parse(res);
|
||||
var sb = new StringBuilder();
|
||||
var playerName = items["list"][query];
|
||||
var playerTag = playerName["tag"];
|
||||
var playerCountryName = playerName["country_name"];
|
||||
var playerStats = playerName["stats"];
|
||||
var playerRank = playerStats["rank"];
|
||||
var playerRank_name = playerRank["name"];
|
||||
var playerGlobal_Kills = playerStats["global"]["kills"];
|
||||
var playerGlobal_Deaths = playerStats["global"]["deaths"];
|
||||
var playerGlobal_KD = Math.Round(Double.Parse(playerGlobal_Kills.ToString()) / Double.Parse(playerGlobal_Deaths.ToString()), 2);
|
||||
var playerGlobal_Wins = playerStats["global"]["wins"];
|
||||
var playerGlobal_Losses = playerStats["global"]["losses"];
|
||||
var playerGlobal_WL = Math.Round(Double.Parse(playerGlobal_Wins.ToString()) / Double.Parse(playerGlobal_Losses.ToString()), 2);
|
||||
var playerGlobal_Shots = playerStats["global"]["shots"];
|
||||
var playerGlobal_Hits = playerStats["global"]["hits"];
|
||||
var playerGlobal_Accuracy = Math.Round(Double.Parse(playerGlobal_Hits.ToString()) / Double.Parse(playerGlobal_Shots.ToString()), 2);
|
||||
var playerGlobal_ELO = playerStats["global"]["elo"];
|
||||
|
||||
var response = $@"```css
|
||||
[☕ BF3 Player: {query}]
|
||||
Platform: [{platform.ToUpper()}]
|
||||
Tag: [{playerTag.ToString()}]
|
||||
K/D: [{playerGlobal_KD.ToString()}]
|
||||
W/L: [{playerGlobal_WL.ToString()}]
|
||||
Accuracy: %[{playerGlobal_Accuracy.ToString()}]
|
||||
ELO: [{playerGlobal_ELO.ToString()}]
|
||||
```";
|
||||
await channel.SendMessageAsync(response);
|
||||
} else if (game == BfGame.Bf4)
|
||||
{
|
||||
var res = await http.GetStringAsync($"http://api.bf4stats.com/api/playerInfo?plat={Uri.EscapeUriString(platform)}&name={Uri.EscapeUriString(query)}&output=json").ConfigureAwait(false);
|
||||
var items = JObject.Parse(res);
|
||||
var sb = new StringBuilder();
|
||||
|
||||
var player = items["player"];
|
||||
var playerStats = items["stats"];
|
||||
|
||||
var playerName = player["name"];
|
||||
var playerTag = player["tag"];
|
||||
var playerPlatform = player["plat"];
|
||||
var playerKills = playerStats["kills"];
|
||||
var playerDeaths = playerStats["deaths"];
|
||||
var player_KD = Math.Round(Double.Parse(playerKills.ToString()) / Double.Parse(playerDeaths.ToString()), 2);
|
||||
var playerWins = playerStats["numWins"];
|
||||
var playerRounds = playerStats["numRounds"];
|
||||
var player_WL = Math.Round(Double.Parse(playerWins.ToString()) / Double.Parse(playerRounds.ToString()), 2);
|
||||
var shotsFired = playerStats["shotsFired"];
|
||||
var shotsHit = playerStats["shotsHit"];
|
||||
var accuracy = Math.Round(Double.Parse(shotsHit.ToString()) / Double.Parse(shotsFired.ToString()), 2);
|
||||
var playerELO = playerStats["elo"];
|
||||
|
||||
var response = $@"```css
|
||||
[☕ BF4 Player: {playerName.ToString()}]
|
||||
Platform: [{playerPlatform.ToString().ToUpper()}]
|
||||
Tag: [{playerTag.ToString()}]
|
||||
K/D: [{player_KD.ToString()}]
|
||||
W/L: [{player_WL.ToString()}]
|
||||
Accuracy: %[{accuracy.ToString()}]
|
||||
ELO: [{playerELO.ToString()}]
|
||||
```";
|
||||
await channel.SendMessageAsync(response);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
await channel.SendErrorAsync($"BF3/BF4 API is most likely not working at the moment or could not find {query}.").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Wikia(IUserMessage umsg, string target, [Remainder] string query = null)
|
||||
|
54
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
54
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
@ -788,60 +788,6 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to bfonline bfo.
|
||||
/// </summary>
|
||||
public static string bfo_cmd {
|
||||
get {
|
||||
return ResourceManager.GetString("bfo_cmd", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Gives you online players for BF3 and BF4.
|
||||
/// </summary>
|
||||
public static string bfo_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("bfo_desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to `{0}bfo bf3` or `{0}bfo bf4`.
|
||||
/// </summary>
|
||||
public static string bfo_usage {
|
||||
get {
|
||||
return ResourceManager.GetString("bfo_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to bfuser bfu.
|
||||
/// </summary>
|
||||
public static string bfu_cmd {
|
||||
get {
|
||||
return ResourceManager.GetString("bfu_cmd", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Gives you back a battlefield user's stats..
|
||||
/// </summary>
|
||||
public static string bfu_desc {
|
||||
get {
|
||||
return ResourceManager.GetString("bfu_desc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to `{0}bfu platform game user`.
|
||||
/// </summary>
|
||||
public static string bfu_usage {
|
||||
get {
|
||||
return ResourceManager.GetString("bfu_usage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to boobs.
|
||||
/// </summary>
|
||||
|
@ -2673,24 +2673,6 @@
|
||||
<data name="wikia_usage" xml:space="preserve">
|
||||
<value>`{0}wikia mtg Vigilance` or `{0}wikia mlp Dashy`</value>
|
||||
</data>
|
||||
<data name="bfo_cmd" xml:space="preserve">
|
||||
<value>bfonline bfo</value>
|
||||
</data>
|
||||
<data name="bfo_desc" xml:space="preserve">
|
||||
<value>Gives you online players for BF3 and BF4</value>
|
||||
</data>
|
||||
<data name="bfo_usage" xml:space="preserve">
|
||||
<value>`{0}bfo bf3` or `{0}bfo bf4`</value>
|
||||
</data>
|
||||
<data name="bfu_cmd" xml:space="preserve">
|
||||
<value>bfuser bfu</value>
|
||||
</data>
|
||||
<data name="bfu_desc" xml:space="preserve">
|
||||
<value>Gives you back a battlefield user's stats.</value>
|
||||
</data>
|
||||
<data name="bfu_usage" xml:space="preserve">
|
||||
<value>`{0}bfu platform game user`</value>
|
||||
</data>
|
||||
<data name="yandere_cmd" xml:space="preserve">
|
||||
<value>yandere</value>
|
||||
</data>
|
||||
|
Loading…
Reference in New Issue
Block a user