From 5abd1e880014a4e5021c4b96204002b689b31855 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sun, 24 Apr 2016 14:17:49 +0200 Subject: [PATCH] !m q now takes youtube timestamp. Improved description for translate command --- NadekoBot/Modules/Music/Classes/Song.cs | 8 +++++++- NadekoBot/Modules/Translator/TranslateCommand.cs | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Modules/Music/Classes/Song.cs b/NadekoBot/Modules/Music/Classes/Song.cs index 6ebf97d2..4cf1d01d 100644 --- a/NadekoBot/Modules/Music/Classes/Song.cs +++ b/NadekoBot/Modules/Music/Classes/Song.cs @@ -260,7 +260,11 @@ namespace NadekoBot.Modules.Music.Classes if (video == null) // do something with this error throw new Exception("Could not load any video elements based on the query."); - return new Song(new SongInfo + var m = Regex.Match(query, @"\?t=(?\d*)"); + int gotoTime = 0; + if (m.Captures.Count > 0) + int.TryParse(m.Groups["t"].ToString(), out gotoTime); + var song = new Song(new SongInfo { Title = video.Title.Substring(0, video.Title.Length - 10), // removing trailing "- You Tube" Provider = "YouTube", @@ -268,6 +272,8 @@ namespace NadekoBot.Modules.Music.Classes Query = link, ProviderType = musicType, }); + song.SkipTo = gotoTime; + return song; } catch (Exception ex) { diff --git a/NadekoBot/Modules/Translator/TranslateCommand.cs b/NadekoBot/Modules/Translator/TranslateCommand.cs index 0c4ae502..2ac7b43c 100644 --- a/NadekoBot/Modules/Translator/TranslateCommand.cs +++ b/NadekoBot/Modules/Translator/TranslateCommand.cs @@ -13,7 +13,8 @@ namespace NadekoBot.Modules.Translator internal override void Init(CommandGroupBuilder cgb) { cgb.CreateCommand(Module.Prefix + "trans") - .Description("Translates from>to text. From the given language to the destiation language.") + .Alias(Module.Prefix + "translate") + .Description($"Translates from>to text. From the given language to the destiation language.\n**Usage**: {Module.Prefix}trans en>fr Hello") .Parameter("langs", ParameterType.Required) .Parameter("text", ParameterType.Unparsed) .Do(TranslateFunc());