!m q now takes youtube timestamp. Improved description for translate command

This commit is contained in:
Master Kwoth 2016-04-24 14:17:49 +02:00
parent 9d10d78727
commit 5abd1e8800
2 changed files with 9 additions and 2 deletions

View File

@ -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=(?<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)
{

View File

@ -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());