corrects a issue with better at home

the bot would start itself when created
and the athome system would also try and start leading to fun issues.
This commit is contained in:
Madpeterz 2021-02-18 11:46:07 +00:00
parent a20c70d806
commit 04c821dc5a
6 changed files with 73 additions and 40 deletions

View file

@ -14,10 +14,12 @@ namespace BetterSecondbot.BetterAtHome
protected JsonConfig configfile;
protected bool LoginFailed = false;
protected bool LoggingIn = false;
protected string whyfailed = "";
protected bool LoggingIn = true;
protected bool LoggedIn = false;
protected bool StartingLogin = false;
protected long LastLoginEvent = 0;
protected bool FiredAfterLogin = false;
protected int homeregionIndexer = 0;
protected long LastTeleportEvent = 0;
protected List<string> homeRegions = new List<string>();
@ -51,6 +53,7 @@ namespace BetterSecondbot.BetterAtHome
LoginFailed = false;
LoggingIn = false;
LoggedIn = false;
FiredAfterLogin = false;
homeregionIndexer = -1;
LastTeleportEvent = 0;
LastLoginEvent = helpers.UnixTimeNow();
@ -69,18 +72,23 @@ namespace BetterSecondbot.BetterAtHome
{
resetSwitchs();
LoginFailed = true;
whyfailed = e.FailReason;
}
else if(e.Status == LoginStatus.ConnectingToLogin)
if (LoginFailed == false)
{
resetSwitchs();
LoggingIn = true;
SetBetterAtHomeAction("Waiting for login to finish");
}
else if(e.Status == LoginStatus.Success)
{
resetSwitchs();
controler.Bot.AfterBotLoginHandler();
LoggedIn = true;
if (e.Status == LoginStatus.ConnectingToLogin)
{
LoggingIn = true;
SetBetterAtHomeAction("Waiting for login to finish");
}
else if (e.Status == LoginStatus.ConnectingToSim)
{
if (LoggedIn == false)
{
resetSwitchs();
LoggedIn = true;
}
}
}
}
@ -124,6 +132,10 @@ namespace BetterSecondbot.BetterAtHome
{
return false;
}
if(LoginFailed == true)
{
return false;
}
if(LoggingIn == true)
{
return false;
@ -132,6 +144,7 @@ namespace BetterSecondbot.BetterAtHome
{
return false;
}
return controler.Bot.GetClient.Network.Connected;
}
@ -190,6 +203,22 @@ namespace BetterSecondbot.BetterAtHome
return;
}
long dif = helpers.UnixTimeNow() - LastLoginEvent;
if (LoginFailed == true)
{
if (whyfailed != "presence")
{
SetBetterAtHomeAction("[DC] Unable to continue: " + whyfailed);
return;
}
else
{
if (dif < 45)
{
SetBetterAtHomeAction("[DC] Clearing logged in avatar 45 secs");
return;
}
}
}
if (dif < 15)
{
SetBetterAtHomeAction("[DC] Waiting for login lockout");
@ -201,11 +230,6 @@ namespace BetterSecondbot.BetterAtHome
SetBetterAtHomeAction("[DC] Waiting for Teleport lockout");
return;
}
if (controler.Bot.KillMe == true)
{
SetBetterAtHomeAction("[DC] Marked for death");
return;
}
SetBetterAtHomeAction("[DC] Attempt to recover");
if (StartingLogin == true)
{
@ -219,19 +243,6 @@ namespace BetterSecondbot.BetterAtHome
protected void LoggedInAction()
{
if((simname == "") || (controler.Bot.GetClient.Self.SimPosition.Z == 0))
{
ChangedSim(null, null);
void_counter++;
SetBetterAtHomeAction("Void counter: "+ void_counter.ToString());
if (void_counter == 10)
{
resetSwitchs();
SetBetterAtHomeAction("Void detected - Resetting switchs");
}
return;
}
void_counter = 0;
SetBetterAtHomeAction("Logged In Actions");
if (controler.Bot.KillMe == true)
{
@ -250,6 +261,29 @@ namespace BetterSecondbot.BetterAtHome
SetBetterAtHomeAction("Waiting for Teleport lockout");
return;
}
if ((simname == "") || (controler.Bot.GetClient.Self.SimPosition.Z == 0))
{
ChangedSim(null, null);
}
if ((simname == "") || (controler.Bot.GetClient.Self.SimPosition.Z == 0))
{
void_counter++;
SetBetterAtHomeAction("Void counter: " + void_counter.ToString());
if (void_counter == 10)
{
void_counter = 0;
resetSwitchs();
SetBetterAtHomeAction("Void detected - Resetting switchs");
}
return;
}
if (FiredAfterLogin == false)
{
FiredAfterLogin = true;
controler.Bot.AfterBotLoginHandler();
controler.Bot.reconnect = true;
}
void_counter = 0;
if (homeRegions.Count == 0)
{
SetBetterAtHomeAction("No home regions");

View file

@ -61,7 +61,7 @@ namespace BetterSecondBot
{
Bot.AsDocker();
}
Bot.Start();
Bot.Start(false);
attachEventListenerObjects(Config, as_docker);
if(use_self_keep_alive == true)
{

View file

@ -221,12 +221,11 @@ namespace BetterSecondBot.bottypes
{
Client.Avatars.UUIDNameReply += Key2NameEvent;
Client.Directory.DirPeopleReply += Name2KeyEvent;
if (helpers.notempty(myconfig.Security_MasterUsername) == true)
{
FindAvatarName2Key(myconfig.Security_MasterUsername);
}
}
if (helpers.notempty(myconfig.Security_MasterUsername) == true)
{
FindAvatarName2Key(myconfig.Security_MasterUsername);
}
base.AfterBotLoginHandler();
}

View file

@ -14,8 +14,7 @@ namespace BetterSecondBot.bottypes
if (reconnect == false)
{
Client.Avatars.AvatarAnimation += AvatarAnimationHandler;
}
reconnect = true;
}
}
public override void ResetAnimations()

View file

@ -29,9 +29,9 @@ namespace BetterSecondBot.bottypes
started_friendship_hug = true;
if (Client.Friends.FriendList.ContainsKey(master_uuid) == false)
{
CallAPI("IM", new string[] { myconfig.Security_MasterUsername, "Hello master, I am sending you a friend request now!" });
CallAPI("IM", new string[] { myconfig.Security_MasterUsername, "Hello master, I am sending you a friend request now!" });
CallAPI("FriendRequest", new string[] { master_uuid.ToString(), "true" });
}
CallAPI("FriendRequest", new string[] { master_uuid.ToString(), "true" });
CallAPI("FriendFullPerms", new string[] { master_uuid.ToString(), "true" });
}
}

View file

@ -51,7 +51,8 @@ namespace BetterSecondBotShared.bottypes
public JsonConfig getMyConfig { get { return myconfig; } }
protected string version = "NotSet V1.0.0.0";
protected bool reconnect;
public bool reconnect;
public string MyVersion { get { return version; } }
public string Name { get { return myconfig.Basic_BotUserName; } }
public string OwnerName { get { return myconfig.Security_MasterUsername; } }