Skip to content

Commit

Permalink
cleanup feedback and add support for dot names for object owners if e…
Browse files Browse the repository at this point in the history
…nabled
  • Loading branch information
Madpeterz committed Feb 4, 2025
1 parent 552f5a4 commit 0c49114
Showing 1 changed file with 42 additions and 17 deletions.
59 changes: 42 additions & 17 deletions SecondBotEvents/Services/InteractionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ public override string Status()
return "Active";
}

protected bool ProcessRequest(bool enabledByConfig, string ConfigAcceptLevel, string avatarName, string sourceName, UUID avataruuid)
protected bool ProcessRequest(bool enabledByConfig, string ConfigAcceptLevel, string avatarName, string sourceName, UUID avataruuid, Dictionary<string,string> misc = null)
{
if(myConfig.GetEnabled() == false)
if (misc == null)
{
misc = new Dictionary<string, string>();
}
if (myConfig.GetEnabled() == false)
{
JsonOuput(false, sourceName, avatarName, "Interactions hooks disabled");
return false;
Expand All @@ -65,15 +69,16 @@ protected bool ProcessRequest(bool enabledByConfig, string ConfigAcceptLevel, st
bool accepted = false;
string ObjectOwnerName = master.DataStoreService.GetAvatarName(avataruuid);
string whyAccepted = "rejected request";
misc.Add("ObjectOwner", ObjectOwnerName);
if (master.CommandsService.myConfig.GetMastersCSV().Contains(avatarName) == true)
{
whyAccepted = "on owners list";
return true;
accepted = true;
}
else if (master.CommandsService.myConfig.GetMastersCSV().Contains(ObjectOwnerName) == true)
{
whyAccepted = "Object Owner is on master list";
return true;
accepted = true;
}
else if (ConfigAcceptLevel == "Anyone")
{
Expand All @@ -91,6 +96,22 @@ protected bool ProcessRequest(bool enabledByConfig, string ConfigAcceptLevel, st
if (bits.Length == 2)
{
accepted = master.CommandsService.myConfig.GetMastersCSV().Contains(bits[0].FirstCharToUpper() + " " + bits[1].FirstCharToUpper());
if (accepted == true)
{
whyAccepted = "on owners list [dot check]";
}
}
if (accepted == false)
{
bits = ObjectOwnerName.ToLower().Split('.');
if (bits.Length == 2)
{
accepted = master.CommandsService.myConfig.GetMastersCSV().Contains(bits[0].FirstCharToUpper() + " " + bits[1].FirstCharToUpper());
if (accepted == true)
{
whyAccepted = "Object Owner is on master list [dot check]";
}
}
}
}
if (accepted == false)
Expand All @@ -102,7 +123,7 @@ protected bool ProcessRequest(bool enabledByConfig, string ConfigAcceptLevel, st
whyAccepted = "was on NextAccept list";
}
}
JsonOuput(accepted, sourceName, avatarName, whyAccepted);
JsonOuput(accepted, sourceName, avatarName, whyAccepted, misc);
return accepted;
}

Expand Down Expand Up @@ -177,7 +198,9 @@ protected void BotTeleportOffer(object o, InstantMessageEventArgs e)
mode = "Teleport Av to Bot";
markTeleport = false;
}
if (ProcessRequest(myConfig.GetAcceptTeleports(),myConfig.GetTeleportRequestLevel(), e.IM.FromAgentName, "Teleport", e.IM.FromAgentID) == false)
Dictionary<string,string> misc = new Dictionary<string, string>();
misc.Add("mode", mode);
if (ProcessRequest(myConfig.GetAcceptTeleports(),myConfig.GetTeleportRequestLevel(), e.IM.FromAgentName, "Teleport", e.IM.FromAgentID, misc) == false)
{
// rejected requests
if (e.IM.Dialog != InstantMessageDialog.RequestLure)
Expand All @@ -203,14 +226,14 @@ protected void BotTeleportOffer(object o, InstantMessageEventArgs e)

protected void BotGroupInviteOffer(object o, GroupInvitationEventArgs e)
{
if (ProcessRequest(myConfig.GetAcceptGroupInvites(),myConfig.GetGroupInviteLevel(), e.FromName, "GroupInvite", e.AgentID) == false)
Dictionary<string, string> reply = new Dictionary<string, string>();
reply.Add("message", e.Message);
reply.Add("fromuuid", e.AgentID.ToString());
if (ProcessRequest(myConfig.GetAcceptGroupInvites(),myConfig.GetGroupInviteLevel(), e.FromName, "GroupInvite", e.AgentID, reply) == false)
{
return;
}
e.Accept = true;
Dictionary<string,string> reply = new Dictionary<string,string>();
reply.Add("message", e.Message);
reply.Add("fromuuid", e.AgentID.ToString());
JsonOuputCleaner(reply, "GroupInvite");
}

Expand All @@ -232,12 +255,6 @@ protected void BotInventoryAdd(object o, InventoryObjectAddedEventArgs e)

protected void BotInventoryOffer(object o, InventoryObjectOfferedEventArgs e)
{
if(ProcessRequest(myConfig.GetAcceptInventory(),myConfig.GetInventoryTransferLevel(),e.Offer.FromAgentName, "InventoryOffer", e.Offer.FromAgentID) == false)
{
e.Accept = false;
return;
}
e.Accept = true;
Dictionary<string, string> details = new Dictionary<string, string>
{
{ "transactionid", e.Offer.IMSessionID.ToString() },
Expand All @@ -246,6 +263,12 @@ protected void BotInventoryOffer(object o, InventoryObjectOfferedEventArgs e)
{ "fromscript", e.FromTask.ToString() },
{ "targetfolder", e.FolderID.ToString() }
};
if (ProcessRequest(myConfig.GetAcceptInventory(),myConfig.GetInventoryTransferLevel(),e.Offer.FromAgentName, "InventoryOffer", e.Offer.FromAgentID, details) == false)
{
e.Accept = false;
return;
}
e.Accept = true;
if(e.FromTask == false)
{
master.DataStoreService.AddAvatar(e.Offer.FromAgentID, e.Offer.FromAgentName);
Expand All @@ -262,7 +285,9 @@ protected void BotInventoryOffer(object o, InventoryObjectOfferedEventArgs e)

protected void BotFriendRequested(object o, FriendshipOfferedEventArgs e)
{
if (ProcessRequest(myConfig.GetAcceptFriendRequests(),myConfig.GetFriendRequestLevel(), e.AgentName, "FriendRequest", e.AgentID) == false)
Dictionary<string, string> misc = new Dictionary<string, string>();
misc.Add("fromName", e.AgentName);
if (ProcessRequest(myConfig.GetAcceptFriendRequests(),myConfig.GetFriendRequestLevel(), e.AgentName, "FriendRequest", e.AgentID, misc) == false)
{
return;
}
Expand Down

0 comments on commit 0c49114

Please sign in to comment.