Beispiel #1
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.
		}
        public static void AddVoice( ChatUser from, Channel channel, string param )
        {
            ChatUser target = ChatSystem.SearchForUser( from, param );

            if ( target != null )
                channel.AddVoiced( target, from );
        }
        public static void AddIgnore( ChatUser from, Channel channel, string param )
        {
            ChatUser target = ChatSystem.SearchForUser( from, param );

            if ( target == null )
                return;

            from.AddIgnored( target );
        }
		public static ChatUser AddChatUser( Mobile from )
		{
			ChatUser user = GetChatUser( from );

			if ( user == null )
			{
				user = new ChatUser( from );

				m_Users.Add( user );
				m_Table[from] = user;

				Channel.SendChannelsTo( user );
			}

			return user;
		}
		public static void RemoveChatUser( ChatUser user )
		{
			if ( user == null )
				return;

			if ( m_Users.Contains( user ) )
			{
				ChatSystem.SendCommandTo( user.Mobile, ChatCommand.CloseChatWindow );

				if ( user.m_Channel != null )
					user.m_Channel.RemoveUser( user );

				m_Users.Remove( user );
				m_Table.Remove( user.m_Mobile );
			}
		}
		public void RemoveUser( ChatUser user )
		{
			if ( Contains( user ) )
			{
				m_Users.Remove( user );
				user.CurrentChannel = null;

				SendCommand( ChatCommand.RemoveUserFromChannel, user, user.Username );
				ChatSystem.SendCommandTo( user.Mobile, ChatCommand.LeaveChannel, String.Format( "{{{0}}}", m_Name ) );
				ChatSystem.SendCommandTo( user.Mobile, ChatCommand.LeftChannel, m_Name );

				ChatLogging.LogLeave( this.Name, user.Username );

				if ( m_Users.Count == 0 && !m_AlwaysAvailable )
					RemoveChannel( this );
			}
		}
Beispiel #7
0
		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 ) )
				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 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;
				}
			}

			CreateAndJoin( from, name );
		}
		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 );
			}
		}
 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.
 }
		public bool CanTalk( ChatUser user )
		{
			return ( !m_VoiceRestricted || m_Voices.Contains( user ) || m_Moderators.Contains( user ) );
		}
		public bool Contains( ChatUser user )
		{
			return m_Users.Contains( user );
		}
		public void SendUsersTo( ChatUser to )
		{
			for ( int i = 0; i < m_Users.Count; ++i )
			{
				ChatUser user = (ChatUser)m_Users[i];

				ChatSystem.SendCommandTo( to.Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
			}
		}
		public void SendCommand( ChatCommand command, ChatUser initiator )
		{
			SendCommand( command, initiator, null, null );
		}
		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;
			}
		}
 public static void ChangeChannelPassword(ChatUser from, Channel channel, string param)
 {
     channel.Password = param;
     from.SendMessage(60);               // The password to the conference has been changed.
 }
 public static void DisableDefaultVoice(ChatUser from, Channel channel, string param)
 {
     channel.VoiceRestricted = true;
 }
 public static void ToggleDefaultVoice(ChatUser from, Channel channel, string param)
 {
     channel.VoiceRestricted = !channel.VoiceRestricted;
 }
 public static void RenameChannel(ChatUser from, Channel channel, string param)
 {
     channel.Name = param;
 }
 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 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.
 }
Beispiel #22
0
 public static void GlobalSendCommand( ChatCommand command, ChatUser initiator, string param1 )
 {
     GlobalSendCommand( command, initiator, param1, null );
 }
 public static void AllowPrivateMessages(ChatUser from, Channel channel, string param)
 {
     from.IgnorePrivateMessage = false;
     from.SendMessage(37);               // You can now receive private messages.
 }
Beispiel #24
0
        public static void RemoveChatUser( ChatUser user )
        {
            if ( user == null )
                return;

            for ( int i = 0; i < user.m_Ignoring.Count; ++i )
                ((ChatUser)user.m_Ignoring[i]).RemoveIgnored( user );

            if ( m_Users.Contains( user ) )
            {
                ChatSystem.SendCommandTo( user.Mobile, ChatCommand.CloseChatWindow );

                if ( user.m_Channel != null )
                    user.m_Channel.RemoveUser( user );

                m_Users.Remove( user );
                m_Table.Remove( user.m_Mobile );
            }
        }
 public bool IsIgnored(ChatUser check)
 {
     return(m_Ignored.Contains(check));
 }
		public void SendMessage( int number, ChatUser initiator, string param1 )
		{
			SendMessage( number, initiator, param1, null );
		}
 public static void GlobalSendCommand(ChatCommand command, ChatUser initiator)
 {
     GlobalSendCommand(command, initiator, null, null);
 }
		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 static void GlobalSendCommand(ChatCommand command, ChatUser initiator, string param1)
 {
     GlobalSendCommand(command, initiator, param1, null);
 }
		public void SendCommand( ChatCommand command, ChatUser initiator, string param1 )
		{
			SendCommand( command, initiator, param1, null );
		}
