示例#1
0
        public void AddModerator(ChatUser user, ChatUser moderator)
        {
            if (!ValidateModerator(moderator))
            {
                return;
            }

            if (IsBanned(user) || IsModerator(user))
            {
                return;
            }

            if (IsVoiced(user))
            {
                m_Voices.Remove(user);
            }

            m_Moderators.Add(user);

            if (moderator != null)
            {
                user.SendMessage(50, moderator.Username);       // %1 has made you a conference moderator.
            }
            SendMessage(48, user, user.Username);               // %1 is now a conference moderator.
            SendCommand(ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username);
        }
示例#2
0
		public static void EmoteMessage( ChatUser from, Channel channel, string param )
		{
			if ( channel.CanTalk( from ) )
				channel.SendIgnorableMessage( 58, from, from.GetColorCharacter() + from.Username, param ); // %1 %2
			else
				from.SendMessage( 36 ); // The moderator of this conference has not given you speaking priviledges.
		}
示例#3
0
        public void Kick(ChatUser user, ChatUser moderator, bool wasBanned)
        {
            if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user))
            {
                return;
            }

            if (Contains(user))
            {
                if (moderator != null)
                {
                    if (wasBanned)
                    {
                        user.SendMessage(63, moderator.Username);                           // %1, a conference moderator, has banned you from the conference.
                    }
                    else
                    {
                        user.SendMessage(45, moderator.Username);                           // %1, a conference moderator, has kicked you out of the conference.
                    }
                }

                RemoveUser(user);
                ChatSystem.SendCommandTo(user.Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username);

                SendMessage(44, user.Username);                    // %1 has been kicked out of the conference.
            }

            if (wasBanned && moderator != null)
            {
                moderator.SendMessage(62, user.Username);                   // You are banning %1 from this conference.
            }
        }
        public static void PrivateMessage(ChatUser from, Channel channel, string param)
        {
            int indexOf = param.IndexOf(' ');

            string name = param.Substring(0, indexOf);
            string text = param.Substring(indexOf + 1);

            ChatUser target = ChatSystem.SearchForUser(from, name);

            if (target == null)
            {
                return;
            }

            if (target.IsIgnored(from))
            {
                // %1 has chosen to ignore you. None of your messages to them will get through.
                from.SendMessage(35, target.Username);
            }
            else if (target.IgnorePrivateMessage)
            {
                // %1 has chosen to not receive private messages at the moment.
                from.SendMessage(42, target.Username);
            }
            else
            {
                // [%1]: %2
                target.SendMessage(59, from.Mobile, from.GetColorCharacter() + from.Username, text);
            }
        }
 public static void DisallowPrivateMessages(ChatUser from, Channel channel, string param)
 {
     from.IgnorePrivateMessage = true;
     from.SendMessage(38);               /* You will no longer receive private messages.
                                          * Those who send you a message will be notified that you are blocking incoming messages.
                                          */
 }
        public static void JoinChannel(ChatUser from, Channel channel, string param)
        {
            string name;
            string password = null;

            int start = param.IndexOf('\"');

            if (start >= 0)
            {
                int end = param.IndexOf('\"', ++start);

                if (end >= 0)
                {
                    name     = param.Substring(start, end - start);
                    password = param.Substring(++end);
                }
                else
                {
                    name = param.Substring(start);
                }
            }
            else
            {
                int indexOf = param.IndexOf(' ');

                if (indexOf >= 0)
                {
                    name     = param.Substring(0, indexOf++);
                    password = param.Substring(indexOf);
                }
                else
                {
                    name = param;
                }
            }

            if (password != null)
            {
                password = password.Trim();
            }

            if (password != null && password.Length == 0)
            {
                password = null;
            }

            Channel joined = Channel.FindChannelByName(name);

            if (joined == null)
            {
                // There is no conference named '%1'.
                from.SendMessage(33, name);
            }
            else
            {
                joined.AddUser(from, password);
            }
        }
示例#7
0
        public static void QueryWhoIs(ChatUser from, Channel channel, string param)
        {
            ChatUser target = ChatSystem.SearchForUser(from, param);

            if (target == null)
            {
                return;
            }

            if (target.Anonymous)
            {
                from.SendMessage(41, target.Username);                   // %1 is remaining anonymous.
            }
            else
            {
                from.SendMessage(43, target.Username, target.Mobile.Name);                   // %2 is known in the lands of Britannia as %2.
            }
        }
