Adjusts the bot to only IM and request friendship if the flag is set AND you are not already on the friends list otherwise just give full friend perms

This commit is contained in:
Madpeter 2020-05-10 22:21:22 +01:00
parent d8d5dfb78b
commit 7a36cec3a7

View file

@ -11,20 +11,54 @@ namespace BSB.bottypes
{
public class SecondBot : DialogsBot
{
protected override void AfterBotLoginHandler()
protected bool friendslist_ready = false;
protected bool masteruuid_ready = false;
protected bool started_friendship_hug = false;
protected virtual void friendsListReady(object sender,FriendsReadyEventArgs e)
{
base.AfterBotLoginHandler();
if (helpers.notempty(myconfig.master) == true)
friendslist_ready = true;
TryHugMaster();
}
protected void TryHugMaster()
{
if ((masteruuid_ready == true) && (friendslist_ready == true) && (started_friendship_hug == false))
{
started_friendship_hug = 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);
if (Client.Friends.FriendList.ContainsKey(master_uuid) == false)
{
CommandsInterface.Call("IM", String.Join("~#~", new string[] { myconfig.master, "Hello master, I am sending you a friend request now!" }));
CommandsInterface.Call("FriendRequest", myconfig.master, Client.Self.AgentID);
}
else
{
CommandsInterface.Call("FriendFullPerms", String.Join("~#~", new string[] { myconfig.master, "true" }), Client.Self.AgentID);
}
}
}
}
protected override void BotStartHandler()
{
base.BotStartHandler();
friendslist_ready = false;
if (reconnect == false)
{
Client.Friends.friendsListReady += friendsListReady;
}
}
protected override void FoundMasterAvatar()
{
if (helpers.notempty(myconfig.master) == true)
{
masteruuid_ready = true;
TryHugMaster();
}
}
protected override void FriendshipResponse(object o,FriendshipResponseEventArgs E)
{
base.FriendshipResponse(o, E);