Esempio n. 1
0
        private static void SendPongReply(StreamWriter writer, ChatReply reply)
        {
            string pongReply = reply.Command;

            writer.WriteLine("PONG " + pongReply);
            writer.Flush();
        }
Esempio n. 2
0
        private void BuildChannelMessage()
        {
            if (!_channel.Property.ChannelMode.IsModeratedChannel)
            {
                return;
            }

            if (_channel.IsUserBanned(_user))
            {
                return;
            }

            if (!_user.IsVoiceable)
            {
                return;
            }
            if (_user.UserInfo.IsQuietMode)
            {
                return;
            }

            _sendingBuffer =
                ChatReply.BuildPrivMsgReply(_user.UserInfo,
                                            _cmd.ChannelName, _cmd.Message);
        }
Esempio n. 3
0
        private void BuildBCASTReply()
        {
            //we only broadcast the b_flags
            string flags = "";

            if (_cmd.KeyValues.ContainsKey("b_flags"))
            {
                flags += @"\" + "b_flags" + @"\" + _cmd.KeyValues["b_flags"];
            }

            //todo check the paramemter
            if (IsSetOthersKeyValue)
            {
                _sendingBuffer =
                    ChatReply.BuildGetCKeyReply(
                        _otherUser.UserInfo.NickName,
                        _channel.Property.ChannelName,
                        "BCAST", flags);
            }
            else
            {
                _sendingBuffer =
                    ChatReply.BuildGetCKeyReply(
                        _user.UserInfo.NickName,
                        _channel.Property.ChannelName,
                        "BCAST", flags);
            }
        }
Esempio n. 4
0
 private void BuildGetCKeyEndMessage()
 {
     _sendingBuffer +=
         ChatReply.BuildEndOfGetCKeyReply(
             _channel.Property.ChannelName,
             _cmd.Cookie);
 }
Esempio n. 5
0
 public ChatReplyWindow(ChatReply options = null)
 {
     this.InitializeComponent();
     if (options != null)
     {
         AddOptions(options);
     }
 }
Esempio n. 6
0
 public override void DataOperation()
 {
     base.DataOperation();
     _sendingBuffer =
         ChatReply.BuildKickReply(
             _channel.Property.ChannelName,
             _user, _kickee, _cmd.Reason);
 }
 public override void ConstructResponse()
 {
     base.ConstructResponse();
     _sendingBuffer =
         ChatReply.BuildGetChanKeyReply(
             _user, _channel.Property.ChannelName,
             _cmd.Cookie, _values);
 }
        public void MultiCastLeave(ChatChannelUser leaver, string message)
        {
            string leaveMessage =
                ChatReply.BuildPartReply(
                    leaver, Property.ChannelName, message);

            MultiCast(leaveMessage);
        }
Esempio n. 9
0
        public override void ConstructResponse()
        {
            base.ConstructResponse();

            string ip = ((IPEndPoint)_session.Socket.RemoteEndPoint).Address.ToString();

            _sendingBuffer = ChatReply.BuildUserIPReply(ip);
        }
Esempio n. 10
0
 private void SetChannelTopic()
 {
     _channel.Property.SetChannelTopic(_cmd.ChannelTopic);
     _sendingBuffer =
         ChatReply.BuildTopicReply(
             _channel.Property.ChannelName,
             _channel.Property.ChannelTopic);
 }
Esempio n. 11
0
        private void GetUserBFlagsOnly(ChatChannelUser user)
        {
            string flags = user.GetBFlagsString();

            _sendingBuffer += ChatReply.BuildGetCKeyReply(
                user.UserInfo.NickName, _channel.Property.ChannelName,
                _cmd.Cookie, flags);
        }
Esempio n. 12
0
 public void AddOptions(ChatReply options)
 {
     if (CR == null)
     {
         nameBox.Text      = options.Name;
         matchesBox.Text   = string.Join(",", options.Matches);
         responsesBox.Text = string.Join(",", options.Matches);
     }
 }
Esempio n. 13
0
        public void GetChannelModes()
        {
            string modes =
                _channel.Property.ChannelMode.GetChannelMode();

            _sendingBuffer =
                ChatReply.BuildModeReply(
                    _channel.Property.ChannelName, modes);
        }
Esempio n. 14
0
        public void SendChannelModesToJoiner(ChatChannelUser joiner)
        {
            string modes = Property.ChannelMode.GetChannelMode();

            string modesMessage =
                ChatReply.BuildChannelModesReply(
                    joiner, Property.ChannelName, modes);

            joiner.Session.SendAsync(modesMessage);
        }
Esempio n. 15
0
        private void GetAllKeyValues(ChatChannelUser user)
        {
            string flags = user.GetUserValuesString(_cmd.Keys);

            //todo check the paramemter
            _sendingBuffer +=
                ChatReply.BuildGetCKeyReply(
                    user.UserInfo.NickName,
                    _channel.Property.ChannelName,
                    _cmd.Cookie, flags);
        }
