private static KickMessage GetKiMessage(string[] array, int index) { string item = string.Empty; KickMessage value = new KickMessage(); for (int i = index; i < array.Length; i++) { item = array[i]; string[] a = item.Split(':'); if (a.Length > 1) { switch (a[0]) { case "value": value.Way = a[2]; break; case "show_reason": value.ShowReason = int.Parse(a[1]); break; case "reason": value.Reason = Encode.DeUnicode(a[1]); break; default: break; } } } return(value); }
private static KickMessage GetKickMessage(JSONObject obj) { KickMessage data = new KickMessage(); data.Reason = obj.GetString("reason"); data.ShowReason = int.Parse(obj.GetString("show_reason")); data.Way = obj.GetString("way"); return(data); }
/// <summary> /// Finds a message type to handle the message. /// </summary> public ReceivableMessage Process() { // Named messages. if (NickMessage.CanProcess(this)) { return(new NickMessage(this)); } if (QuitMessage.CanProcess(this)) { return(new QuitMessage(this)); } if (JoinMessage.CanProcess(this)) { return(new JoinMessage(this)); } if (PartMessage.CanProcess(this)) { return(new PartMessage(this)); } if (PrivateMessage.CanProcess(this)) { return(new PrivateMessage(this)); } if (PingMessage.CanProcess(this)) { return(new PingMessage(this)); } if (NoticeMessage.CanProcess(this)) { return(new NoticeMessage(this)); } if (UserModeMessage.CanProcess(this)) { return(new UserModeMessage(this)); } if (ChannelModeMessage.CanProcess(this)) { return(new ChannelModeMessage(this)); } if (KickMessage.CanProcess(this)) { return(new KickMessage(this)); } if (InviteMessage.CanProcess(this)) { return(new InviteMessage(this)); } if (OperwallMessage.CanProcess(this)) { return(new OperwallMessage(this)); } if (Receive.TopicMessage.CanProcess(this)) { return(new Receive.TopicMessage(this)); } // IRCv3 messages. if (Receive.v3.CapabilityMessage.CanProcess(this)) { return(new Receive.v3.CapabilityMessage(this)); } if (Receive.v3.AwayMessage.CanProcess(this)) { return(new Receive.v3.AwayMessage(this)); } // Numerics. if (NumericMessage.CanProcess(this)) { // Pass all numeric messages to NumericMessage so an event can be fired, then pass it to more specific instances. // ReSharper disable once ObjectCreationAsStatement new NumericMessage(this); if (WelcomeMessage.CanProcess(this)) { return(new WelcomeMessage(this)); } if (YourHostMessage.CanProcess(this)) { return(new YourHostMessage(this)); } if (CreatedMessage.CanProcess(this)) { return(new CreatedMessage(this)); } if (MyInfoMessage.CanProcess(this)) { return(new MyInfoMessage(this)); } if (SupportMessage.CanProcess(this)) { return(new SupportMessage(this)); } if (BounceMessage.CanProcess(this)) { return(new BounceMessage(this)); } if (MOTDEndMessage.CanProcess(this)) { return(new MOTDEndMessage(this)); } if (MOTDStartMessage.CanProcess(this)) { return(new MOTDStartMessage(this)); } if (MOTDMessage.CanProcess(this)) { return(new MOTDMessage(this)); } if (LUserMessage.CanProcess(this)) { return(new LUserMessage(this)); } if (NamesMessage.CanProcess(this)) { return(new NamesMessage(this)); } if (EndOfNamesMessage.CanProcess(this)) { return(new EndOfNamesMessage(this)); } if (TopicMessage.CanProcess(this)) { return(new TopicMessage(this)); } if (TopicWhoTimeMessage.CanProcess(this)) { return(new TopicWhoTimeMessage(this)); } if (ListMessage.CanProcess(this)) { return(new ListMessage(this)); } if (ListEndMessage.CanProcess(this)) { return(new ListEndMessage(this)); } if (YoureOperMessage.CanProcess(this)) { return(new YoureOperMessage(this)); } if (AwayMessage.CanProcess(this)) { return(new AwayMessage(this)); } if (UnAwayMessage.CanProcess(this)) { return(new UnAwayMessage(this)); } if (NowAwayMessage.CanProcess(this)) { return(new NowAwayMessage(this)); } if (ChannelModeIsMessage.CanProcess(this)) { return(new ChannelModeIsMessage(this)); } if (UModeIsMessage.CanProcess(this)) { return(new UModeIsMessage(this)); } if (VersionMessage.CanProcess(this)) { return(new VersionMessage(this)); } if (TimeMessage.CanProcess(this)) { return(new TimeMessage(this)); } if (WhoMessage.CanProcess(this)) { return(new WhoMessage(this)); } if (WhoisMessage.CanProcess(this)) { return(new WhoisMessage(this)); } if (EndOfWhoMessage.CanProcess(this)) { return(new EndOfWhoMessage(this)); } if (EndOfWhoisMessage.CanProcess(this)) { return(new EndOfWhoisMessage(this)); } if (BanListMessage.CanProcess(this)) { return(new BanListMessage(this)); } if (EndOfBanListMessage.CanProcess(this)) { return(new EndOfBanListMessage(this)); } if (InviteListMessage.CanProcess(this)) { return(new InviteListMessage(this)); } if (EndOfInviteListMessage.CanProcess(this)) { return(new EndOfInviteListMessage(this)); } if (ExceptListMessage.CanProcess(this)) { return(new ExceptListMessage(this)); } if (EndOfExceptListMessage.CanProcess(this)) { return(new EndOfExceptListMessage(this)); } if (IsOnMessage.CanProcess(this)) { return(new IsOnMessage(this)); } // Catch all for unhandled error messages. if (ErrorMessage.CanProcess(this)) { return(new ErrorMessage(this)); } } Console.WriteLine("Message handler for \"" + Text + "\" not found."); return(null); }
/// <summary> /// Do any channel level processing required for the message. /// </summary> /// <param name="message">The message to process.</param> public void HandleMessage(Message message) { Action namesRequest = () => { if (!this.expectingNamesMessage) { this.users.Clear(); this.expectingNamesMessage = true; this.marshal.Send(this.TabPage, new NamesMessage(this.Name)); } }; if (message is JoinMessage) { namesRequest.Invoke(); } else if (message is PartMessage) { PartMessage partMessage = message as PartMessage; if (partMessage.NickName.Equals(this.marshal.Connection.Nickname, StringComparison.OrdinalIgnoreCase)) { this.Dispose(); return; } else { IRCUser user = this.users.Find(i => i.NickName.Equals(partMessage.NickName, StringComparison.OrdinalIgnoreCase)); this.TabPage.RemoveUserFromList(user); this.users.Remove(user); } } else if (message is KickMessage) { KickMessage kickMessage = message as KickMessage; IRCUser user = this.users.Find(i => i.NickName.Equals(kickMessage.NickName, StringComparison.OrdinalIgnoreCase)); this.TabPage.RemoveUserFromList(user); this.users.Remove(user); } else if (message is NickMessage) { NickMessage nickMessage = message as NickMessage; IRCUser user = this.users.Find(i => i.NickName.Equals(nickMessage.OldNickname, StringComparison.OrdinalIgnoreCase)); if (user != null) { this.TabPage.RemoveUserFromList(user); user.NickName = nickMessage.NewNickname; this.TabPage.AddUserToList(user, true); } else { return; } } else if (message is QuitMessage) { QuitMessage quitMessage = message as QuitMessage; IRCUser user = this.users.Find(i => i.NickName.Equals(quitMessage.NickName, StringComparison.OrdinalIgnoreCase)); if (user != null) { this.TabPage.RemoveUserFromList(user); this.users.Remove(user); } else { return; } } else if (message is ModeMessage) { namesRequest.Invoke(); } GlobalSettings settings = GlobalSettings.Instance; if (settings.DebugMode == GlobalSettings.Boolean.Yes) { this.TabPage.AppendMessage(message.Command, "[RAW]", message.ToString(), MessageType.WarningMessage); } this.TabPage.AppendMessage(message.Command, message.Source, message.Content, message.Type); }
internal void OnKick(KickMessage message) => Kick?.Invoke(message);