Beispiel #1
0
 public async Task CheckOnJoin(ClientJoinedEventArgs client)
 {
     try
     {
         var restrictedwords = _config.BannedWords;
         var regexMatch      = string.Join <string>("|", restrictedwords);
         var regex           = new Regex($"({regexMatch})", RegexOptions.IgnoreCase);
         var clientinfo      = new ClientInfoCommand(client.ClientId).ExecuteAsync(Interface.XfQueryBot.QueryClient)
                               .Result;
         if (!regex.IsMatch(client.Nickname) || !client.ClientType.Equals(0))
         {
             return;
         }
         if (_config.PokeOrKick.Equals("Kick", StringComparison.OrdinalIgnoreCase))
         {
             await new ClientKickCommand(client.ClientId, KickReason.Server,
                                         _config.Reason[CheckClientLang(clientinfo)].Replace("[NICKNAME]", client.Nickname))
             .ExecuteAsync(Interface.XfQueryBot.QueryClient);
         }
         else
         {
             await new ClientPokeCommand(client.ClientId,
                                         _config.Reason[CheckClientLang(clientinfo)].Replace("[NICKNAME]", client.Nickname))
             .ExecuteAsync(Interface.XfQueryBot.QueryClient);
         }
     }
     catch (Exception ex)
     {
         _log.Error($"({_extension.Name}) : {ex}");
     }
 }
Beispiel #2
0
 /// <summary>
 /// Determines whether this instance can invoke the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
 /// <returns>
 ///   <c>true</c> if this instance can invoke the specified e; otherwise, <c>false</c>.
 /// </returns>
 public override bool CanInvoke(ClientJoinedEventArgs e)
 {
     return(CanInvoke(new ISettings[]
     {
         Repository.Settings.Record
     }));
 }
Beispiel #3
0
        internal void OnJoined()
        {
            LoggedIn = true;
            string DisplayMessage = DisplayName + " has logged in";
            //Event
            ClientJoinedEventArgs e = new ClientJoinedEventArgs(Client);

            Server.PluginManager.CallEvent(Event.PlayerJoined, e);
            //We kick the player because it would not work to use return.
            if (e.EventCanceled)
            {
                _client.Kick("");
                return; //return here so we do not display message
            }
            DisplayMessage = e.BrodcastMessage;
            //End Event
            Server.Broadcast(DisplayMessage);

            if (!string.IsNullOrEmpty(ChraftConfig.ServerTextureUrl))
            {
                string message = ChraftConfig.ServerTextureUrl + '\0' + 16;
                _client.SendPacket(new PluginMessagePacket
                {
                    Channel = "MC|TPack",
                    Message = Encoding.UTF8.GetBytes(message),
                });
            }
        }
 private static async void ClientJoinToServer(object sender, ClientJoinedEventArgs e)
 {
     if (_service != null)
     {
         await _service.WelcomeMessage(e);
     }
 }
 private static async void OnJoin(object sender, ClientJoinedEventArgs e)
 {
     if (_service != null)
     {
         await _service.CheckOnJoin(e);
     }
 }
Beispiel #6
0
 private void ModuleManager_ClientJoined(object sender, ClientJoinedEventArgs eventArgs)
 {
     //PokeDPlayerSendToAllClients(new CreatePlayerPacket { PlayerID = client.ID }, -1);
     //PokeDPlayerSendToAllClients(client.GetDataPacket(), client.ID);
     SendPacketToAll(new ChatGlobalMessagePacket {
         Message = $"Player {eventArgs.Client.Name} joined the game!"
     });
 }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleClientEntity"/> class.
 /// </summary>
 /// <param name="client">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
 public SimpleClientEntity(ClientJoinedEventArgs client)
 {
     this.ClientDatabaseId = client.ClientDatabaseId;
     this.ClientId         = client.ClientId;
     this.Nickname         = client.Nickname;
     this.ServerGroups     = new List <uint>(client.ServerGroups);
     this.ChannelId        = client.ChannelId;
     this.Connected        = DateTime.UtcNow;
 }
