diff --git a/Core/bottypes/ActionsAutoAcceptBot.cs b/Core/bottypes/ActionsAutoAcceptBot.cs new file mode 100644 index 0000000..a909afa --- /dev/null +++ b/Core/bottypes/ActionsAutoAcceptBot.cs @@ -0,0 +1,91 @@ +using BetterSecondBotShared.bottypes; +using BetterSecondBotShared.Static; +using OpenMetaverse; +using System.Collections.Generic; + +namespace BSB.bottypes +{ + public abstract class ActionsAutoAcceptBot : BasicBot + { + Dictionary> accept_actions_storage = new Dictionary>(); + Dictionary> sticky_accept_actions_storage = new Dictionary>(); + + public bool Accept_action_from(string action, UUID avatar) + { + if(accept_actions_storage.ContainsKey(avatar) == true) + { + if (accept_actions_storage[avatar].Contains(action) == true) + { + return true; + } + } + if(sticky_accept_actions_storage.ContainsKey(avatar) == true) + { + return sticky_accept_actions_storage[avatar].Contains(action); + } + return false; + } + public void Remove_action_from(string action, UUID avatar) + { + Remove_action_from(action, avatar, false); + } + + public void Remove_action_from(string action, UUID avatar, bool remove_sticky) + { + if (accept_actions_storage.ContainsKey(avatar) == true) + { + if(accept_actions_storage[avatar].Contains(action) == true) + { + accept_actions_storage[avatar].Remove(action); + } + if(accept_actions_storage[avatar].Count == 0) + { + accept_actions_storage.Remove(avatar); + } + } + if(remove_sticky == true) + { + if (sticky_accept_actions_storage.ContainsKey(avatar) == true) + { + if (sticky_accept_actions_storage[avatar].Contains(action) == true) + { + sticky_accept_actions_storage[avatar].Remove(action); + } + if (sticky_accept_actions_storage[avatar].Count == 0) + { + sticky_accept_actions_storage.Remove(avatar); + } + } + } + } + public void Add_action_from(string action, UUID avatar) + { + Add_action_from(action, avatar, false); + } + public void Add_action_from(string action, UUID avatar, bool sticky) + { + if(sticky == true) + { + if (sticky_accept_actions_storage.ContainsKey(avatar) == false) + { + sticky_accept_actions_storage.Add(avatar, new List()); + } + if (sticky_accept_actions_storage[avatar].Contains(action) == false) + { + sticky_accept_actions_storage[avatar].Add(action); + } + } + else + { + if (accept_actions_storage.ContainsKey(avatar) == false) + { + accept_actions_storage.Add(avatar, new List()); + } + if (accept_actions_storage[avatar].Contains(action) == false) + { + accept_actions_storage[avatar].Add(action); + } + } + } + } +}