void ParseJTVMessage(ChatMessage message) { // jtv: xxx is now hosting you for up to 4 viewers. // jtv: xxx is now hosting you. Match match = Regex.Match(message.Message, "^(?<user>[^ ]+) is now (auto )?hosting you( for up to (?<viewers>[0-9]+) viewers)?\\.$"); if (match.Success) { Hosted?.Invoke(this, new HostInformation { Service = Service, Channel = match.Groups["user"].Value.ToLower(), Viewers = match.Groups["viewers"].Success ? int.Parse(match.Groups["viewers"].Value) : -1 }); return; } Logger.Warning(this, "Unprocessed message from jtv", message.ToString()); }
protected override bool FilterMessage(ChatMessage message) { if (message.Message.StartsWith("!")) { try { int indexof = message.Message.IndexOf(' '); if (indexof == -1) { CommandReceived?.Invoke(this, new StreamCommand { Service = Service, Channel = Name, IsWhispered = false, User = message.User, Command = message.Message.Substring(1), Arguments = new string[0] }); } else { CommandReceived?.Invoke(this, new StreamCommand { Service = Service, Channel = Name, IsWhispered = false, User = message.User, Command = message.Message.Substring(1, indexof - 1), Arguments = Commands.SplitArguments(message.Message.Substring(indexof + 1)).ToArray() }); } } catch (Exception e) { Logger.Error(this, "Error triggering CommandReceived event", e); } return(true); } return(message.Message.StartsWith("!") || message.User == "jtv" || message.User.ToLower() == "ncstreamrc"); }
protected override bool FilterMessage(ChatMessage message) { if (message.User == "jtv") { ParseJTVMessage(message); return(true); } if (message.Bits > 0) { MicroPresent?.Invoke(this, new MicroPresent { Currency = "Bits", Amount = message.Bits, Service = Service, Username = message.User, Message = message.Message }); } return(base.FilterMessage(message)); }