예제 #1
0
파일: MOTD.cs 프로젝트: jasegiffin/JustUO
		private static bool HandlePopupRequest(PlayerMobile user, MOTDMessage message)
		{
			if (user == null || user.Deleted)
			{
				return false;
			}

			if (message == null)
			{
				user.SendMessage(0x22, "No message to display.");
				return false;
			}

			SuperGump.Send(new MOTDMessageOverviewGump(user, selected: message));
			return true;
		}
예제 #2
0
        /// <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);
        }
예제 #3
0
		private static bool Deserialize(XmlDocument doc)
		{
			VitaNexCore.TryCatch(
				() =>
				{
					if (doc.FirstChild == null || doc.FirstChild.Name != "messages")
					{
						return;
					}

					XmlElement root = doc["messages"];

					if (root == null)
					{
						return;
					}

					MOTDMessage message;
					TimeStamp date;
					bool published;
					string author, title, content, uid;

					foreach (XmlElement node in root)
					{
						VitaNexCore.TryCatch(
							() =>
							{
								date = node.HasAttribute("timestamp")
										   ? (TimeStamp)Double.Parse(node.GetAttribute("timestamp"))
										   : TimeStamp.UtcNow;
								published = !node.HasAttribute("published") || Boolean.Parse(node.GetAttribute("published"));
								author = node.HasAttribute("author") ? node.GetAttribute("author") : "Anonymous";
								title = node.HasAttribute("title") ? node.GetAttribute("title") : "Update";
								content = node["content"] != null ? node["content"].InnerText.Replace(@"\r\n", "[br]") : String.Empty;

								uid = node.HasAttribute("uid")
										  ? node.GetAttribute("uid")
										  : CryptoGenerator.GenString(CryptoHashType.MD5, String.Format("{0}", date.Stamp)).Replace("-", "");

								message = new MOTDMessage(uid, date, title, content, author, published);

								if (Messages.ContainsKey(uid))
								{
									Messages[uid] = message;
								}
								else
								{
									Messages.Add(uid, message);
								}
							},
							CMOptions.ToConsole);
					}
				},
				CMOptions.ToConsole);

			return true;
		}