From bb226a9ecedd3925d22f4f8baa2c3221cb734e14 Mon Sep 17 00:00:00 2001 From: Basique Evangelist Date: Mon, 19 Apr 2021 16:14:01 +0300 Subject: [PATCH] Turn GetTopicListing to ToString for Db.Topic --- JetHerald/Commands/DiscordCommands.cs | 2 +- JetHerald/Commands/ListCommand.cs | 6 +----- JetHerald/Db.cs | 3 +++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/JetHerald/Commands/DiscordCommands.cs b/JetHerald/Commands/DiscordCommands.cs index a39af9b..d390f24 100644 --- a/JetHerald/Commands/DiscordCommands.cs +++ b/JetHerald/Commands/DiscordCommands.cs @@ -67,7 +67,7 @@ namespace JetHerald var topics = await db.GetTopicsForChat((long)ctx.Channel.Id, "Discord"); await ctx.RespondAsync(topics.Any() - ? "Topics:\n" + string.Join("\n", topics.Select(ListCommand.GetTopicListing)) + ? "Topics:\n" + string.Join("\n", topics) : "No subscriptions active."); } diff --git a/JetHerald/Commands/ListCommand.cs b/JetHerald/Commands/ListCommand.cs index f0a328c..36af191 100644 --- a/JetHerald/Commands/ListCommand.cs +++ b/JetHerald/Commands/ListCommand.cs @@ -20,12 +20,8 @@ namespace JetHerald var topics = await db.GetTopicsForChat(chatid, "Telegram"); return topics.Any() - ? "Topics:\n" + string.Join("\n", topics.Select(GetTopicListing)) + ? "Topics:\n" + string.Join("\n", topics) : "No subscriptions active."; } - - internal static string GetTopicListing(Db.Topic t) - => t.Name == t.Description ? t.Name : $"{t.Name}: {t.Description}"; - } } \ No newline at end of file diff --git a/JetHerald/Db.cs b/JetHerald/Db.cs index 14db2f3..bf62820 100644 --- a/JetHerald/Db.cs +++ b/JetHerald/Db.cs @@ -25,6 +25,9 @@ namespace JetHerald public long? ChatId { get; set; } public string Service { get; set; } + + public override string ToString() + => Name == Description ? Name : $"{Name}: {Description}"; } public class ExpiredTopicChat