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}"); } }
/// <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 })); }
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); } }
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!" }); }
/// <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; }
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); } }
/// <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()); } }
private void OnPlayerJoined(ClientJoinedEventArgs e) { foreach (EventListener bl in Plugins) { IPlayerListener pl = (IPlayerListener)bl.Listener; if (bl.Event == Event.PlayerJoined) { pl.OnPlayerJoined(e); } } }
/// <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); } }
/// <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); } }
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); }
/// <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); } }
/// <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); } }
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!" }); }
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); } } }
/// <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)); }
/// <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); }
/// <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); }
/// <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); }
/// <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)); }
private void _server_Joined(object sender, ClientJoinedEventArgs e) { SendFromServer($"{e.Client} has joined"); }
private static void ClientJoined_Triggered(object sender, ClientJoinedEventArgs e) { ClientJoined(e); }
private void onClientConnect(object sender, ClientJoinedEventArgs e) { GreetUser((int)e.ClientId); }
public void OnPlayerJoined(ClientJoinedEventArgs e) { }
/// <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) { }
/// <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); }
/// <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); }
/// <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); }