diff --git a/BSBshared/Json/JsonConfig.cs b/BSBshared/Json/JsonConfig.cs index e23bea9..7fc6125 100644 --- a/BSBshared/Json/JsonConfig.cs +++ b/BSBshared/Json/JsonConfig.cs @@ -15,13 +15,15 @@ namespace BetterSecondBotShared.Json // Security public bool AllowFunds { get; set; } - // Mixed + // Settings public bool allowRLV { get; set; } - public string DefaultSitUUID { get; set; } + public bool OnStartLinkupWithMaster { get; set; } + + // Mixed public bool CommandsToConsole { get; set; } public int MaxCommandHistory { get; set; } public string RelayImToAvatar { get; set; } - + // Discord public string discordWebhookURL { get; set; } public string discordGroupTarget { get; set; } @@ -34,6 +36,7 @@ namespace BetterSecondBotShared.Json public string[] homeRegion { get; set; } public bool AtHomeSimOnly { get; set; } public float AtHomeSimPosMaxRange { get; set; } + public string DefaultSitUUID { get; set; } // HTTP interface public bool EnableHttp { get; set; } diff --git a/BSBshared/Json/JsonConfigApi.cs b/BSBshared/Json/JsonConfigApi.cs index f869605..5ee4135 100644 --- a/BSBshared/Json/JsonConfigApi.cs +++ b/BSBshared/Json/JsonConfigApi.cs @@ -41,6 +41,7 @@ namespace BetterSecondBotShared.Json case "athomesimonly": { return "AtHome"; } case "athomesimposmaxrange": { return "AtHome"; } case "allowfunds": { return "security"; } + case "onstartlinkupwithmaster": { return "Options"; } default: { return "Unknown"; } } @@ -75,6 +76,7 @@ namespace BetterSecondBotShared.Json case "athomesimonly": { return "Should the @Home system only care if the sim name is correct (use false to use max distance checks)"; } case "athomesimposmaxrange": { return "How far away from the location in homeregion can the bot be before teleporting"; } case "allowfunds": { return "Allow the bot to transfer L$ to avatars / objects and display its L$ balance via command/web gui"; } + case "onstartlinkupwithmaster": { return "After the bot logs in should it send the master a friend request, IM them and request teleport"; } default: { return "None given"; } } } @@ -128,6 +130,7 @@ namespace BetterSecondBotShared.Json case "athomesimonly": { return new[] { "false" }; } case "athomesimposmaxrange": { return new[] { "10.0" }; } case "allowfunds": { return new[] { "true" }; } + case "onstartlinkupwithmaster": { return new[] { "true" }; } default: { return new string[] { }; } } } diff --git a/Core/bottypes/EventsBot.cs b/Core/bottypes/EventsBot.cs index 97fab92..5dd0053 100644 --- a/Core/bottypes/EventsBot.cs +++ b/Core/bottypes/EventsBot.cs @@ -228,10 +228,16 @@ namespace BSB.bottypes Client.Self.IM += MessageHandler; Client.Groups.CurrentGroups += GroupsHandler; Client.Self.ScriptQuestion += PermissionsHandler; + Client.Friends.FriendshipResponse += FriendshipResponse; delay_group_fetch = helpers.UnixTimeNow() + 10; } } + protected virtual void FriendshipResponse(object o, FriendshipResponseEventArgs E) + { + + } + protected override void PermissionsHandler(object sender, ScriptQuestionEventArgs e) { if(e.ObjectOwnerName == Client.Self.Name) diff --git a/Core/bottypes/SecondBot.cs b/Core/bottypes/SecondBot.cs index e75fc13..83a5584 100644 --- a/Core/bottypes/SecondBot.cs +++ b/Core/bottypes/SecondBot.cs @@ -5,10 +5,36 @@ using OpenMetaverse; using Discord; using Discord.Webhook; using BetterSecondBotShared.Json; +using BetterSecondBotShared.Static; namespace BSB.bottypes { public class SecondBot : DialogsBot { + protected override void AfterBotLoginHandler() + { + base.AfterBotLoginHandler(); + if (helpers.notempty(myconfig.master) == true) + { + if (myconfig.OnStartLinkupWithMaster == true) + { + CommandsInterface.Call("IM", String.Join("~#~", new string[] { myconfig.master, "Hello master I am now online and ready to accept teleport offers" })); + CommandsInterface.Call("FriendRequest", myconfig.master, Client.Self.AgentID); + CommandsInterface.Call("FriendFullPerms", String.Join("~#~", new string[] { myconfig.master, "true" }), Client.Self.AgentID); + } + } + } + + protected override void FriendshipResponse(object o,FriendshipResponseEventArgs E) + { + base.FriendshipResponse(o, E); + if(E.Accepted == true) + { + if(E.AgentName == myconfig.master) + { + CommandsInterface.Call("FriendFullPerms", String.Join("~#~", new string[] { myconfig.master, "true" }), Client.Self.AgentID); + } + } + } } }