1 parent
df99b6ea7f
commit
d146f11f02
63 files changed
+8331
-2709
No files matched your search
@@ -18,11 +18,26 @@ namespace Echoion::Core
|
||||
|
||||
class MusicManager;
|
||||
|
||||
enum class CommandCategory { Music, Queue, Playback, Utility, Admin };
|
||||
// Declaration order also decides the order of the collapsible sections
|
||||
// in !help (the help map is keyed by this enum). Play and Search lead so
|
||||
// their related commands are grouped together up top.
|
||||
enum class CommandCategory {
|
||||
Play,
|
||||
Search,
|
||||
Music,
|
||||
Queue,
|
||||
Playback,
|
||||
Utility,
|
||||
Admin
|
||||
};
|
||||
|
||||
inline std::string toString(CommandCategory category)
|
||||
{
|
||||
switch (category) {
|
||||
case CommandCategory::Play:
|
||||
return "Play";
|
||||
case CommandCategory::Search:
|
||||
return "Search";
|
||||
case CommandCategory::Music:
|
||||
return "Music";
|
||||
case CommandCategory::Queue:
|
||||
@@ -78,6 +93,32 @@ namespace Echoion::Core
|
||||
return escapeMarkdown(text);
|
||||
}
|
||||
|
||||
// The best public link for a track: the shortened faumaray link when
|
||||
// available, otherwise the original source URL (e.g. the YouTube or
|
||||
// Yandex Music page). Used so every list — search, queue, history,
|
||||
// favorites, stats — links to the real track, never the CDN/stream URL.
|
||||
inline std::optional<std::string> trackLinkUrl(const Api::TrackInfo& track)
|
||||
{
|
||||
if (track.shortenedUrl.has_value() && !track.shortenedUrl->empty()) {
|
||||
return track.shortenedUrl;
|
||||
}
|
||||
if (!track.originalUrl.empty()) {
|
||||
return track.originalUrl;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Render "Title by Artist" (or just Title) as a Markdown link to the
|
||||
// track's best public URL.
|
||||
inline std::string trackLink(const Api::TrackInfo& track)
|
||||
{
|
||||
std::string display = track.title;
|
||||
if (!track.artist.empty()) {
|
||||
display = std::format("{} by {}", track.title, track.artist);
|
||||
}
|
||||
return markdownLink(display, trackLinkUrl(track));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Context passed to every command execution.
|
||||
* Wraps all dependencies required to perform an action.
|
||||
|
||||
Reference in new issue
Block a user