Esempio n. 16
0
        public override void DataOperation()
        {
            base.DataOperation();

            _sendingBuffer =
                ChatReply.BuildWhoIsUserReply(_userInfo);

            BuildJoinedChannelReply();

            _sendingBuffer +=
                ChatReply.BuildEndOfWhoIsReply(_userInfo);
        }
Esempio n. 17
0
        public override void ConstructResponse()
        {
            base.ConstructResponse();

            // 2. Prepare two keys
            ChatCrypt.Init(_session.UserInfo.ClientCTX, ChatServer.ClientKey, _session.UserInfo.GameSecretKey);
            ChatCrypt.Init(_session.UserInfo.ServerCTX, ChatServer.ServerKey, _session.UserInfo.GameSecretKey);

            // 3. Response the crypt command
            _sendingBuffer =
                ChatReply.
                BuildCryptReply(ChatServer.ClientKey, ChatServer.ServerKey);
        }
        public override void ConstructResponse()
        {
            base.ConstructResponse();
            string flags = "";

            foreach (var kv in _cmd.KeyValue)
            {
                flags += $@"\{kv.Key}\{kv.Value}";
            }
            _sendingBuffer =
                ChatReply.BuildGetChanKeyReply(
                    _user, _channel.Property.ChannelName, "BCAST", flags);
        }
Esempio n. 19
0
        public override void ConstructResponse()
        {
            base.ConstructResponse();

            _sendingBuffer =
                ChatReply.BuildWelcomeReply(_session.UserInfo);

            _session.UserInfo.SetLoginFlag(true);


            //check this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //_sendingBuffer += ChatCommandBase.BuildMessageRPL(
            //_nickCmd.NickName, $"MODE {_nickCmd.NickName}", "+iwx");
        }
        private static string GetReplyTo(ChatReply reply, string botNick)
        {
            string replyTo;

            if (reply.Param == botNick)
            {
                replyTo = reply.User.Substring(1).Split("!")[0];
            }
            else
            {
                replyTo = reply.Param;
            }
            return(replyTo);
        }
Esempio n. 21
0
 private void BuildWhoReplyForUser(ChatSession session)
 {
     _sendingBuffer = "";
     foreach (var channel in session.UserInfo.JoinedChannels)
     {
         ChatChannelUser user;
         channel.GetChannelUserBySession(session, out user);
         _sendingBuffer +=
             ChatReply.BuildWhoReply(
                 channel.Property.ChannelName,
                 session.UserInfo,
                 user.GetUserModes());
     }
 }
Esempio n. 22
0
        private void BuildJoinedChannelReply()
        {
            if (_userInfo.JoinedChannels.Count() != 0)
            {
                string channelNames = "";
                //todo remove last space
                foreach (var channel in _userInfo.JoinedChannels)
                {
                    channelNames += $"@{channel.Property.ChannelName} ";
                }

                _sendingBuffer +=
                    ChatReply.BuildWhoIsChannelReply(_userInfo, channelNames);
            }
        }
Esempio n. 23
0
        public void MultiCastJoin(ChatChannelUser joiner)
        {
            string joinMessage =
                ChatReply.BuildJoinReply(
                    joiner, Property.ChannelName);

            string modes =
                Property.ChannelMode.GetChannelMode();

            joinMessage +=
                ChatReply.BuildModeReply(
                    Property.ChannelName, modes);

            MultiCast(joinMessage);
        }
Esempio n. 24
0
 public override void DataOperation()
 {
     base.DataOperation();
     _sendingBuffer = "";
     foreach (var channel in _session.UserInfo.JoinedChannels)
     {
         ChatChannelUser user;
         if (channel.GetChannelUserBySession(_session, out user))
         {
             string valueStr = user.GetUserValuesString(_cmd.Keys);
             _sendingBuffer += ChatReply.BuildGetKeyReply(_session.UserInfo, _cmd.Cookie, valueStr);
         }
     }
     _sendingBuffer += ChatReply.BuildEndOfGetKeyReply(_session.UserInfo, _cmd.Cookie);
 }
Esempio n. 25
0
        public override void DataOperation()
        {
            base.DataOperation();
            switch (_cmd.RequestType)
            {
            case ChatMessageType.ChannelMessage:
                _sendingBuffer = ChatReply.BuildNoticeReply(
                    _user.UserInfo, _cmd.ChannelName, _cmd.Message);
                break;

            case ChatMessageType.UserMessage:
                _sendingBuffer = ChatReply.BuildNoticeReply(
                    _session.UserInfo, _cmd.NickName, _cmd.Message);
                break;
            }
        }
