public MuteListEntry(MuteListEntry src) { MuteName = src.MuteName; MuteID = src.MuteID; Type = src.Type; Flags = src.Flags; }
public MuteEntry(UUID ID, MuteFlags Flags, string Name, MuteType Type) { this.ID = ID; this.Flags = Flags; this.Name = Name; this.Type = Type; }
public static bool IsAvailable(MuteType type, SearchMode search, string text) { return(Enum.IsDefined(typeof(MuteType), type) && Enum.IsDefined(typeof(SearchMode), search) && !string.IsNullOrWhiteSpace(text) && (search != SearchMode.Regex || IsEnableRegex(text))); }
public static bool AddMute(MuteFlags flags, UUID uuid, string name, MuteType type) { return(!uuid.Equals(UUID.Zero) && !string.IsNullOrEmpty(name) && AddMute(new MuteEntry { Flags = flags, ID = uuid, Name = name, Type = type })); }
/// <summary> /// Checks if track is muted. Defaults to all. /// </summary> /// <param name="type">The track <see cref="MuteType" /> to be muted .</param> /// <returns>The resulting <see cref="bool" />.</returns> public static bool IsMute(MuteType type = MuteType.All) { switch (type) { case MuteType.All: return(mute.all); case MuteType.Sound: return(mute.sound); case MuteType.Music: return(mute.music); case MuteType.VO: return(mute.vo); } return(false); }
private void MuteCommands_UserUnmuted(IGuildUser usr, MuteType muteType) { var _ = Task.Run(async() => { try { if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out LogSetting logSetting) || (logSetting.UserMutedId == null)) { return; } ITextChannel logChannel; if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserMuted)) == null) { return; } var mutes = ""; var unmutedLocalized = GetText(logChannel.Guild, "unmuted_sn"); switch (muteType) { case MuteType.Voice: mutes = "🔊 " + GetText(logChannel.Guild, "xmuted_voice", unmutedLocalized); break; case MuteType.Chat: mutes = "🔊 " + GetText(logChannel.Guild, "xmuted_text", unmutedLocalized); break; case MuteType.All: mutes = "🔊 " + GetText(logChannel.Guild, "xmuted_text_and_voice", unmutedLocalized); break; } var embed = new EmbedBuilder().WithAuthor(eab => eab.WithName(mutes)) .WithTitle($"{usr.Username}#{usr.Discriminator} | {usr.Id}") .WithFooter(fb => fb.WithText($"{CurrentTime(usr.Guild)}")) .WithOkColor(); await logChannel.EmbedAsync(embed).ConfigureAwait(false); } catch { // ignored } }); }
private void CommonMuteControl(MuteType muteType) { _logger.LogDebug($"Game({_game.Code.Code}) mute task start."); var mtasks = new List <Task>(); foreach (var user in _guildMembersInVC.Values) { var nextMuteState = CreateNextMuteState(user, muteType); if (NeedMuteControl(user, nextMuteState)) { mtasks.Add(user.ModifyAsync(x => { x.Mute = nextMuteState.Mute; x.Deaf = nextMuteState.Deaf; })); } } try { Task.WhenAll(mtasks); } catch (Exception e) { LogStackTrace(e, "CommonMuteControl"); } _delayTimer?.Stop(); _delayTimer?.Dispose(); _delayTimer = null; // Change current phase switch (muteType) { case MuteType.TaskPhase: _phase = PhaseTypes.Task; break; case MuteType.MeetingPhase: _phase = PhaseTypes.Meeting; break; case MuteType.Default: _phase = PhaseTypes.Lobby; break; } PutInternalInfo(); UpdateEmbedMonitor(); }
/// <summary> /// UnMutes audio track. By default mutes all. /// </summary> /// <param name="type">The track <see cref="MuteType" /> to be unmuted .</param> public static void UnMute(MuteType type = MuteType.All) { switch (type) { case MuteType.All: mute.all = false; break; case MuteType.Sound: mute.sound = false; break; case MuteType.Music: mute.music = false; break; case MuteType.VO: mute.vo = false; break; } if (type == MuteType.All) { SoundEffect.MasterVolume = 1f; MasterVolume = 1f; Microsoft.Xna.Framework.Media.MediaPlayer.IsMuted = false; for (int i = 0; i < playingInstances.Count; i++) { playingInstances[i].Volume = 1f; } } else if (type == MuteType.Sound) { SoundEffect.MasterVolume = 1f; MasterVolume = 1f; for (int i = 0; i < playingInstances.Count; i++) { playingInstances[i].Volume = 1f; } } else if (type == MuteType.Music) { Microsoft.Xna.Framework.Media.MediaPlayer.IsMuted = false; } }
public async Task MuteUser(IGuildUser usr, MuteType type = MuteType.All) { if (type == MuteType.All) { await usr.ModifyAsync(x => x.Mute = true).ConfigureAwait(false); var muteRole = await GetMuteRole(usr.Guild); if (!usr.RoleIds.Contains(muteRole.Id)) { await usr.AddRoleAsync(muteRole).ConfigureAwait(false); } StopUnmuteTimer(usr.GuildId, usr.Id); using (var uow = _db.UnitOfWork) { var config = uow.GuildConfigs.For(usr.Guild.Id, set => set.Include(gc => gc.MutedUsers) .Include(gc => gc.UnmuteTimers)); config.MutedUsers.Add(new MutedUserId() { UserId = usr.Id }); if (MutedUsers.TryGetValue(usr.Guild.Id, out ConcurrentHashSet <ulong> muted)) { muted.Add(usr.Id); } config.UnmuteTimers.RemoveWhere(x => x.UserId == usr.Id); await uow.CompleteAsync().ConfigureAwait(false); } UserMuted(usr, MuteType.All); } else if (type == MuteType.Voice) { await usr.ModifyAsync(x => x.Mute = true).ConfigureAwait(false); UserMuted(usr, MuteType.Voice); } else if (type == MuteType.Chat) { await usr.AddRoleAsync(await GetMuteRole(usr.Guild).ConfigureAwait(false)).ConfigureAwait(false); UserMuted(usr, MuteType.Chat); } }
private MuteState CreateNextMuteState(IGuildUser user, MuteType muteType) { // set default state _logger.LogDebug($"{user.Username} mute conf"); var ms = new MuteState(_defaultVCProps[user.Id]); if (muteType == MuteType.Default) { return(ms); } _logger.LogDebug($"{user.Username} dead state set"); // Set dead state bool isDead = true; var cnvInfo = _idConversionDict.FirstOrDefault(u => u.Value == user.Id); if (cnvInfo.Value == user.Id) { try { _logger.LogDebug($"{user.Username} found in conversion list"); isDead = _isDead[cnvInfo.Key]; var name = _players[cnvInfo.Key].Client.Name; _logger.LogDebug($"Player => {name}({user.Username}) is dead: {isDead}"); } catch (Exception e) { LogStackTrace(e, "CreateNextMuteState"); } } else { _logger.LogInformation($"Spectator => {user.Username}"); } // Apply mute rule MuteConfig m = _config.TaskPhaseMuteRules; if (muteType == MuteType.MeetingPhase) { m = _config.MeetingPhaseMuteRules; } ms.Mute = isDead ? m.Mute.Dead : m.Mute.Alive; ms.Deaf = isDead ? m.Deaf.Dead : m.Deaf.Alive; return(ms); }
private void TriggerMuteTimer(int delay, MuteType MuteType) { _delayTimer?.Dispose(); if (delay == 0) { Task.Run(() => CommonMuteControl(MuteType)); _logger.LogInformation($"Mute delay = 0, mute start - type: {MuteType}"); return; } _delayTimer = new Timer(); _delayTimer.Interval = delay; _delayTimer.Elapsed += (s, e) => { CommonMuteControl(MuteType); }; _delayTimer.AutoReset = false; _delayTimer.Start(); _logger.LogInformation($"Mute delay timer started - type: {MuteType}, delay: {delay}ms"); }
public async Task UnmuteUser(IGuildUser usr, MuteType type = MuteType.All) { if (type == MuteType.All) { StopUnmuteTimer(usr.GuildId, usr.Id); try { await usr.ModifyAsync(x => x.Mute = false).ConfigureAwait(false); } catch { /*ignore*/ } try { await usr.RemoveRoleAsync(await GetMuteRole(usr.Guild)).ConfigureAwait(false); } catch { /*ignore*/ } using (var uow = _db.UnitOfWork) { var config = uow.GuildConfigs.For(usr.Guild.Id, set => set.Include(gc => gc.MutedUsers) .Include(gc => gc.UnmuteTimers)); config.MutedUsers.Remove(new MutedUserId { UserId = usr.Id }); if (MutedUsers.TryGetValue(usr.Guild.Id, out var muted)) { muted.TryRemove(usr.Id); } config.UnmuteTimers.RemoveWhere(x => x.UserId == usr.Id); await uow.CompleteAsync().ConfigureAwait(false); } UserUnmuted(usr, MuteType.All); } else if (type == MuteType.Voice) { await usr.ModifyAsync(x => x.Mute = false).ConfigureAwait(false); UserUnmuted(usr, MuteType.Voice); } else if (type == MuteType.Chat) { await usr.RemoveRoleAsync(await GetMuteRole(usr.Guild).ConfigureAwait(false)).ConfigureAwait(false); UserUnmuted(usr, MuteType.Chat); } }
public static bool RemoveMute(MuteFlags flags, UUID muteUUID, string name, MuteType type) { MuteEntry mute; lock (MuteCacheLock) { mute = ObservableMuteCache[new MuteEntry { ID = muteUUID, Flags = flags, Name = name, Type = type }]; } if (mute.Equals(default(MuteEntry))) { return(false); } lock (MuteCacheLock) { return(ObservableMuteCache.Remove(mute)); } }
/// <summary> /// Mute an object, resident, etc. /// </summary> /// <param name="type">Mute type</param> /// <param name="id">Mute UUID</param> /// <param name="name">Mute name</param> /// <param name="flags">Mute flags</param> public void UpdateMuteListEntry(MuteType type, UUID id, string name, MuteFlags flags) { UpdateMuteListEntryPacket p = new UpdateMuteListEntryPacket(); p.AgentData.AgentID = Client.Self.AgentID; p.AgentData.SessionID = Client.Self.SessionID; p.MuteData.MuteType = (int)type; p.MuteData.MuteID = id; p.MuteData.MuteName = Utils.StringToBytes(name); p.MuteData.MuteFlags = (uint)flags; Client.Network.SendPacket(p); MuteEntry me = new MuteEntry(); me.Type = type; me.ID = id; me.Name = name; me.Flags = flags; lock (MuteList.Dictionary) { MuteList[string.Format("{0}|{1}", me.ID, me.Name)] = me; } OnMuteListUpdated(EventArgs.Empty); }
/// <summary> /// Mute an object, resident, etc. /// </summary> /// <param name="type">Mute type</param> /// <param name="id">Mute UUID</param> /// <param name="name">Mute name</param> public void UpdateMuteListEntry(MuteType type, UUID id, string name) { UpdateMuteListEntry(type, id, name, MuteFlags.Default); }
public MutedEventArgs(MuteType type, int secondsLeft) { Type = type; SecondsLeft = secondsLeft; }
public override CmdResult ExecuteRequest(CmdRequest pargs) { string verb = pargs.CmdName; string[] args = pargs.tokens; var chat = TheBotClient.Self; string arg1 = "show"; if (args.Length > 0) { arg1 = args[0].ToLower(); } var cmld = chat.MuteList.Copy(); if (arg1 == "show" || arg1 == "list" || arg1 == "request") { if (arg1 == "request") { chat.RequestMuteList(); } int nfound = 0; foreach (var mm in cmld) { AddSuccess("Mutelist Item: " + mm.Key + " is " + Helpers.StructToString(mm.Value)); nfound++; } return(Success(verb + " found: " + nfound + " object/agent(s)")); } lock (cmld) { cmld.Clear(); } bool unmute = verb.ToLower().StartsWith("u"); if (arg1 == "all") { if (unmute) { int nfound = 0; foreach (var mm in cmld) { MuteEntry me = mm.Value; chat.UpdateMuteListEntry(me.Type, me.ID, me.Name, MuteFlags.All); chat.RemoveMuteListEntry(me.ID, me.Name); AddSuccess("Unmuted " + Helpers.StructToString(me) + "."); nfound++; } chat.RequestMuteList(); return(Success(verb + " found: " + nfound + " object/agent(s)")); } if (args.Length == 1) { args = new[] { "dist", "30" } } ; } object value; MuteFlags mf = MuteFlags.All; int argsUsed; if (TryEnumParse(typeof(MuteFlags), args, 0, out argsUsed, out value)) { mf = (MuteFlags)value; } if (!unmute) { // invert the flags mf = (MuteFlags)((int)MuteFlags.All - (int)mf); } // if flags found if (argsUsed > 0) { args = Parser.SplitOff(args, argsUsed); } string muteName = ((MuteFlags)((int)MuteFlags.All - (int)mf)).ToString(); List <SimObject> PS = WorldSystem.GetPrimitives(args, out argsUsed); if (!IsEmpty(PS)) { int nfound = 0; foreach (var prim in PS) { UUID id = prim.ID; MuteType mt = MuteType.Object; if (prim is SimAvatar) { mt = MuteType.Resident; } if (mf == MuteFlags.All) { chat.RemoveMuteListEntry(id, null); } else { chat.UpdateMuteListEntry(mt, id, null, mf); } nfound++; AddSuccess(verb + " " + muteName + " " + prim + " " + id + "."); } if (nfound > 0) { chat.RequestMuteList(); return(Success(verb + " " + muteName + ": " + nfound + " object/agent(s)")); } } return(Failure("I don't know who " + pargs.str + " is.")); } }
public static bool Create(MuteType type, SearchMode search, string text, out Mute mute) { return((mute = new Mute(type, search, text)).Apply()); }
public Mute(MuteType type, SearchMode search, string text) { Type = type; Search = search; Text = text; }