示例#8
0
        public static ChatUser SearchForUser(ChatUser from, string name)
        {
            ChatUser user = ChatUser.GetChatUser(name);

            if (user == null)
            {
                from.SendMessage(32, name);                   // There is no player named '%1'.
            }
            return(user);
        }
示例#9
0
        public bool ValidateModerator(ChatUser user)
        {
            if (user != null && !IsModerator(user))
            {
                user.SendMessage(29);                   // You must have operator status to do this.
                return(false);
            }

            return(true);
        }
示例#10
0
        public bool AddUser(ChatUser user, string password)
        {
            if (Contains(user))
            {
                user.SendMessage(46, m_Name);                   // You are already in the conference '%1'.
                return(true);
            }

            else if (IsBanned(user))
            {
                user.SendMessage(64);                   // You have been banned from this conference.
                return(false);
            }

            else if (!ValidatePassword(password))
            {
                user.SendMessage(34);                   // That is not the correct password.
                return(false);
            }

            else
            {
                if (user.CurrentChannel != null)
                {
                    user.CurrentChannel.RemoveUser(user);                       // Remove them from their current channel first
                }
                //ChatSystem.SendCommandTo( user.Mobile, ChatCommand.JoinedChannel, m_Name );
                SendCommand(ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username);

                m_Users.Add(user);
                user.CurrentChannel = this;

                if (user.Mobile.AccessLevel >= AccessLevel.GameMaster || (!m_AlwaysAvailable && m_Users.Count == 1))
                {
                    AddModerator(user);
                }

                SendUsersTo(user);

                return(true);
            }
        }
示例#11
0
 public static void EmoteMessage(ChatUser from, Channel channel, string param)
 {
     if (channel.CanTalk(from))
     {
         channel.SendIgnorableMessage(58, from, from.GetColorCharacter() + from.Username, param);                   // %1 %2
     }
     else
     {
         from.SendMessage(36);                   // The moderator of this conference has not given you speaking priviledges.
     }
 }
示例#12
0
        public static void JoinChannel(ChatUser from, Channel channel, string param)
        {
            string name;
            string password = null;

            var start = param.IndexOfOrdinal('\"');

            if (start >= 0)
            {
                var end = param.IndexOf('\"', ++start);

                if (end >= 0)
                {
                    name     = param.Substring(start, end - start);
                    password = param.Substring(++end);
                }
                else
                {
                    name = param.Substring(start);
                }
            }
            else
            {
                var indexOf = param.IndexOfOrdinal(' ');

                if (indexOf >= 0)
                {
                    name     = param.Substring(0, indexOf++);
                    password = param.Substring(indexOf);
                }
                else
                {
                    name = param;
                }
            }

            password = (password?.Trim()).DefaultIfNullOrEmpty(null);

            var joined = Channel.FindChannelByName(name);

            if (joined == null)
            {
                from.SendMessage(33, name); // There is no conference named '%1'.
            }
            else
            {
                joined.AddUser(from, password);
            }
        }
示例#13
0
        public static void ChatAction(NetState state, PacketReader pvSrc)
        {
            if (!Enabled)
            {
                return;
            }

            try
            {
                Mobile   from = state.Mobile;
                ChatUser user = ChatUser.GetChatUser(from);

                if (user == null)
                {
                    return;
                }

                string lang     = pvSrc.ReadStringSafe(4);
                short  actionId = pvSrc.ReadInt16();
                string param    = pvSrc.ReadUnicodeString();

                ChatActionHandler handler = ChatActionHandlers.GetHandler(actionId);

                if (handler != null)
                {
                    Channel channel = user.CurrentChannel;

                    if (handler.RequireConference && channel == null)
                    {
                        /* You must be in a conference to do this.
                         * To join a conference, select one from the Conference menu.
                         */
                        user.SendMessage(31);
                    }
                    else
                    {
                        handler.Callback(user, channel, param);
                    }
                }
                else
                {
                    Console.WriteLine("Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionId, param);
                }
            }
            catch (Exception e)
            {
                Diagnostics.ExceptionLogging.LogException(e);
            }
        }
示例#14
0
        public void RemoveModerator(ChatUser user, ChatUser moderator)
        {
            if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user))
            {
                return;
            }

            if (IsModerator(user))
            {
                m_Moderators.Remove(user);

                if (moderator != null)
                {
                    user.SendMessage(49, moderator.Username);           // %1 has removed you from the list of conference moderators.
                }
                SendMessage(47, user, user.Username);                   // %1 is no longer a conference moderator.
                SendCommand(ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username);
            }
        }
