add a bot header for discord log parsing

This commit is contained in:
Florian Stinglmayr 2024-05-02 20:07:10 +02:00
parent a3b7623557
commit c43d2ff1d3
5 changed files with 35 additions and 8 deletions

View File

@ -111,10 +111,6 @@ public class DiscordLogGenerator {
string summary = GenerateSummary(objective);
log.AppendFormat("**Log Generated:** {0} by {1}\n",
DateTime.Now.ToString("dd/MM/yyyy"),
GetToolVersion()
);
var earliest = GetDateOfEarliestEntry(objective);
var latest = GetDateOfLatestEntry(objective);
if (earliest != null && latest != null) {
@ -149,6 +145,16 @@ public class DiscordLogGenerator {
return log;
}
public virtual string Name {
get { return "GenericLog"; }
}
protected virtual string BotHeader() {
var sb = new StringBuilder();
sb.AppendFormat("**Bot-Header**: {0}; {1}\n", GetToolVersion(), this.Name);
return sb.ToString();
}
public virtual string GenerateDiscordLog(Report report) {
StringBuilder log = new StringBuilder();
@ -164,6 +170,7 @@ public class DiscordLogGenerator {
return "";
}
log.AppendFormat("{0}", BotHeader());
log.AppendFormat("{0}", GenerateHeader());
foreach (Objective objective in objectives) {

View File

@ -2,6 +2,10 @@
public class GenericDiscordLog : DiscordLogGenerator {
public override string ToString() {
return "Generic Log";
return "Generic";
}
public override string Name {
get { return "Generic"; }
}
}

View File

@ -32,8 +32,8 @@ public partial class MainWindow : MetroWindow {
private LoadEntriesWindow loadentries = null;
private static readonly List<DiscordLogGenerator> logtypes = new List<DiscordLogGenerator>() {
new NonaDiscordLog(),
new GenericDiscordLog(),
new NonaDiscordLog(),
new OneLineDiscordLog(),
};

View File

@ -7,6 +7,12 @@ using System.Linq;
namespace EliteBGS.BGS;
public class NonaDiscordLog : DiscordLogGenerator {
protected override string BotHeader() {
var sb = new StringBuilder();
sb.AppendFormat(":robot: `Bot-Header`: {0}; {1}\n", GetToolVersion(), this.Name);
return sb.ToString();
}
private string FormatDate() {
CultureInfo cultureInfo = CultureInfo.InvariantCulture;
StringBuilder date = new StringBuilder();
@ -79,6 +85,10 @@ public class NonaDiscordLog : DiscordLogGenerator {
}
public override string ToString() {
return "Nova Navy Log";
return "Nova Navy";
}
public override string Name {
get { return "NovaNavy"; }
}
}

View File

@ -40,6 +40,8 @@ public class OneLineDiscordLog : DiscordLogGenerator {
return "";
}
log.AppendFormat("{0}\n", BotHeader());
foreach (Objective objective in objectives) {
log.AppendFormat("{0}", GenerateObjectiveHeader(objective));
@ -60,6 +62,10 @@ public class OneLineDiscordLog : DiscordLogGenerator {
}
public override string ToString() {
return "One Line Report";
return "One Line";
}
public override string Name {
get { return "OneLine"; }
}
}