Skip to content

Commit 8891338

Browse files
committed
Promote next user when autoOp is on
1 parent 41e5de2 commit 8891338

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/Atlasd/Battlenet/Channel.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Concurrent;
77
using System.Collections.Generic;
8+
using System.Globalization;
89
using System.Net;
910
using System.Text;
1011

@@ -615,6 +616,25 @@ public bool RemoveUser(GameState user)
615616
Logging.WriteLine(Logging.LogLevel.Error, Logging.LogType.Channel, $"Failed to remove designated heir [{heir.OnlineName}] from channel [{this.Name}]");
616617
}
617618
}
619+
620+
// If autoOp is enabled and channel is not public, does not start with "clan " or "op ", then promote next user by oldest entry to channel operator.
621+
var autoOp = Settings.GetBoolean(new string[] { "channel", "auto_op" }, false);
622+
if (autoOp && !(IsPublic() || Name.StartsWith("clan ", true, CultureInfo.InvariantCulture) || Name.StartsWith("op ", true, CultureInfo.InvariantCulture)))
623+
{
624+
bool hasOperator = false;
625+
lock (Users)
626+
{
627+
foreach (var subuser in Users)
628+
{
629+
if (subuser.HasAdmin(includeChannelOp: true))
630+
{
631+
hasOperator = true;
632+
break;
633+
}
634+
}
635+
if (!hasOperator && Count > 0) UpdateUser(Users[0], Users[0].ChannelFlags | Account.Flags.ChannelOp);
636+
}
637+
}
618638
}
619639

620640
if (Count == 0 && !ActiveFlags.HasFlag(Flags.Public)) Close();

0 commit comments

Comments
 (0)