public override void ExecuteCommand(EvtChatCommandArgs e) { List <string> args = e.Command.ArgumentsAsList; if (args.Count < 2) { BotProgram.MsgHandler.QueueMessage($"{Globals.CommandIdentifier}addmeme usage: memename memevalue"); return; } if (args[0].ElementAt(0) == '/' || args[1].ElementAt(0) == '/') { BotProgram.MsgHandler.QueueMessage("Memes cannot start with Twitch chat commands!"); return; } if (args[0].ElementAt(0) == Globals.CommandIdentifier) { BotProgram.MsgHandler.QueueMessage($"Memes cannot start with \'{Globals.CommandIdentifier}\'"); return; } if (args[0].ElementAt(0) == Globals.MacroIdentifier) { BotProgram.MsgHandler.QueueMessage($"Memes cannot start with \'{Globals.MacroIdentifier}\'"); return; } if (args[0].Length > MAX_MEME_LENGTH) { BotProgram.MsgHandler.QueueMessage($"The max meme length is {MAX_MEME_LENGTH} characters!"); return; } string memeToLower = args[0].ToLower(); bool sendOverwritten = false; if (BotProgram.BotData.Memes.ContainsKey(memeToLower) == true) { BotProgram.BotData.Memes.TryRemove(memeToLower, out string meme); sendOverwritten = true; } string actualMeme = e.Command.ArgumentsAsString.Remove(0, args[0].Length + 1); BotProgram.BotData.Memes.TryAdd(memeToLower, actualMeme); BotProgram.SaveBotData(); if (sendOverwritten == true) { BotProgram.MsgHandler.QueueMessage("Meme overwritten!"); } else { MemesCommand.CacheMemesString(); } }
public override void ExecuteCommand(EvtChatCommandArgs e) { List <string> args = e.Command.ArgumentsAsList; if (args.Count != 1) { BotProgram.MsgHandler.QueueMessage($"{Globals.CommandIdentifier}removememe usage: memename"); return; } string meme = args[0].ToLower(); if (BotProgram.BotData.Memes.ContainsKey(meme) == true) { BotProgram.BotData.Memes.TryRemove(meme, out string removedMeme); BotProgram.SaveBotData(); MemesCommand.CacheMemesString(); } }