Beispiel #8
0
        public async Task WelcomeMessage(ClientJoinedEventArgs e)
        {
            try
            {
                var clientInfo =
                    await new ClientInfoCommand(e.ClientId).ExecuteAsync(Interface.XfQueryBot.QueryClient);
                if (clientInfo.TotalConnections <= 1)
                {
                    _config.FirstConnectionMessage[clientInfo.ClientCountry.ToLower()].ForEach(msg =>
                                                                                               new SendTextMessageCommand(MessageTarget.Client, e.ClientId, MessageBuilder(msg, clientInfo))
                                                                                               .ExecuteAsync(Interface.XfQueryBot.QueryClient));
                }
                else
                {
                    _config.ConnectionMessage[clientInfo.ClientCountry.ToLower()].ForEach(msg =>
                                                                                          new SendTextMessageCommand(MessageTarget.Client, e.ClientId, MessageBuilder(msg, clientInfo))
                                                                                          .ExecuteAsync(Interface.XfQueryBot.QueryClient));
                }
            }
            catch (KeyNotFoundException)
            {
                var clientInfo = await new ClientInfoCommand(e.ClientId).ExecuteAsync(Interface.XfQueryBot.QueryClient);
                if (clientInfo.TotalConnections <= 1)
                {
                    _config.FirstConnectionMessage[_config.DefaultLang].ForEach(msg =>
                                                                                new SendTextMessageCommand(MessageTarget.Client, e.ClientId, MessageBuilder(msg, clientInfo))
                                                                                .ExecuteAsync(Interface.XfQueryBot.QueryClient));
                }
                else
                {
                    _config.ConnectionMessage[_config.DefaultLang].ForEach(msg =>
                                                                           new SendTextMessageCommand(MessageTarget.Client, e.ClientId, MessageBuilder(msg, clientInfo))
                                                                           .ExecuteAsync(Interface.XfQueryBot.QueryClient));
                }
            }
            catch (Exception ex)
            {
                _log.Error($"({_addon.Name}) : {ex}");
            }

            string MessageBuilder(string msg, ClientInfoCommandResponse clientInfo)
            {
                var replaced = msg.Replace("[Nickname]", clientInfo.Nickname)
                               .Replace("[DatabaseId]", clientInfo.DatabaseId.ToString())
                               .Replace("[TotalConnectionCount]", clientInfo.TotalConnections.ToString())
                               .Replace("[LastConnected]", clientInfo.LastConnected.ToString(CultureInfo.InvariantCulture))
                               .Replace("[Created]", clientInfo.Created.ToString(CultureInfo.InvariantCulture))
                               .Replace("[Platform]", clientInfo.Platform)
                               .Replace("[ConnectionIp]", clientInfo.ClientIP)
                               .Replace("[Version]", clientInfo.Version)
                               .Replace("[UniqueIdentifier]", clientInfo.UniqueId);

                return(replaced);
            }
        }
Beispiel #9
0
 /// <summary>
 /// Handles the ClientJoined event of the Teamspeak Server.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
 public void Notifications_ClientJoined(object sender, ClientJoinedEventArgs e)
 {
     try
     {
         ManagerFactory.Invoke(e);
     }
     catch (Exception ex)
     {
         LogService.Error(ex.ToString());
     }
 }
Beispiel #10
0
 private void OnPlayerJoined(ClientJoinedEventArgs e)
 {
     foreach (EventListener bl in Plugins)
     {
         IPlayerListener pl = (IPlayerListener)bl.Listener;
         if (bl.Event == Event.PlayerJoined)
         {
             pl.OnPlayerJoined(e);
         }
     }
 }