示例#15
0
        public void RemoveVoiced(ChatUser user, ChatUser moderator)
        {
            if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user))
            {
                return;
            }

            if (!IsModerator(user) && IsVoiced(user))
            {
                m_Voices.Remove(user);

                if (moderator != null)
                {
                    user.SendMessage(53, moderator.Username);           // %1, a conference moderator, has removed your speaking priviledges for this conference.
                }
                SendMessage(51, user, user.Username);                   // %1 no longer has speaking privileges in this conference.
                SendCommand(ChatCommand.AddUserToChannel, user, user.GetColorCharacter() + user.Username);
            }
        }
示例#16
0
        public void AddVoiced(ChatUser user, ChatUser moderator)
        {
            if (!ValidateModerator(moderator))
            {
                return;
            }

            if (!IsBanned(user) && !IsModerator(user) && !IsVoiced(user))
            {
                m_Voices.Add(user);

                if (moderator != null)
                {
                    user.SendMessage(54, moderator.Username);           // %1, a conference moderator, has granted you speaking priviledges in this conference.
                }
                SendMessage(52, user, user.Username);                   // %1 now has speaking privileges in this conference.
                SendCommand(ChatCommand.AddUserToChannel, user, user.GetColorCharacter() + user.Username);
            }
        }
示例#17
0
        public void SendMessage(int number, ChatUser initiator, string param1, string param2)
        {
            for (int i = 0; i < m_Users.Count; ++i)
            {
                ChatUser user = (ChatUser)m_Users[i];

                if (user == initiator)
                {
                    continue;
                }

                if (user.CheckOnline())
                {
                    user.SendMessage(number, param1, param2);
                }
                else if (!Contains(user))
                {
                    --i;
                }
            }
        }
示例#18
0
        public void SendIgnorableMessage(int number, ChatUser from, string param1, string param2)
        {
            for (int i = 0; i < m_Users.Count; ++i)
            {
                ChatUser user = (ChatUser)m_Users[i];

                if (user.IsIgnored(from))
                {
                    continue;
                }

                if (user.CheckOnline())
                {
                    user.SendMessage(number, from.Mobile, param1, param2);
                }
                else if (!Contains(user))
                {
                    --i;
                }
            }
        }
		public void AddUser( ChatUser user )
		{
			if ( Contains( user ) )
			{
				user.SendMessage( 46, m_Name ); // You are already in the conference '%1'.
			}
			else
			{
				if ( user.CurrentChannel != null )
					user.CurrentChannel.RemoveUser( user ); // Remove them from their current channel first

				ChatSystem.SendCommandTo( user.Mobile, ChatCommand.JoinedChannel, m_Name );

				SendCommand( ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );

				m_Users.Add( user );
				user.CurrentChannel = this;

				SendUsersTo( user );

				ChatLogging.LogJoin( this.Name, user.Username );
			}
		}
示例#20
0
        public void AddUser(ChatUser user)
        {
            if (Contains(user))
            {
                user.SendMessage(46, m_Name); // You are already in the conference '%1'.
            }
            else
            {
                if (user.CurrentChannel != null)
                {
                    user.CurrentChannel.RemoveUser(user); // Remove them from their current channel first
                }
                ChatSystem.SendCommandTo(user.Mobile, ChatCommand.JoinedChannel, m_Name);

                SendCommand(ChatCommand.AddUserToChannel, ChatUser.GetColorCharacter() + user.Username);

                m_Users.Add(user);
                user.CurrentChannel = this;

                SendUsersTo(user);

                ChatLogging.LogJoin(Name, user.Username);
            }
        }
		public static void PrivateMessage( ChatUser from, Channel channel, string param )
		{	// stop crash by ensuring we don't continue processing if indexOf == -1
			param = param.Trim();
			int indexOf = param.IndexOf( ' ' );
			if (indexOf >= 0)
			{
				string name = param.Substring(0, indexOf);
				string text = param.Substring(indexOf + 1);

				ChatUser target = ChatSystem.SearchForUser(from, name);

				if (target == null)
					return;

				if (target.IsIgnored(from))
					from.SendMessage(35, target.Username); // %1 has chosen to ignore you. None of your messages to them will get through.
				else if (target.IgnorePrivateMessage)
					from.SendMessage(42, target.Username); // %1 has chosen to not receive private messages at the moment.
				else
					target.SendMessage(59, from.Mobile, from.GetColorCharacter() + from.Username, text); // [%1]: %2
			}
		}
		public static void ChangeChannelPassword( ChatUser from, Channel channel, string param )
		{
			channel.Password = param;
			from.SendMessage( 60 ); // The password to the conference has been changed.
		}
