public void ClientMoved(ClientMovedEventArgs e) { // czy klient był na obserwowanym kanale if (WasOnTackedChannel(e.ClientId)) { LeftTrackedChannel(e.ClientId); } if (channels.ContainsKey(e.TargetChannelId)) { UpdateTimers(); log.Info($"{DateTime.Now}: Client (clid:{e.ClientId}) moved to channel (cid:{e.TargetChannelId})."); ChannelData ch = channels[e.TargetChannelId]; if (ch.WasStaff) { return; } ClientData cd = GetClientData(e.ClientId); if (cd == null) { return; } ch.Join(cd); if (ch.NeedHelp) { InitializeTimer(ch); } return; } }
private void InitializeTimer(ChannelData cd) { lock (TimersLock) { if (!timers.ContainsKey(cd.Id)) { Timer t = new Timer(); t.Interval = 1800; t.Enabled = true; t.Elapsed += delegate { ChannelTick(cd); }; timers.Add(cd.Id, t); log.Info($"Added timer for (cid:{cd.Id})."); } } }
public void AddChannel(ChannelData channel) { channels.Add(channel.Id, channel); }
private void ChannelTick(ChannelData ch) { if (ch.WasStaff) { UpdateTimers(); } List <Client> chStaffOnline = Server.GetClientsWithGroups(ch.GetGroupList()); Channel channel = Server.GetChannel(ch.Id); string clientMsgKey; if (chStaffOnline.Count > 0) { if (ch.LongerTime(config.DelayNotifStart)) { string clientName = string.Join(", ", ch.Clients.Select(c => c.Object.Nickname)); clientName = clientName.Substring(0, Math.Min(config.MaxLengthNicknames, clientName.Length)); // Notifications for staff foreach (var s in chStaffOnline) { // TODO: czas reakcji, typ, bądź ignorowanie wiadmości idndywidualne dla każego z obsługi var cd = GetClientData(s.ClientId); if (!cd.HasNotifCooldown(config.StaffNotifCooldown)) { log.Info($"Staff Notice (clid:{cd.Object.ClientId}) per (cid:{ch.Id})."); if (ch.WasStaff) { return; } new ClientPokeCommand(s.ClientId, lang.GetMessage("StaffNotification", extension, s.ClientId) .Replace("{ClientName}", clientName).Replace("{ChannelName}", channel.Name).Replace("{Time}", ch.Time())) .Execute(Interface.TS3Bot.QueryClient); cd.LastNotifNow(); } } //ch.NextLevel(); } if (!ch.LongerTime(config.MaxWaitingTimeWhenStaffIsOnline)) { clientMsgKey = "UserNotification"; } else { clientMsgKey = "UserStaffBusyNotification"; } } else { clientMsgKey = "UserNoStaffOnlineNotification"; } // Notifications for clients foreach (var cd in ch.Clients) { if (!cd.HasNotifCooldown(config.UserNotifCooldown)) { log.Info($"Client Notice '{clientMsgKey}' (clid:{cd.Object.ClientId}) per (cid:{ch.Id})."); if (ch.WasStaff) { return; } new SendTextMessageCommand(MessageTarget.Client, cd.Object.ClientId, lang.GetMessage(clientMsgKey, extension, cd.Object.ClientId) .Replace("{ClientName}", cd.Object.Nickname)).Execute(Interface.TS3Bot.QueryClient); cd.LastNotifNow(); } } }