Beispiel #11
0
        /// <summary>
        /// Clears the away clients.
        /// </summary>
        /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
        protected void ClearAwayClients(ClientJoinedEventArgs e)
        {
            if (!Repository.Settings.Away.Enabled)
            {
                return;
            }

            if (!e.IsClientAway && !e.IsClientInputMuted && !e.IsClientOutputMuted)
            {
                Repository.Client.RemoveLastChannelByClientId(e.ClientId);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Stickies the channel.
        /// </summary>
        /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
        protected void StickyChannel(ClientJoinedEventArgs e)
        {
            if (!Repository.Settings.Sticky.Enabled ||
                !PermissionHelper.IsGranted(Repository.Settings.Sticky, e.ServerGroups))
            {
                return;
            }

            var sticky = Repository.Channel.GetClientSticky(e.ClientDatabaseId);

            if (sticky != null && sticky.Value != e.ChannelId)
            {
                MoveClientToSticky(e.ClientId, sticky.Value);
            }
        }
Beispiel #13
0
        internal void OnJoined()
        {
            LoggedIn = true;
            string DisplayMessage = DisplayName + " has logged in";
            //Event
            ClientJoinedEventArgs e = new ClientJoinedEventArgs(Client);

            Server.PluginManager.CallEvent(Event.PlayerJoined, e);
            //We kick the player because it would not work to use return.
            if (e.EventCanceled)
            {
                _client.Kick("");
                return; //return here so we do not display message
            }
            DisplayMessage = e.BrodcastMessage;
            //End Event
            Server.Broadcast(DisplayMessage);
        }
Beispiel #14
0
        /// <summary>
        /// Kicks the recording clients.
        /// </summary>
        /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
        protected void KickRecordingClients(ClientJoinedEventArgs e)
        {
            if (!Repository.Settings.Record.Enabled)
            {
                return;
            }

            if (e.ClientType == 0 && e.IsRecording)
            {
                var client = new SimpleClientEntity(e);
                if (!PermissionHelper.IsGranted(Repository.Settings.Record, e.ServerGroups))
                {
                    return;
                }

                PunishClientForRecord(client);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Kicks the clients with bad nickname.
        /// </summary>
        /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
        protected void KickClientsWithBadNickname(ClientJoinedEventArgs e)
        {
            if (!Repository.Settings.BadNickname.Enabled)
            {
                return;
            }

            if (IsBadNickname(e.Nickname))
            {
                var client = new SimpleClientEntity(e);
                if (!PermissionHelper.IsGranted(Repository.Settings.BadNickname, client.ServerGroups))
                {
                    return;
                }

                KickClientForBadNickname(client);
            }
        }
Beispiel #16
0
        private void ModuleManager_ClientJoined(object sender, ClientJoinedEventArgs eventArgs)
        {
            var player = eventArgs.Client as P3DPlayer;

            lock (JoiningClients)
                JoiningClients.Remove(player);

            lock (Clients)
                Clients.Add(player);


            SendPacketToAll(new CreatePlayerPacket {
                Origin = Origin.Server, PlayerID = eventArgs.Client.ID
            });
            SendPacketToAll(eventArgs.Client.GetDataPacket());
            SendPacketToAll(new ChatMessageGlobalPacket {
                Origin = Origin.Server, Message = $"Player {eventArgs.Client.Name} joined the game!"
            });
        }
Beispiel #17
0
        private static void ClientJoined(ClientJoinedEventArgs e)
        {
            if (DoubleEvent(e.ClientId))
            {
                return;
            }

            lock (ClientLock(e.ClientId))
            {
                if (!clients.ContainsKey(e.ClientId))
                {
                    clients.Add(e.ClientId, mapper.Map <ClientJoinedEventArgs, Client>(e));
                }
                else
                {
                    clients[e.ClientId] = mapper.Map <ClientJoinedEventArgs, Client>(e);
                }
            }
        }
Beispiel #18
0
        /// <summary>
        /// Welcomes the message.
        /// </summary>
        /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
        /// <param name="message">The message.</param>
        protected void WelcomeMessage(ClientJoinedEventArgs e, MessageDefinition message)
        {
            if (!message.Enabled)
            {
                return;
            }

            if (e.ClientType == 0)
            {
                QueryRunner.SendTextMessage(
                    MessageTarget.Channel, message.Channel,
                    message.TextMessage.ToMessage(new MessageContext
                {
                    ClientDatabaseId = e.ClientDatabaseId,
                    ClientNickname   = e.Nickname
                }));
            }

            Log(message, string.Format("Welcome message successfully sent to client '{0}'(id:{1}).", e.Nickname, e.ClientDatabaseId));
        }
Beispiel #19
0
 /// <summary>
 /// Invokes the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
 public override void Invoke(ClientJoinedEventArgs e)
 {
     ClearAwayClients(e);
 }
Beispiel #20
0
 /// <summary>
 /// Times the capture.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
 protected void TimeCapture(ClientJoinedEventArgs e)
 {
     Repository.Client.CaptureTime(e.ClientDatabaseId, Repository.Static.Now, null);
 }
Beispiel #21
0
 /// <summary>
 /// Invokes the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
 public override void Invoke(ClientJoinedEventArgs e)
 {
     KickClientsWithBadNickname(e);
 }
Beispiel #22
0
 /// <summary>
 /// Invokes the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
 public virtual void Invoke(ClientJoinedEventArgs e)
 {
     Manager.Where(m => m.CanInvoke(e)).ForEach(m => m.Invoke(e));
 }
Beispiel #23
0
 private void _server_Joined(object sender, ClientJoinedEventArgs e)
 {
     SendFromServer($"{e.Client} has joined");
 }
Beispiel #24
0
 private static void ClientJoined_Triggered(object sender, ClientJoinedEventArgs e)
 {
     ClientJoined(e);
 }
Beispiel #25
0
 private void onClientConnect(object sender, ClientJoinedEventArgs e)
 {
     GreetUser((int)e.ClientId);
 }
Beispiel #26
0
 public void OnPlayerJoined(ClientJoinedEventArgs e)
 {
 }
Beispiel #27
0
 /// <summary>
 /// Invokes the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
 public virtual void Invoke(ClientJoinedEventArgs e)
 {
 }
Beispiel #28
0
 /// <summary>
 /// Determines whether this instance can invoke the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
 /// <returns>
 ///   <c>true</c> if this instance can invoke the specified e; otherwise, <c>false</c>.
 /// </returns>
 public virtual bool CanInvoke(ClientJoinedEventArgs e)
 {
     return(false);
 }
Beispiel #29
0
 /// <summary>
 /// Invokes the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
 public override void Invoke(ClientJoinedEventArgs e)
 {
     KickRecordingClients(e);
 }
Beispiel #30
0
 /// <summary>
 /// Invokes the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.ClientJoinedEventArgs"/> instance containing the event data.</param>
 public override void Invoke(ClientJoinedEventArgs e)
 {
     StickyChannel(e);
 }