Esempio n. 26
0
 private void GetChannelTopic()
 {
     if (_channel.Property.ChannelTopic == "" || _channel.Property.ChannelTopic == null)
     {
         _sendingBuffer =
             ChatReply.BuildNoTopicReply(
                 _channel.Property.ChannelName);
     }
     else
     {
         _sendingBuffer =
             ChatReply.BuildTopicReply(
                 _channel.Property.ChannelName,
                 _channel.Property.ChannelTopic);
     }
 }
Esempio n. 27
0
 private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
 {
     if (nameBox.Text == "" || matchesBox.Text == "" || responsesBox.Text == "")
     {
         MessageDialog dialog = new MessageDialog("You must include a name, matches, and responses. Matches and responses must be separated with commas.", "Error");
         await dialog.ShowAsync();
     }
     else
     {
         CR = new ChatReply()
         {
             Name      = nameBox.Text,
             Matches   = matchesBox.Text.Split(',').ToList(),
             Responses = responsesBox.Text.Split(',').ToList()
         };
     }
 }
Esempio n. 28
0
        private void KickAllUserAndShutDownChannel(ChatChannelUser kicker)
        {
            foreach (var user in Property.ChannelUsers)
            {
                //kick all user out
                string kickMsg =
                    ChatReply.BuildKickReply(
                        Property.ChannelName, kicker, user, "Server Hoster leaves channel");

                user.Session.SendAsync(kickMsg);
            }

            ChatChannelManager.RemoveChannel(this);

            GameServer.DeleteSimilarServer(
                kicker.Session.RemoteEndPoint,
                kicker.Session.UserInfo.GameName);
        }
Esempio n. 29
0
        private void GetChannelUsersInfo()
        {
            ChatChannelBase channel;

            if (!ChatChannelManager.GetChannel(_cmd.Name, out channel))
            {
                _errorCode = ChatError.IRCError;
                return;
            }
            _sendingBuffer = "";

            foreach (var user in channel.Property.ChannelUsers)
            {
                _sendingBuffer +=
                    ChatReply.BuildWhoReply(
                        channel.Property.ChannelName,
                        user.UserInfo, user.GetUserModes());
            }
        }
 private async Task LogUserAsync(StreamWriter writer, ChatReply reply, string replyTo, IServiceProvider services)
 {
     if (reply.Message.Contains(".seen"))
     {
         return;
     }
     try
     {
         string   username = reply.User.Substring(1).Split("!")[0];
         string[] input    = { username, reply.Message, DateTime.Now.ToString() };
         SeenUser seenUser = SeenUser.CreateSeen(input, replyTo);
         using var scope = services.CreateScope();
         SeenUserRepository repository = scope.ServiceProvider.GetRequiredService <SeenUserRepository>();
         await repository.UpsertSeenUser(seenUser);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            if(matchesBox.Text == "" || responsesBox.Text == "" || nameBox.Text == "")
            {
                MessageBox.Show("You must include matches, responses, and a name.", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
            else
            {
                CR = new ChatReply
                {
                    Name = "",
                    Matches = new List<string>(),
                    Responses = new List<string>(),
                    TriggerLists = new TriggerLists(),
                    TriggerNumbers = new TriggerNumbers()
                };

                CR.Name = nameBox.Text;
                CR.Matches = matchesBox.Text.Split(',').ToList();
                CR.Responses = responsesBox.Text.Split(',').ToList();

                List<SteamID> ignores = new List<SteamID>();
                List<SteamID> rooms = new List<SteamID>();
                List<SteamID> users = new List<SteamID>();
                if (delayBox.Text == "") CR.TriggerNumbers.Delay = null;
                else CR.TriggerNumbers.Delay = Convert.ToInt32(delayBox.Text);

                if (probBox.Text == "") CR.TriggerNumbers.Probability = null;
                else CR.TriggerNumbers.Probability = (float)Convert.ToDouble(probBox.Text);

                if (timeoutBox.Text == "") CR.TriggerNumbers.Timeout = null;
                else CR.TriggerNumbers.Timeout = Convert.ToInt32(timeoutBox.Text);

                if (ignoresBox.Text.Split(',').Length > 0 && ignoresBox.Text != "")
                {
                    foreach (string ignore in ignoresBox.Text.Split(','))
                    {
                        ignores.Add(new SteamID(Convert.ToUInt64(ignore)));
                    }
                }
                if (roomsBox.Text.Split(',').Length > 0 && roomsBox.Text != "")
                {
                    foreach (string room in roomsBox.Text.Split(','))
                    {
                        rooms.Add(new SteamID(Convert.ToUInt64(room)));
                    }
                }
                if (usersBox.Text.Split(',').Length > 0 && usersBox.Text != "")
                {
                    foreach (string user in usersBox.Text.Split(','))
                    {
                        users.Add(new SteamID(Convert.ToUInt64(user)));
                    }
                }

                CR.TriggerLists.Ignore = ignores;
                CR.TriggerLists.Rooms = rooms;
                CR.TriggerLists.User = users;
                DialogResult = true;
                Close();
            }
        }