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);
            }
        }
예제 #2
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);
            }
        }
예제 #3
0
        private static void CreateAndJoin(ChatUser from, string name)
        {
            Channel joined = Channel.FindChannelByName(name);

            if (joined == null)
            {
                if (ChatSystem.AllowCreateChannels)
                {
                    from.Mobile.SendMessage("You have created the channel {0}", name);
                    joined = Channel.AddChannel(name);
                }
                else
                {
                    from.Mobile.SendMessage("Channel creation is not allowed right now. Switching to default channel...");
                    joined = Channel.Default;
                }
            }

            joined.AddUser(from);
        }