Beispiel #31
0
        public static void RemoveChatUser(Mobile from)
        {
            ChatUser user = GetChatUser(from);

            RemoveChatUser(user);
        }
		public static void SendChannelsTo( ChatUser user )
		{
			for ( int i = 0; i < m_Channels.Count; ++i )
			{
				Channel channel = (Channel)m_Channels[i];

				if ( !channel.IsBanned( user ) )
					ChatSystem.SendCommandTo( user.Mobile, ChatCommand.AddChannel, channel.Name, "0" );
			}
		}
		public bool IsVoiced( ChatUser user )
		{
			return m_Voices.Contains( user );
		}
		public bool IsBanned( ChatUser user )
		{
			return m_Banned.Contains( user );
		}
Beispiel #35
0
        public static ChatUser AddChatUser( Mobile from )
        {
            ChatUser user = GetChatUser( from );

            if ( user == null )
            {
                user = new ChatUser( from );

                m_Users.Add( user );
                m_Table[from] = user;

                Channel.SendChannelsTo( user );

                ArrayList list = Channel.Channels;

                for ( int i = 0; i < list.Count; ++i )
                {
                    Channel c = (Channel)list[i];

                    if ( c.AddUser( user ) )
                        break;
                }

                //ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
            }

            return user;
        }
		public bool IsModerator( ChatUser user )
		{
			return m_Moderators.Contains( user );
		}
 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 bool ValidateModerator( ChatUser user )
		{
			if ( user != null && !IsModerator( user ) )
			{
				user.SendMessage( 29 ); // You must have operator status to do this.
				return false;
			}

			return true;
		}
Beispiel #39
0
 public bool IsIgnored( ChatUser check )
 {
     return m_Ignored.Contains( check );
 }
Beispiel #40
0
 public static void GlobalSendCommand( ChatCommand command, ChatUser initiator )
 {
     GlobalSendCommand( command, initiator, null, null );
 }
Beispiel #41
0
 public bool Contains(ChatUser user)
 {
     return(m_Users.Contains(user));
 }
Beispiel #42
0
        public static void GlobalSendCommand( ChatCommand command, 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() )
                    ChatSystem.SendCommandTo( user.m_Mobile, command, param1, param2 );
                else if ( !m_Users.Contains( i ) )
                    --i;
            }
        }
Beispiel #43
0
        public static void OpenChatWindowRequest(NetState state, PacketReader pvSrc)
        {
            Mobile from = state.Mobile;

            if (!m_Enabled)
            {
                from.SendMessage("The chat system has been disabled.");
                return;
            }

            pvSrc.Seek(2, System.IO.SeekOrigin.Begin);
            string chatName = pvSrc.ReadUnicodeStringSafe((0x40 - 2) >> 1).Trim();

            Account acct = state.Account as Account;

            string accountChatName = null;

            if (acct != null)
            {
                accountChatName = acct.GetTag("ChatName");
            }

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

            if (accountChatName != null && accountChatName.Length > 0)
            {
                if (chatName.Length > 0 && chatName != accountChatName)
                {
                    from.SendMessage("You cannot change chat nickname once it has been set.");
                }
            }
            else
            {
                if (chatName == null || chatName.Length == 0)
                {
                    SendCommandTo(from, ChatCommand.AskNewNickname);
                    return;
                }

                if (NameVerification.Validate(chatName, 2, 31, true, true, true, 0, NameVerification.SpaceDashPeriodQuote) && chatName.ToLower().IndexOf("system") == -1)
                {
                    // TODO: Optimize this search

                    foreach (Account checkAccount in Accounts.GetAccounts())
                    {
                        string existingName = checkAccount.GetTag("ChatName");

                        if (existingName != null)
                        {
                            existingName = existingName.Trim();

                            if (Insensitive.Equals(existingName, chatName))
                            {
                                from.SendMessage("Nickname already in use.");
                                SendCommandTo(from, ChatCommand.AskNewNickname);
                                return;
                            }
                        }
                    }

                    accountChatName = chatName;

                    if (acct != null)
                    {
                        acct.AddTag("ChatName", chatName);
                    }
                }
                else
                {
                    from.SendLocalizedMessage(501173);                       // That name is disallowed.
                    SendCommandTo(from, ChatCommand.AskNewNickname);
                    return;
                }
            }

            SendCommandTo(from, ChatCommand.OpenChatWindow, accountChatName);
            ChatUser.AddChatUser(from);
        }
Beispiel #44
0
        public void AddIgnored( ChatUser user )
        {
            if ( IsIgnored( user ) )
            {
                SendAsciiMessage( 22, user.Username ); // You are already ignoring %1.
            }
            else
            {
                m_Ignored.Add( user );
                user.m_Ignoring.Add( this );

                SendAsciiMessage( 23, user.Username ); // You are now ignoring %1.
            }
        }
 public static void LeaveChat(ChatUser from, Channel channel, string param)
 {
     ChatUser.RemoveChatUser(from);
 }
Beispiel #46
0
        public void RemoveIgnored( ChatUser user )
        {
            if ( IsIgnored( user ) )
            {
                m_Ignored.Remove( user );
                user.m_Ignoring.Remove( this );

                SendAsciiMessage( 24, user.Username ); // You are no longer ignoring %1.

                if ( m_Ignored.Count == 0 )
                    SendAsciiMessage( 26 ); // You are no longer ignoring anyone.
            }
            else
            {
                SendAsciiMessage( 25, user.Username ); // You are not ignoring %1.
            }
        }
Beispiel #47
0
 private static void EventSink_Disconnected(DisconnectedEventArgs e)
 {
     ChatUser.RemoveChatUser(e.Mobile);
 }