update group invite to lock per group not global and rollback libra
This commit is contained in:
parent
422b753c3d
commit
da6b1a7a8d
2 changed files with 32 additions and 21 deletions
|
|
@ -33,9 +33,9 @@ namespace BSB.Commands.Group
|
||||||
{
|
{
|
||||||
if (bot.MyGroups.ContainsKey(target_group) == true)
|
if (bot.MyGroups.ContainsKey(target_group) == true)
|
||||||
{
|
{
|
||||||
if (bot.GetAllowGroupInvite(target_avatar) == true)
|
if (bot.GetAllowGroupInvite(target_avatar, target_group) == true)
|
||||||
{
|
{
|
||||||
bot.GroupInviteLockoutArm(target_avatar); // enable 120 sec cooldown
|
bot.GroupInviteLockoutArm(target_avatar,target_group); // enable 120 sec cooldown
|
||||||
ForRealGroupInvite(args, target_group, target_avatar);
|
ForRealGroupInvite(args, target_group, target_avatar);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ namespace BSB.bottypes
|
||||||
|
|
||||||
protected Dictionary<string, string> Scripts_content = new Dictionary<string, string>();
|
protected Dictionary<string, string> Scripts_content = new Dictionary<string, string>();
|
||||||
protected Dictionary<string, string> notecards_content = new Dictionary<string, string>();
|
protected Dictionary<string, string> notecards_content = new Dictionary<string, string>();
|
||||||
protected Dictionary<UUID, long> group_invite_lockout_timer = new Dictionary<UUID, long>();
|
protected Dictionary<UUID, Dictionary<UUID, long>> group_invite_lockout_timer = new Dictionary<UUID, Dictionary<UUID, long>>();
|
||||||
protected long last_cleanup_commands;
|
protected long last_cleanup_commands;
|
||||||
|
|
||||||
public override string GetStatus()
|
public override string GetStatus()
|
||||||
|
|
@ -102,35 +102,46 @@ namespace BSB.bottypes
|
||||||
CommandsInterface.StatusTick();
|
CommandsInterface.StatusTick();
|
||||||
return base.GetStatus();
|
return base.GetStatus();
|
||||||
}
|
}
|
||||||
public bool GetAllowGroupInvite(UUID avatar)
|
public bool GetAllowGroupInvite(UUID avatar, UUID group)
|
||||||
{
|
{
|
||||||
return !group_invite_lockout_timer.ContainsKey(avatar);
|
if (group_invite_lockout_timer.ContainsKey(group) == true)
|
||||||
|
{
|
||||||
|
return !group_invite_lockout_timer[group].ContainsKey(avatar);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GroupInviteLockoutArm(UUID avatar)
|
public void GroupInviteLockoutArm(UUID avatar, UUID group)
|
||||||
{
|
{
|
||||||
if (group_invite_lockout_timer.ContainsKey(avatar) == false)
|
if (group_invite_lockout_timer.ContainsKey(group) == false)
|
||||||
|
{
|
||||||
|
group_invite_lockout_timer.Add(group, new Dictionary<UUID, long>());
|
||||||
|
}
|
||||||
|
if (group_invite_lockout_timer[group].ContainsKey(avatar) == false)
|
||||||
{
|
{
|
||||||
group_invite_lockout_timer.Add(avatar,0);
|
group_invite_lockout_timer[group].Add(avatar,0);
|
||||||
}
|
}
|
||||||
group_invite_lockout_timer[avatar] = helpers.UnixTimeNow();
|
group_invite_lockout_timer[group][avatar] = helpers.UnixTimeNow();
|
||||||
}
|
}
|
||||||
protected void PurgeOldGroupinviteLockouts()
|
protected void PurgeOldGroupinviteLockouts()
|
||||||
{
|
{
|
||||||
long now = helpers.UnixTimeNow();
|
long now = helpers.UnixTimeNow();
|
||||||
List<UUID> clear_locks = new List<UUID>();
|
foreach (UUID group in group_invite_lockout_timer.Keys)
|
||||||
foreach(KeyValuePair<UUID,long> Glock in group_invite_lockout_timer)
|
{
|
||||||
{
|
List<UUID> clear_locks = new List<UUID>();
|
||||||
long dif = now - Glock.Value;
|
foreach (KeyValuePair<UUID, long> Glock in group_invite_lockout_timer[group])
|
||||||
if(dif >= 120)
|
{
|
||||||
{
|
long dif = now - Glock.Value;
|
||||||
clear_locks.Add(Glock.Key);
|
if (dif >= 120)
|
||||||
|
{
|
||||||
|
clear_locks.Add(Glock.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (UUID glock in clear_locks)
|
||||||
|
{
|
||||||
|
group_invite_lockout_timer[group].Remove(glock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach(UUID glock in clear_locks)
|
|
||||||
{
|
|
||||||
group_invite_lockout_timer.Remove(glock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void custom_commands_loop(string command,string arg,UUID caller)
|
protected void custom_commands_loop(string command,string arg,UUID caller)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue