Add fancy printing to lodestone output
This commit is contained in:
parent
b4617838dd
commit
1f41e7cf46
@ -23,16 +23,29 @@ namespace ChaosBot.Discord.Modules
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Character character = LodestoneManager.GetCharacter(id);
|
CharacterDetailed character = LodestoneManager.GetCharacter(id);
|
||||||
|
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
var embed = new EmbedBuilder();
|
var embed = new EmbedBuilder();
|
||||||
|
|
||||||
embed.WithColor(new Color(255, 255,0));
|
embed.WithColor(new Color(255, 255,0));
|
||||||
embed.Title = $"Character Information";
|
embed.Title = $"Character Information";
|
||||||
embed.Url = $"https://na.finalfantasyxiv.com/lodestone/character/{character.ID}/";
|
embed.Url = $"https://na.finalfantasyxiv.com/lodestone/character/{character.Character.ID}/";
|
||||||
embed.ImageUrl = character.Avatar;
|
embed.ImageUrl = character.Character.Avatar;
|
||||||
sb.AppendLine($"{character.Name} ({character.Server})");
|
embed.Footer = new EmbedFooterBuilder().WithText($"Lodestone ID {character.Character.ID}");
|
||||||
|
|
||||||
|
char genderIcon = character.Character.Gender == 1 ? '♂' : '♀';
|
||||||
|
sb.AppendLine($"{character.Character.Name} {genderIcon} ({character.Character.Server})");
|
||||||
|
sb.AppendLine($"Bio: {character.Character.Bio}");
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.AppendLine($"Current Job: {character.Character.ActiveClassJob.Name} (level {character.Character.ActiveClassJob.Level})");
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.AppendLine("All Jobs:");
|
||||||
|
foreach (CharacterClassJob characterClassJob in character.Character.ClassJobs.ToArray())
|
||||||
|
{
|
||||||
|
if (characterClassJob.Level == 0) continue;
|
||||||
|
sb.AppendLine($"{characterClassJob.Name} (level {characterClassJob.Level})");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add the string to the Embed
|
* Add the string to the Embed
|
||||||
@ -64,6 +77,7 @@ namespace ChaosBot.Discord.Modules
|
|||||||
embed.Title = $"Character Information";
|
embed.Title = $"Character Information";
|
||||||
embed.Url = $"https://na.finalfantasyxiv.com/lodestone/character/{character.ID}/";
|
embed.Url = $"https://na.finalfantasyxiv.com/lodestone/character/{character.ID}/";
|
||||||
embed.ImageUrl = character.Avatar;
|
embed.ImageUrl = character.Avatar;
|
||||||
|
embed.Footer = new EmbedFooterBuilder().WithText($"Lodestone ID {character.ID}");
|
||||||
sb.AppendLine($"{character.Name} ({character.Server})");
|
sb.AppendLine($"{character.Name} ({character.Server})");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -84,20 +98,37 @@ namespace ChaosBot.Discord.Modules
|
|||||||
|
|
||||||
[Command("lodestone freecompany")]
|
[Command("lodestone freecompany")]
|
||||||
[Alias("lodestone fc")]
|
[Alias("lodestone fc")]
|
||||||
public async Task GetFreeCompanyById(long id)
|
public async Task GetFreeCompanyById(string id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FreeCompany freeCompany = LodestoneManager.GetFreeCompanyById(id.ToString());
|
FreeCompanyDetailed freeCompany = LodestoneManager.GetFreeCompanyById(id.ToString());
|
||||||
|
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
var embed = new EmbedBuilder();
|
var embed = new EmbedBuilder();
|
||||||
|
|
||||||
embed.WithColor(new Color(255, 255,0));
|
embed.WithColor(new Color(255, 255,0));
|
||||||
embed.Title = $"Free Company Information";
|
embed.Title = $"Free Company Information";
|
||||||
embed.Url = $"https://na.finalfantasyxiv.com/lodestone/freecompany/{freeCompany.ID}/";
|
embed.Url = $"https://na.finalfantasyxiv.com/lodestone/freecompany/{freeCompany.FreeCompany.ID}/";
|
||||||
embed.ImageUrl = freeCompany.Crest.First();
|
embed.ImageUrl = freeCompany.FreeCompany.Crest.First();
|
||||||
sb.AppendLine($"{freeCompany.Name} ({freeCompany.Server})");
|
embed.Footer = new EmbedFooterBuilder().WithText($"Lodestone ID {freeCompany.FreeCompany.ID}");
|
||||||
|
|
||||||
|
sb.AppendLine($"{freeCompany.FreeCompany.Name} ({freeCompany.FreeCompany.Server}, rank {freeCompany.FreeCompany.Rank})");
|
||||||
|
sb.AppendLine($"{freeCompany.FreeCompany.Slogan}");
|
||||||
|
sb.AppendLine();
|
||||||
|
sb.AppendLine($"{freeCompany.FreeCompany.ActiveMemberCount} active members.");
|
||||||
|
sb.AppendLine($"Company estate {freeCompany.FreeCompany.Estate.Plot}");
|
||||||
|
sb.AppendLine($"Pledged to Grand Company {freeCompany.FreeCompany.GrandCompany}");
|
||||||
|
sb.AppendLine();
|
||||||
|
|
||||||
|
var rankCounts = freeCompany.FreeCompanyMembers.GroupBy(m => m.Rank).Select(g => new {Rank = g.Key, Count = g.Count()})
|
||||||
|
.OrderBy(x => x.Rank);
|
||||||
|
|
||||||
|
foreach (string rank in new List<string>{"Council", "Mentor", "Member", "Initiate"})
|
||||||
|
{
|
||||||
|
var rankCount = rankCounts.First(e => e.Rank == rank);
|
||||||
|
sb.AppendLine($"{rankCount.Count} members are of rank {rankCount.Rank} ");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add the string to the Embed
|
* Add the string to the Embed
|
||||||
@ -130,6 +161,8 @@ namespace ChaosBot.Discord.Modules
|
|||||||
embed.Title = $"Free Company Information";
|
embed.Title = $"Free Company Information";
|
||||||
embed.Url = $"https://na.finalfantasyxiv.com/lodestone/freecompany/{freeCompany.ID}/";
|
embed.Url = $"https://na.finalfantasyxiv.com/lodestone/freecompany/{freeCompany.ID}/";
|
||||||
embed.ImageUrl = freeCompany.Crest.First();
|
embed.ImageUrl = freeCompany.Crest.First();
|
||||||
|
embed.Footer = new EmbedFooterBuilder().WithText($"Lodestone ID {freeCompany.ID}");
|
||||||
|
|
||||||
sb.AppendLine($"{freeCompany.Name} ({freeCompany.Server})");
|
sb.AppendLine($"{freeCompany.Name} ({freeCompany.Server})");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -5,10 +5,10 @@ namespace ChaosBot.Lodestone
|
|||||||
public string Avatar;
|
public string Avatar;
|
||||||
public int FeastMatches;
|
public int FeastMatches;
|
||||||
public long ID;
|
public long ID;
|
||||||
public string Lang;
|
public string? Lang;
|
||||||
public string Name;
|
public string Name;
|
||||||
// public ? Rank;
|
public string? Rank;
|
||||||
// public ? RankIcon;
|
public string? RankIcon;
|
||||||
public string Server;
|
public string Server;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
59
ChaosBot/Lodestone/CharacterDetailed.cs
Normal file
59
ChaosBot/Lodestone/CharacterDetailed.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ChaosBot.Lodestone
|
||||||
|
{
|
||||||
|
public class CharacterDetailed
|
||||||
|
{
|
||||||
|
public CharacterDetails Character;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CharacterDetails
|
||||||
|
{
|
||||||
|
public CharacterClassJob ActiveClassJob;
|
||||||
|
public string Avatar;
|
||||||
|
public string Bio;
|
||||||
|
public List<CharacterClassJob> ClassJobs;
|
||||||
|
public string DC;
|
||||||
|
public string FreeCompanyId;
|
||||||
|
public int Gender;
|
||||||
|
public CharacterGrandCompany GrandCompany;
|
||||||
|
public int GuardianDeity;
|
||||||
|
public long ID;
|
||||||
|
public string? Lang;
|
||||||
|
public string Name;
|
||||||
|
public string Nameday;
|
||||||
|
public long ParseDate;
|
||||||
|
public string Portrait;
|
||||||
|
public int Race;
|
||||||
|
public string Server;
|
||||||
|
public int Title;
|
||||||
|
public bool TitleTop;
|
||||||
|
public int Town;
|
||||||
|
public int Tribe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CharacterClassJob
|
||||||
|
{
|
||||||
|
public int ClassID;
|
||||||
|
public long ExpLevel;
|
||||||
|
public long ExpLevelMax;
|
||||||
|
public long ExpLevelTogo;
|
||||||
|
public bool IsSpecialised;
|
||||||
|
public int JobID;
|
||||||
|
public int Level;
|
||||||
|
public string Name;
|
||||||
|
public CharacterClassJobUnlockedState UnlockedState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CharacterGrandCompany
|
||||||
|
{
|
||||||
|
public int NameID;
|
||||||
|
public int RankID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CharacterClassJobUnlockedState
|
||||||
|
{
|
||||||
|
public int? ID;
|
||||||
|
public string Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
56
ChaosBot/Lodestone/FreeCompanyDetailed.cs
Normal file
56
ChaosBot/Lodestone/FreeCompanyDetailed.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ChaosBot.Lodestone
|
||||||
|
{
|
||||||
|
public class FreeCompanyDetailed
|
||||||
|
{
|
||||||
|
public FreeCompanyDetails FreeCompany;
|
||||||
|
public List<FreeCompanyCharacter> FreeCompanyMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FreeCompanyDetails
|
||||||
|
{
|
||||||
|
public string Active;
|
||||||
|
public int ActiveMemberCount;
|
||||||
|
public List<string> Crest;
|
||||||
|
public string DC;
|
||||||
|
public FreeCompanyEstate Estate;
|
||||||
|
public long Formed;
|
||||||
|
public string GrandCompany;
|
||||||
|
public string ID;
|
||||||
|
public string Name;
|
||||||
|
public long ParseDate;
|
||||||
|
public int Rank;
|
||||||
|
public FreeCompanyRanking Ranking;
|
||||||
|
public string Recruitment;
|
||||||
|
public List<FreeCompanyReputation> Reputation;
|
||||||
|
public string Server;
|
||||||
|
public string Slogan;
|
||||||
|
public string Tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FreeCompanyCharacter : Character
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FreeCompanyEstate
|
||||||
|
{
|
||||||
|
public string Greeting;
|
||||||
|
public string Name;
|
||||||
|
public string Plot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FreeCompanyRanking
|
||||||
|
{
|
||||||
|
public int Monthly;
|
||||||
|
public int Weekly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FreeCompanyReputation
|
||||||
|
{
|
||||||
|
public string Name;
|
||||||
|
public int Progress;
|
||||||
|
public string Rank;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,9 +9,9 @@ namespace ChaosBot.Services
|
|||||||
{
|
{
|
||||||
private static readonly Dictionary<Endpoints, string> EndpointPaths = new Dictionary<Endpoints, string>
|
private static readonly Dictionary<Endpoints, string> EndpointPaths = new Dictionary<Endpoints, string>
|
||||||
{
|
{
|
||||||
{Endpoints.CHARACTER_SEARCH_BY_ID, "character/%s"},
|
{Endpoints.CHARACTER_SEARCH_BY_ID, "character/{0}"},
|
||||||
{Endpoints.CHARACTER_SEARCH, "character/search"},
|
{Endpoints.CHARACTER_SEARCH, "character/search"},
|
||||||
{Endpoints.FREECOMPANY_SEARCH_BY_ID, "freecompany/%s"},
|
{Endpoints.FREECOMPANY_SEARCH_BY_ID, "freecompany/{0}"},
|
||||||
{Endpoints.FREECOMPANY_SEARCH, "freecompany/search"},
|
{Endpoints.FREECOMPANY_SEARCH, "freecompany/search"},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -29,10 +29,12 @@ namespace ChaosBot.Services
|
|||||||
return characterWrapper.Results.First();
|
return characterWrapper.Results.First();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Character GetCharacter(long id)
|
public static CharacterDetailed GetCharacter(long id)
|
||||||
{
|
{
|
||||||
PaginationWrapper<Character> characterWrapper = LodestoneHttpProxy.Fetch<PaginationWrapper<Character>>(GetEndpointPaths(Endpoints.CHARACTER_SEARCH_BY_ID, id.ToString()));
|
Dictionary<string, string> parameters = new Dictionary<string, string>
|
||||||
return characterWrapper.Results.First();
|
{{"data", "CJ"}};
|
||||||
|
CharacterDetailed character = LodestoneHttpProxy.Fetch<CharacterDetailed>(GetEndpointPaths(Endpoints.CHARACTER_SEARCH_BY_ID, id.ToString()), parameters);
|
||||||
|
return character;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FreeCompany GetFreeCompany(string server, string name)
|
public static FreeCompany GetFreeCompany(string server, string name)
|
||||||
@ -44,9 +46,12 @@ namespace ChaosBot.Services
|
|||||||
return freeCompanyWrapper.Results.First();
|
return freeCompanyWrapper.Results.First();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FreeCompany GetFreeCompanyById(string id) {
|
public static FreeCompanyDetailed GetFreeCompanyById(string id) {
|
||||||
PaginationWrapper<FreeCompany> freeCompanyWrapper = LodestoneHttpProxy.Fetch<PaginationWrapper<FreeCompany>>(GetEndpointPaths(Endpoints.FREECOMPANY_SEARCH_BY_ID, id));
|
Dictionary<string, string> parameters = new Dictionary<string, string>
|
||||||
return freeCompanyWrapper.Results.First();}
|
{{"data", "FCM"}};
|
||||||
|
FreeCompanyDetailed freeCompany = LodestoneHttpProxy.Fetch<FreeCompanyDetailed>(GetEndpointPaths(Endpoints.FREECOMPANY_SEARCH_BY_ID, id), parameters);
|
||||||
|
return freeCompany;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Endpoints
|
public enum Endpoints
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user