private static void HandleChatMessage(TwitchChatMessage msg) { if (!msg.Message.StartsWith("!")) { return; } var cmd = msg.Message.Substring(1); ChatCommand chatCommand; if (Commands.TryGetValue(cmd, out chatCommand)) { chatCommand.Execute(msg); } else { Log.Info($"Unknown command by {msg.User}: {msg.Message}", "TwitchPlugin"); } }
public void Execute(TwitchChatMessage msg) { Logger.WriteLine(string.Format("Command \"{0}\" requested by {1}.", _command, msg.User), "TwitchPlugin"); if(_generalConfigItem != null && !Config.GetConfigItem<bool>(_generalConfigItem)) { Logger.WriteLine(string.Format("Command \"{0}\" is disabled (general).", _command), "TwitchPlugin"); return; } if(!Config.GetConfigItem<bool>(_configItem)) { Logger.WriteLine(string.Format("Command \"{0}\" is disabled.", _command), "TwitchPlugin"); return; } if((DateTime.Now - _lastExecute).TotalSeconds < 10) { Logger.WriteLine(string.Format("Time since last execute of {0} is less than 10 seconds. Not executing.", _command), "TwitchPlugin"); return; } _lastExecute = DateTime.Now; _action.Invoke(); }
public void Execute(TwitchChatMessage msg) { Log.Info($"Command \"{_command}\" requested by {msg.User}.", "TwitchPlugin"); if (_generalConfigItem != null && !Config.GetConfigItem <bool>(_generalConfigItem)) { Log.Info($"Command \"{_command}\" is disabled (general).", "TwitchPlugin"); return; } if (!Config.GetConfigItem <bool>(_configItem)) { Log.Info($"Command \"{_command}\" is disabled.", "TwitchPlugin"); return; } if ((DateTime.Now - _lastExecute).TotalSeconds < 10) { Log.Info($"Time since last execute of {_command} is less than 10 seconds. Not executing.", "TwitchPlugin"); return; } _lastExecute = DateTime.Now; _action.Invoke(); }
private static void HandleChatMessage(TwitchChatMessage msg) { if(!msg.Message.StartsWith("!")) return; var cmd = msg.Message.Substring(1); ChatCommand chatCommand; if(Commands.TryGetValue(cmd, out chatCommand)) chatCommand.Execute(msg); else Logger.WriteLine(string.Format("Unknown command by {0}: {1}", msg.User, msg.Message), "TwitchPlugin"); }