EDBGS/EliteBGS/OneLineDiscordLog.cs

72 lines
1.9 KiB
C#
Raw Normal View History

using EliteBGS.LogGenerator;
using System.Linq;
using System.Text;
namespace EliteBGS;
public class OneLineDiscordLog : DiscordLogGenerator {
protected override string GenerateObjectiveHeader(Objective objective) {
if (!string.IsNullOrEmpty(objective.Faction)) {
2022-12-16 21:48:16 +01:00
return string.Format("**{0}** for **{1}**: ", objective.System, objective.Faction);
} else {
2022-12-16 21:48:16 +01:00
return string.Format("**{0}**: ", objective.System);
}
}
protected override string GenerateObjectiveFooter(Objective objective) {
return "\n";
}
protected override string GenerateFooter() {
return "";
}
protected override string GenerateHeader() {
return "";
}
public override string GenerateDiscordLog(Report report) {
StringBuilder log = new StringBuilder();
if (report == null) {
return "";
}
var objectives = report.Objectives
.Where(x => x.IsEnabled && x.Transactions.Count() > 0)
;
if (objectives == null || objectives.Count() <= 0) {
return "";
}
log.AppendFormat("{0}\n", BotHeader());
foreach (Objective objective in objectives) {
log.AppendFormat("{0}", GenerateObjectiveHeader(objective));
foreach (LogFormatter formatter in formatters) {
string text = formatter.GenerateSummary(objective);
text = text.Trim();
if (!string.IsNullOrEmpty(text)) {
log.AppendFormat("{0}; ", text);
}
}
log.AppendFormat("{0}", GenerateObjectiveFooter(objective));
}
log.AppendFormat("{0}", GenerateFooter());
return log.ToString().Trim();
}
public override string ToString() {
return "One Line";
}
public override string Name {
get { return "OneLine"; }
}
}