public static void Help(DrakeBot bot, string channel, string user, string command) { if (!bot.Commands.ContainsKey(command)) { bot.Client.SendMessage(channel, "@" + user + " " + "The command " + command + " does not exist"); } else { ICommand com = bot.Commands[command]; string args = ""; foreach (string desc in com.ArgumentDescription) { args += "{" + desc + "} "; } args = args.Trim(' '); bot.Client.SendMessage(channel, "@" + user + " " + com.Name + " (!" + com.Command + " " + args + ") - " + com.Description); } }
public bool Run(DrakeBot bot, OnChatCommandReceivedArgs e) { if (!bot.HasPermission(e.Command.ChatMessage.UserId, e.Command.ChatMessage.Channel, perms[0])) { return(false); } string command = ""; if (e.Command.ArgumentsAsList.Count == 0) { command = "help"; } else { command = e.Command.ArgumentsAsList[0]; } Help(bot, e.Command.ChatMessage.Channel, e.Command.ChatMessage.Username, command); return(true); }
public bool Run(DrakeBot bot, OnChatCommandReceivedArgs e) { BroadcasterInfo broadcaster = bot.ChannelBroadcaster[e.Command.ChatMessage.Channel]; if (!bot.HasPermission(e.Command.ChatMessage.UserId, e.Command.ChatMessage.Channel, perms[0])) { return(false); } Clip retrieved = null; if (e.Command.ArgumentsAsList.Count > 0) { string arg = e.Command.ArgumentsAsList[0]; if (arg.StartsWith("https://clips.twitch.tv/")) { arg = arg.Substring(24); } var split = arg.Split('/'); for (int i = 0; i < split.Length; i++) { if (split[i] != string.Empty) { arg = split[i]; break; } } var getClip = bot.Service.Helix.Clips.GetClipAsync(arg); getClip.Wait(); if (getClip.Result.Clips.Length == 0) { bot.Client.SendMessage(e.Command.ChatMessage.Channel, "@" + e.Command.ChatMessage.Username + " your clip had an invalid id/url"); return(true); } retrieved = getClip.Result.Clips[0]; bot.Client.SendMessage(e.Command.ChatMessage.Channel, "@" + e.Command.ChatMessage.Username + " your clip was retrieved ( " + "https://clips.twitch.tv/" + arg + " )"); } else { var task = bot.Service.Helix.Clips.CreateClipAsync(broadcaster.ID, broadcaster.AccessToken); task.Wait(); var result = task.Result; var clip = result.CreatedClips[0]; bot.Client.SendMessage(e.Command.ChatMessage.Channel, "@" + e.Command.ChatMessage.Username + " your clip was created and is available at https://clips.twitch.tv/" + result.CreatedClips[0].Id); var getClip = bot.Service.Helix.Clips.GetClipAsync(result.CreatedClips[0].Id); getClip.Wait(); while (getClip.Result.Clips.Length == 0) { Thread.Sleep(1000); getClip = bot.Service.Helix.Clips.GetClipAsync(result.CreatedClips[0].Id); getClip.Wait(); } retrieved = getClip.Result.Clips[0]; } var getGame = bot.Service.Helix.Games.GetGamesAsync(new List <string>(new[] { retrieved.GameId })); getGame.Wait(); string game = getGame.Result.Games[0].Name; //TODO: SAVE to database return(true); }