示例#23
0
 public static void ToggleCharacterName(ChatUser from, Channel channel, string param)
 {
     from.Anonymous = !from.Anonymous;
     from.SendMessage(from.Anonymous ? 40 : 39);               // See above for messages
 }
示例#24
0
 public static void HideCharacterName(ChatUser from, Channel channel, string param)
 {
     from.Anonymous = true;
     from.SendMessage(40);               // You are no longer showing your character name to any players who inquire with the whois command.
 }
		public static void HideCharacterName( ChatUser from, Channel channel, string param )
		{
			from.Anonymous = true;
			from.SendMessage( 40 ); // You are no longer showing your character name to any players who inquire with the whois command.
		}
示例#26
0
		public void RemoveModerator( ChatUser user, ChatUser moderator )
		{
			if ( !ValidateModerator( moderator ) || !ValidateAccess( moderator, user ) )
				return;

			if ( IsModerator( user ) )
			{
				m_Moderators.Remove( user );

				if ( moderator != null )
					user.SendMessage( 49, moderator.Username ); // %1 has removed you from the list of conference moderators.

				SendMessage( 47, user, user.Username ); // %1 is no longer a conference moderator.
				SendCommand( ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
			}
		}
示例#27
0
		public void RemoveVoiced( ChatUser user, ChatUser moderator )
		{
			if ( !ValidateModerator( moderator ) || !ValidateAccess( moderator, user ) )
				return;

			if ( !IsModerator( user ) && IsVoiced( user ) )
			{
				m_Voices.Remove( user );

				if ( moderator != null )
					user.SendMessage( 53, moderator.Username ); // %1, a conference moderator, has removed your speaking priviledges for this conference.

				SendMessage( 51, user, user.Username ); // %1 no longer has speaking privileges in this conference.
				SendCommand( ChatCommand.AddUserToChannel, user, user.GetColorCharacter() + user.Username );
			}
		}
示例#28
0
		public void Kick( ChatUser user, ChatUser moderator, bool wasBanned )
		{
			if ( !ValidateModerator( moderator ) || !ValidateAccess( moderator, user ) )
				return;

			if ( Contains( user ) )
			{
				if ( moderator != null )
				{
					if ( wasBanned )
						user.SendMessage( 63, moderator.Username ); // %1, a conference moderator, has banned you from the conference.
					else
						user.SendMessage( 45, moderator.Username ); // %1, a conference moderator, has kicked you out of the conference.
				}

				RemoveUser( user );
				ChatSystem.SendCommandTo( user.Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );

				SendMessage( 44, user.Username ) ; // %1 has been kicked out of the conference.
			}

			if ( wasBanned && moderator != null )
				moderator.SendMessage( 62, user.Username ); // You are banning %1 from this conference.
		}
示例#29
0
		public static ChatUser SearchForUser( ChatUser from, string name )
		{
			ChatUser user = ChatUser.GetChatUser( name );

			if ( user == null )
				from.SendMessage( 32, name ); // There is no player named '%1'.

			return user;
		}
		public static void ToggleCharacterName( ChatUser from, Channel channel, string param )
		{
			from.Anonymous = !from.Anonymous;
			from.SendMessage( from.Anonymous ? 40 : 39 ); // See above for messages
		}
		public static void DisallowPrivateMessages( ChatUser from, Channel channel, string param )
		{
			from.IgnorePrivateMessage = true;
			from.SendMessage( 38 ); /* You will no longer receive private messages.
									 * Those who send you a message will be notified that you are blocking incoming messages.
									 */
		}
		public static void JoinChannel( ChatUser from, Channel channel, string param )
		{
			string name;
			string password = null;

			int start = param.IndexOf( '\"' );

			if ( start >= 0 )
			{
				int end = param.IndexOf( '\"', ++start );

				if ( end >= 0 )
				{
					name = param.Substring( start, end - start );
					password = param.Substring( ++end );
				}
				else
				{
					name = param.Substring( start );
				}
			}
			else
			{
				int indexOf = param.IndexOf( ' ' );

				if ( indexOf >= 0 )
				{
					name = param.Substring( 0, indexOf++ );
					password = param.Substring( indexOf );
				}
				else
				{
					name = param;
				}
			}

			if ( password != null )
				password = password.Trim();

			if ( password != null && password.Length == 0 )
				password = null;

			Channel joined = Channel.FindChannelByName( name );

			if ( joined == null )
				from.SendMessage( 33, name ); // There is no conference named '%1'.
			else
				joined.AddUser( from, password );
		}
		public static void QueryWhoIs( ChatUser from, Channel channel, string param )
		{
			ChatUser target = ChatSystem.SearchForUser( from, param );

			if ( target == null )
				return;

			if ( target.Anonymous )
				from.SendMessage( 41, target.Username ); // %1 is remaining anonymous.
			else
				from.SendMessage( 43, target.Username, target.Mobile.Name ); // %2 is known in the lands of Britannia as %2.
		}
		public static void TogglePrivateMessages( ChatUser from, Channel channel, string param )
		{
			from.IgnorePrivateMessage = !from.IgnorePrivateMessage;
			from.SendMessage( from.IgnorePrivateMessage ? 38 : 37 ); // See above for messages
		}
		public static void AllowPrivateMessages( ChatUser from, Channel channel, string param )
		{
			from.IgnorePrivateMessage = false;
			from.SendMessage( 37 ); // You can now receive private messages.
		}
示例#36
0
 public static void ChangeChannelPassword(ChatUser from, Channel channel, string param)
 {
     channel.Password = param;
     from.SendMessage(60);               // The password to the conference has been changed.
 }
示例#37
0
		public bool AddUser( ChatUser user, string password )
		{
			if ( Contains( user ) )
			{
				user.SendMessage( 46, m_Name ); // You are already in the conference '%1'.
				return true;
			}
			else if ( IsBanned( user ) )
			{
				user.SendMessage( 64 ); // You have been banned from this conference.
				return false;
			}
			else if ( !ValidatePassword( password ) )
			{
				user.SendMessage( 34 ); // That is not the correct password.
				return false;
			}
			else
			{
				if ( user.CurrentChannel != null )
					user.CurrentChannel.RemoveUser( user ); // Remove them from their current channel first

				ChatSystem.SendCommandTo( user.Mobile, ChatCommand.JoinedChannel, m_Name );

				SendCommand( ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );

				m_Users.Add( user );
				user.CurrentChannel = this;

				if ( user.Mobile.AccessLevel >= AccessLevel.GameMaster || (!m_AlwaysAvailable && m_Users.Count == 1) )
					AddModerator( user );

				SendUsersTo( user );

				return true;
			}
		}
示例#38
0
 public static void AllowPrivateMessages(ChatUser from, Channel channel, string param)
 {
     from.IgnorePrivateMessage = false;
     from.SendMessage(37);               // You can now receive private messages.
 }
示例#39
0
		public void AddVoiced( ChatUser user, ChatUser moderator )
		{
			if ( !ValidateModerator( moderator ) )
				return;

			if ( !IsBanned( user ) && !IsModerator( user ) && !IsVoiced( user ) )
			{
				m_Voices.Add( user );

				if ( moderator != null )
					user.SendMessage( 54, moderator.Username ); // %1, a conference moderator, has granted you speaking priviledges in this conference.

				SendMessage( 52, user, user.Username ); // %1 now has speaking privileges in this conference.
				SendCommand( ChatCommand.AddUserToChannel, user, user.GetColorCharacter() + user.Username );
			}
		}
示例#40
0
 public static void TogglePrivateMessages(ChatUser from, Channel channel, string param)
 {
     from.IgnorePrivateMessage = !from.IgnorePrivateMessage;
     from.SendMessage(from.IgnorePrivateMessage ? 38 : 37);               // See above for messages
 }
示例#41
0
		public void AddModerator( ChatUser user, ChatUser moderator )
		{
			if ( !ValidateModerator( moderator ) )
				return;

			if ( IsBanned( user ) || IsModerator( user ) )
				return;

			if ( IsVoiced( user ) )
				m_Voices.Remove( user );

			m_Moderators.Add( user );

			if ( moderator != null )
				user.SendMessage( 50, moderator.Username ); // %1 has made you a conference moderator.

			SendMessage( 48, user, user.Username ); // %1 is now a conference moderator.
			SendCommand( ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
		}
示例#42
0
 public static void ShowCharacterName(ChatUser from, Channel channel, string param)
 {
     from.Anonymous = false;
     from.SendMessage(39);               // You are now showing your character name to any players who inquire with the whois command.
 }
示例#43
0
		public bool ValidateModerator( ChatUser user )
		{
			if ( user != null && !IsModerator( user ) )
			{
				user.SendMessage( 29 ); // You must have operator status to do this.
				return false;
			}

			return true;
		}
		public static void ShowCharacterName( ChatUser from, Channel channel, string param )
		{
			from.Anonymous = false;
			from.SendMessage( 39 ); // You are now showing your character name to any players who inquire with the whois command.
		}