public ServerInfo() { // Guess for some defaults Prefixes = new[] { "ov", "@+" }; SupportedChannelModes = new ChannelModes(); IsGuess = true; }
internal ServerInfo() { // Guess for some defaults Prefixes = new[] { "ovhaq", "@+%&~" }; SupportedChannelModes = new ChannelModes(); IsGuess = true; ExtendedWho = false; }
/// <summary> /// Creates a new instance of the <see cref="Iris.Irc.Channel"/> class with the given channel name. /// </summary> /// <param name="name">The channel's name.</param> public Channel(string name, ChannelModes channelModes = 0) { if (!(name.StartsWith(LocalChannelPrefix.ToString()) || name.StartsWith(GlobalChannelPrefix.ToString()))) throw new FormatException("Channel must start with '" + LocalChannelPrefix + "' (local) or '" + GlobalChannelPrefix + "' (network wide)."); Name = name; ChannelModes = channelModes; Messages = new List<Message>(); Users = new List<User>(); }
private void SetChannelMode(string name, ChannelModes mode, bool set) { if (set) { this.modes = this.modes | mode; } else { this.modes = this.modes & ~mode; } OnSetMode(name, mode, set); }
protected override void OnModeChange(TwitchIrcChannel channel, ChannelModes mode) { // }
public Task <bool> MessageReceived(ProtocolMessage protocolMessage, RealtimeState state) { if (protocolMessage.Channel.IsEmpty()) { return(Task.FromResult(false)); } var channel = _channels.Exists(protocolMessage.Channel) ? GetChannel(protocolMessage.Channel) : null; if (channel == null) { Logger.Warning($"Message received {protocolMessage} for a channel that does not exist {protocolMessage.Channel}"); return(Task.FromResult(false)); } switch (protocolMessage.Action) { case ProtocolMessage.MessageAction.Error: channel.SetChannelState(ChannelState.Failed, protocolMessage); break; case ProtocolMessage.MessageAction.Attached: channel.Properties.AttachSerial = protocolMessage.ChannelSerial; if (protocolMessage.Flags.HasValue) { var modes = new ChannelModes(((ProtocolMessage.Flag)protocolMessage.Flags.Value).FromFlag()); channel.Modes = new ReadOnlyChannelModes(modes.ToList()); } if (protocolMessage.Params != null) { channel.Params = new ReadOnlyChannelParams(protocolMessage.Params); } if (channel.State == ChannelState.Attached) { // RTL12 if (!protocolMessage.HasFlag(ProtocolMessage.Flag.Resumed)) { channel.Presence.ChannelAttached(protocolMessage); channel.EmitUpdate(protocolMessage.Error, false, protocolMessage); } } else { channel.SetChannelState(ChannelState.Attached, protocolMessage); } break; case ProtocolMessage.MessageAction.Detach: case ProtocolMessage.MessageAction.Detached: if (channel.State != ChannelState.Detached) { channel.SetChannelState(ChannelState.Detached, protocolMessage); } break; case ProtocolMessage.MessageAction.Message: if (channel.State == ChannelState.Attaching) { Logger.Warning( $"Channel #{channel.Name} is currently in Attaching state. Messages received in this state are ignored. Ignoring ${protocolMessage.Messages?.Length ?? 0} messages"); return(TaskConstants.BooleanTrue); } if (ValidateIfDeltaItHasCorrectPreviousMessageId(protocolMessage, channel.LastSuccessfulMessageIds) == false) { var message = "Delta message decode failure. Previous message id does not equal expected message id."; var reason = new ErrorInfo(message, ErrorCodes.VcDiffDecodeError); channel.StartDecodeFailureRecovery(reason); return(TaskConstants.BooleanTrue); } var result = _messageHandler.DecodeMessages( protocolMessage, protocolMessage.Messages, channel.MessageDecodingContext); if (result.IsFailure) { Logger.Error($"{channel.Name} - failed to decode message. ErrorCode: {result.Error.Code}, Message: {result.Error.Message}"); if (result.Error is VcDiffErrorInfo) { channel.StartDecodeFailureRecovery(result.Error); // Break any further message processing return(TaskConstants.BooleanTrue); } } channel.LastSuccessfulMessageIds = LastMessageIds.Create(protocolMessage); foreach (var msg in protocolMessage.Messages) { channel.OnMessage(msg); } break; case ProtocolMessage.MessageAction.Presence: case ProtocolMessage.MessageAction.Sync: var presenceDecodeResult = _messageHandler.DecodeMessages( protocolMessage, protocolMessage.Presence, channel.Options); if (presenceDecodeResult.IsFailure) { Logger.Error($"{channel.Name} - failed to decode presence message. ErrorCode: {presenceDecodeResult.Error.Code}, Message: {presenceDecodeResult.Error.Message}"); channel.OnError(presenceDecodeResult.Error); } string syncSerial = protocolMessage.Action == ProtocolMessage.MessageAction.Sync ? protocolMessage.ChannelSerial : null; channel.Presence.OnPresence(protocolMessage.Presence, syncSerial); break; } return(Task.FromResult(true)); }
private void OnSetMode(string name, ChannelModes mode, bool set) { throw new NotImplementedException(); }
/// <summary> /// Sets a channel mode with an integer parameter /// </summary> /// <param name="mode"></param> /// <param name="parameter"></param> public void SetMode(ChannelModes mode, int parameter) { lock (lockObject) { modes = modes | (int)mode; switch (mode) { case ChannelModes.l: if (parameter < 1) { parameter = 0; SetMode(mode, false); } Limit = parameter; break; } } }
/// <summary> /// Sets a channel mode with a string parameter /// </summary> /// <param name="mode"></param> /// <param name="parameter"></param> public void SetMode(ChannelModes mode, string parameter) { lock (lockObject) { modes = modes | (int)mode; switch (mode) { case ChannelModes.k: Key = parameter; if (String.IsNullOrEmpty(Key)) { SetMode(mode, false); } break; } } }
/// <summary> /// Sets a boolean channel mode /// </summary> /// <param name="mode"></param> /// <param name="value"></param> public void SetMode(ChannelModes mode, bool value) { lock (lockObject) { if (value == true) { modes = modes | (int)mode; } else { modes = modes & (~(int)mode); } } }
/// <summary> /// Gets a channel mode /// </summary> /// <param name="mode"></param> /// <returns></returns> public bool GetMode(ChannelModes mode) { lock (lockObject) { return (modes & (int)mode) > 0; } }