This commit is contained in:
Madpeter 2023-07-25 20:43:16 +01:00
parent 1ebf6725d4
commit 45fdca1896
15 changed files with 132 additions and 66 deletions

View file

@ -278,6 +278,34 @@ namespace SecondBotEvents.Commands
return BasicReply(reply.ToString(), new [] { item }); return BasicReply(reply.ToString(), new [] { item });
} }
[About("sends a item to an avatar via a path")]
[ReturnHints("ok")]
[ReturnHints("Failed")]
[ReturnHints("Invaild avatar uuid")]
[ReturnHints("Unable to find item")]
[ArgHints("path", "item name and path example: Notecard/sendme or Objects/DemoItem")]
[ArgHints("avatar", "a UUID or Firstname Lastname")]
public object SendItemByPath(string path, string avatar)
{
ProcessAvatar(avatar);
if (avataruuid == UUID.Zero)
{
return Failure("Invaild avatar uuid", new[] { path, avatar });
}
UUID targetitem = GetClient().Inventory.FindObjectByPath(GetClient().Inventory.Store.RootFolder.UUID, GetClient().Self.AgentID, path, (3 * 1000));
if(targetitem == UUID.Zero)
{
return Failure("Unable to find item via path", new[] { path, avatar });
}
InventoryItem itm = GetClient().Inventory.FetchItem(targetitem, GetClient().Self.AgentID, (3 * 1000));
if (itm == null)
{
return Failure("Unable to find item with found uuid", new[] { path, avatar });
}
GetClient().Inventory.GiveItem(itm.UUID, itm.Name, itm.AssetType, avataruuid, false);
return BasicReply("ok", new[] { path, avatar });
}
[About("sends a item to an avatar")] [About("sends a item to an avatar")]
[ReturnHints("ok")] [ReturnHints("ok")]
[ReturnHints("Failed")] [ReturnHints("Failed")]
@ -321,7 +349,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Invaild avatar uuid", new [] { folder, avatar }); return Failure("Invaild avatar uuid", new [] { folder, avatar });
} }
if (UUID.TryParse(folder, out UUID targetfolder) == true) if (UUID.TryParse(folder, out UUID targetfolder) == false)
{ {
return Failure("Invaild folder uuid", new [] { folder, avatar }); return Failure("Invaild folder uuid", new [] { folder, avatar });
} }

View file

@ -106,6 +106,7 @@ namespace SecondBotEvents.Commands
[ReturnHints("ok")] [ReturnHints("ok")]
public object Stand() public object Stand()
{ {
master.HomeboundService.MarkStandup();
GetClient().Self.Stand(); GetClient().Self.Stand();
return BasicReply("ok"); return BasicReply("ok");
} }

View file

@ -26,7 +26,7 @@ namespace SecondBotEvents.Config
public int GetRelayCount() public int GetRelayCount()
{ {
return ReadSettingAsInt("count", 1); return ReadSettingAsInt("count", 0);
} }
public bool GetRelayEnabled(int relayID) public bool GetRelayEnabled(int relayID)

View file

@ -155,7 +155,7 @@ namespace SecondBotEvents
RegisterService("CustomCommandsService"); RegisterService("CustomCommandsService");
if (BotClient.IsLoaded() == false) if (BotClient.IsLoaded() == false)
{ {
Console.WriteLine("Config is not loaded :("); LogFormater.Info("Config is not loaded :(");
exitNow = true; exitNow = true;
return; return;
} }

View file

@ -36,7 +36,7 @@ namespace SecondBotEvents.Services
public override void Start() public override void Start()
{ {
running = true; running = true;
Console.WriteLine("Client service [Starting]"); LogFormater.Info("Client service [Starting]");
AutoRestartLoginTimer = new Timer(); AutoRestartLoginTimer = new Timer();
AutoRestartLoginTimer.Interval = 30 * 1000; AutoRestartLoginTimer.Interval = 30 * 1000;
AutoRestartLoginTimer.AutoReset = false; AutoRestartLoginTimer.AutoReset = false;
@ -47,7 +47,7 @@ namespace SecondBotEvents.Services
{ {
if(running == true) if(running == true)
{ {
Console.WriteLine("Client service [Stopping]"); LogFormater.Info("Client service [Stopping]");
} }
running = false; running = false;
AutoRestartLoginTimer.Stop(); AutoRestartLoginTimer.Stop();
@ -56,35 +56,35 @@ namespace SecondBotEvents.Services
protected void BotLoggedOut(object o, LoggedOutEventArgs e) protected void BotLoggedOut(object o, LoggedOutEventArgs e)
{ {
Console.WriteLine("Client service ~ Logged out"); LogFormater.Info("Client service ~ Logged out");
} }
protected void BotSimConnected(object o, SimConnectedEventArgs e) protected void BotSimConnected(object o, SimConnectedEventArgs e)
{ {
AutoRestartLoginTimer.Stop(); AutoRestartLoginTimer.Stop();
Console.WriteLine("Client service ~ Connected to sim: "+e.Simulator.Name); LogFormater.Info("Client service ~ Connected to sim: "+e.Simulator.Name);
} }
protected void BotSimDisconnected(object o, SimDisconnectedEventArgs e) protected void BotSimDisconnected(object o, SimDisconnectedEventArgs e)
{ {
Console.WriteLine("Client service ~ Disconnected from sim: " + e.Simulator.Name); LogFormater.Info("Client service ~ Disconnected from sim: " + e.Simulator.Name);
} }
protected void BotDisconnected(object o, DisconnectedEventArgs e) protected void BotDisconnected(object o, DisconnectedEventArgs e)
{ {
Console.WriteLine("Client service ~ Network disconnected: " + e.Message); LogFormater.Info("Client service ~ Network disconnected: " + e.Message);
} }
protected void BotLoginStatus(object o, LoginProgressEventArgs e) protected void BotLoginStatus(object o, LoginProgressEventArgs e)
{ {
if(e.FailReason != "") if(e.FailReason != "")
{ {
Console.WriteLine("Client service ~ {FAILED} Login status: " + e.FailReason.ToString()); LogFormater.Info("Client service ~ {FAILED} Login status: " + e.FailReason.ToString());
client.Network.Logout(); client.Network.Logout();
ResetClient(); ResetClient();
return; return;
} }
Console.WriteLine("Client service ~ Login status: " + e.Status.ToString()); LogFormater.Info("Client service ~ Login status: " + e.Status.ToString());
} }
public void SendIM(UUID avatar, string message) public void SendIM(UUID avatar, string message)
{ {

View file

@ -309,7 +309,7 @@ namespace SecondBotEvents.Services
protected void BotClientRestart(object o, BotClientNotice e) protected void BotClientRestart(object o, BotClientNotice e)
{ {
acceptNewCommands = false; acceptNewCommands = false;
Console.WriteLine("Commands service [Attached to new client]"); LogFormater.Info("Commands service [Attached to new client]");
GetClient().Network.LoggedOut += BotLoggedOut; GetClient().Network.LoggedOut += BotLoggedOut;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
} }
@ -317,7 +317,7 @@ namespace SecondBotEvents.Services
protected void BotLoggedOut(object o, LoggedOutEventArgs e) protected void BotLoggedOut(object o, LoggedOutEventArgs e)
{ {
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
Console.WriteLine("Commands service [Waiting for connect]"); LogFormater.Info("Commands service [Waiting for connect]");
} }
protected void BotLoggedIn(object o, SimConnectedEventArgs e) protected void BotLoggedIn(object o, SimConnectedEventArgs e)
@ -332,7 +332,7 @@ namespace SecondBotEvents.Services
} }
} }
acceptNewCommands = true; acceptNewCommands = true;
Console.WriteLine("Commands service [accepting IM commands]"); LogFormater.Info("Commands service [accepting IM commands]");
} }
} }

View file

@ -85,7 +85,7 @@ namespace SecondBotEvents.Services
protected void BotClientRestart(object o, BotClientNotice e) protected void BotClientRestart(object o, BotClientNotice e)
{ {
Console.WriteLine("CustomCommands service [Attached to new client]"); LogFormater.Info("CustomCommands service [Attached to new client]");
GetClient().Network.LoggedOut += BotLoggedOut; GetClient().Network.LoggedOut += BotLoggedOut;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
} }
@ -93,7 +93,7 @@ namespace SecondBotEvents.Services
protected void BotLoggedOut(object o, LoggedOutEventArgs e) protected void BotLoggedOut(object o, LoggedOutEventArgs e)
{ {
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
Console.WriteLine("CustomCommands service [waiting for new client]"); LogFormater.Info("CustomCommands service [waiting for new client]");
} }
protected void BotLoggedIn(object o, SimConnectedEventArgs e) protected void BotLoggedIn(object o, SimConnectedEventArgs e)

View file

@ -790,7 +790,7 @@ namespace SecondBotEvents.Services
protected void BotClientRestart(object o, BotClientNotice e) protected void BotClientRestart(object o, BotClientNotice e)
{ {
botConnected = false; botConnected = false;
Console.WriteLine("DataStore Service [Attached to new client]"); LogFormater.Info("DataStore Service [Attached to new client]");
GetClient().Network.LoggedOut += BotLoggedOut; GetClient().Network.LoggedOut += BotLoggedOut;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
} }
@ -799,7 +799,7 @@ namespace SecondBotEvents.Services
{ {
botConnected = false; botConnected = false;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
Console.WriteLine("DataStore Service [Standby]"); LogFormater.Info("DataStore Service [Standby]");
} }
protected void GroupRoles(object o, GroupRolesDataReplyEventArgs e) protected void GroupRoles(object o, GroupRolesDataReplyEventArgs e)
@ -877,7 +877,7 @@ namespace SecondBotEvents.Services
GetClient().Estate.EstateBansReply += EstateBans; GetClient().Estate.EstateBansReply += EstateBans;
GetClient().Groups.RequestCurrentGroups(); GetClient().Groups.RequestCurrentGroups();
botConnected = true; botConnected = true;
Console.WriteLine("DataStore Service [Active]"); LogFormater.Info("DataStore Service [Active]");
GetAvatarName(GetClient().Self.AgentID); GetAvatarName(GetClient().Self.AgentID);
} }
readonly string[] hard_blocked_agents = new[] { "secondlife", "second life" }; readonly string[] hard_blocked_agents = new[] { "secondlife", "second life" };
@ -1045,14 +1045,14 @@ namespace SecondBotEvents.Services
Stop(); Stop();
running = true; running = true;
master.BotClientNoticeEvent += BotClientRestart; master.BotClientNoticeEvent += BotClientRestart;
Console.WriteLine("DataStore Service [Starting]"); LogFormater.Info("DataStore Service [Starting]");
} }
public override void Stop() public override void Stop()
{ {
if(running == true) if(running == true)
{ {
Console.WriteLine("DataStore Service [Stopping]"); LogFormater.Info("DataStore Service [Stopping]");
} }
running = false; running = false;
Reset(); Reset();

View file

@ -194,7 +194,7 @@ namespace SecondBotEvents.Services
protected void BotClientRestart(object o, BotClientNotice e) protected void BotClientRestart(object o, BotClientNotice e)
{ {
Console.WriteLine("Dialog service [Attached to new client]"); LogFormater.Info("Dialog service [Attached to new client]");
GetClient().Network.LoggedOut += BotLoggedOut; GetClient().Network.LoggedOut += BotLoggedOut;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
} }
@ -202,7 +202,7 @@ namespace SecondBotEvents.Services
protected void BotLoggedOut(object o, LoggedOutEventArgs e) protected void BotLoggedOut(object o, LoggedOutEventArgs e)
{ {
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
Console.WriteLine("Dialog service [waiting for new client]"); LogFormater.Info("Dialog service [waiting for new client]");
if (GetClient() != null) if (GetClient() != null)
{ {
GetClient().Self.ScriptDialog -= DialogWindowEvent; GetClient().Self.ScriptDialog -= DialogWindowEvent;

View file

@ -58,14 +58,14 @@ namespace SecondBotEvents.Services
protected Task DiscordClientLoggedOut() protected Task DiscordClientLoggedOut()
{ {
Console.WriteLine("Discord service [Logged out]"); LogFormater.Info("Discord service [Logged out]");
DiscordIsReady = false; DiscordIsReady = false;
return Task.CompletedTask; return Task.CompletedTask;
} }
protected Task DicordClientLoggedin() protected Task DicordClientLoggedin()
{ {
Console.WriteLine("Discord service [Logged in]"); LogFormater.Info("Discord service [Logged in]");
DiscordDoingLogin = false; DiscordDoingLogin = false;
_ = DiscordClient.StartAsync(); _ = DiscordClient.StartAsync();
return Task.CompletedTask; return Task.CompletedTask;
@ -73,7 +73,7 @@ namespace SecondBotEvents.Services
protected Task DiscordClientReady() protected Task DiscordClientReady()
{ {
Console.WriteLine("Discord service [Ready]"); LogFormater.Info("Discord service [Ready]");
DiscordIsReady = true; DiscordIsReady = true;
DoServerChannelSetup(); DoServerChannelSetup();
return Task.CompletedTask; return Task.CompletedTask;
@ -358,7 +358,7 @@ namespace SecondBotEvents.Services
} }
if (message.Author.Id != DiscordClient.CurrentUser.Id) if (message.Author.Id != DiscordClient.CurrentUser.Id)
{ {
GetClient().Self.Chat(message.Author.Username + ": " + message.CleanContent, 0, ChatType.Normal); GetClient().Self.Chat(message.CleanContent, 0, ChatType.Normal);
_ = message.DeleteAsync(); _ = message.DeleteAsync();
} }
} }
@ -380,7 +380,7 @@ namespace SecondBotEvents.Services
protected Task DiscordDisconnected(Exception e) protected Task DiscordDisconnected(Exception e)
{ {
Console.WriteLine("Discord service [Disconnected: "+e.Message+"]"); LogFormater.Info("Discord service [Disconnected: "+e.Message+"]");
DiscordIsReady = false; DiscordIsReady = false;
if(DiscordDisconnectExpected == false) if(DiscordDisconnectExpected == false)
{ {
@ -407,21 +407,25 @@ namespace SecondBotEvents.Services
running = true; running = true;
if (myConfig.GetEnabled() == false) if (myConfig.GetEnabled() == false)
{ {
Console.WriteLine("Discord service [Disabled]"); LogFormater.Info("Discord service [Disabled]");
return; return;
} }
if(myConfig.GetServerID() == 0) if(myConfig.GetServerID() == 0)
{ {
Console.WriteLine("Discord service [Invaild server id]"); LogFormater.Info("Discord service [Invaild server id]");
return; return;
} }
DiscordServerChannelsSetup = false; DiscordServerChannelsSetup = false;
DiscordDisconnectExpected = false; DiscordDisconnectExpected = false;
DiscordIsReady = false; DiscordIsReady = false;
Console.WriteLine("Discord service [Starting]"); LogFormater.Info("Discord service [Starting]");
master.SystemStatusMessagesEvent += SystemStatusEvent; master.SystemStatusMessagesEvent += SystemStatusEvent;
master.BotClientNoticeEvent += BotClientRestart; master.BotClientNoticeEvent += BotClientRestart;
DiscordClient = new DiscordSocketClient(); var config = new DiscordSocketConfig()
{
GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.GuildIntegrations | GatewayIntents.MessageContent
};
DiscordClient = new DiscordSocketClient(config);
DiscordClient.Ready += DiscordClientReady; DiscordClient.Ready += DiscordClientReady;
DiscordClient.LoggedOut += DiscordClientLoggedOut; DiscordClient.LoggedOut += DiscordClientLoggedOut;
DiscordClient.LoggedIn += DicordClientLoggedin; DiscordClient.LoggedIn += DicordClientLoggedin;
@ -434,7 +438,7 @@ namespace SecondBotEvents.Services
{ {
if(running == true) if(running == true)
{ {
Console.WriteLine("Discord service [Stopping]"); LogFormater.Info("Discord service [Stopping]");
} }
running = false; running = false;
@ -473,7 +477,7 @@ namespace SecondBotEvents.Services
{ {
if (e.isRestart == false) if (e.isRestart == false)
{ {
Console.WriteLine("Discord service [Avi link]"); LogFormater.Info("Discord service [Avi link]");
AcceptEventsFromSL = false; AcceptEventsFromSL = false;
GetClient().Network.LoggedOut += BotLoggedOut; GetClient().Network.LoggedOut += BotLoggedOut;
GetClient().Self.ChatFromSimulator -= LocalChat; GetClient().Self.ChatFromSimulator -= LocalChat;
@ -491,7 +495,7 @@ namespace SecondBotEvents.Services
GetClient().Self.IM -= BotImMessage; GetClient().Self.IM -= BotImMessage;
GetClient().Groups.CurrentGroups -= GroupCurrent; GetClient().Groups.CurrentGroups -= GroupCurrent;
AcceptEventsFromSL = false; AcceptEventsFromSL = false;
Console.WriteLine("Discord service [Avi link - standby]"); LogFormater.Info("Discord service [Avi link - standby]");
} }
protected void BotImMessage(object o, InstantMessageEventArgs e) protected void BotImMessage(object o, InstantMessageEventArgs e)
@ -536,6 +540,7 @@ namespace SecondBotEvents.Services
protected async void DoServerChannelSetup() protected async void DoServerChannelSetup()
{ {
LogFormater.Info("Setting up channels"); LogFormater.Info("Setting up channels");
LoginEvents();
Dictionary<string, string> WantedTextChannels = new Dictionary<string, string> Dictionary<string, string> WantedTextChannels = new Dictionary<string, string>
{ {
{ "status", StatusPrefill() }, { "status", StatusPrefill() },
@ -830,10 +835,33 @@ namespace SecondBotEvents.Services
{ {
AcceptEventsFromSL = true; AcceptEventsFromSL = true;
GetClient().Network.SimConnected -= BotLoggedIn; GetClient().Network.SimConnected -= BotLoggedIn;
GetClient().Self.IM += BotImMessage; LogFormater.Info("Discord service [Avi link - Active]");
GetClient().Self.ChatFromSimulator += LocalChat; LoginEvents();
GetClient().Groups.CurrentGroups += GroupCurrent; BotCurrentSim(o, e);
Console.WriteLine("Discord service [Avi link - Active]"); }
protected void BotCurrentSim(object o, SimConnectedEventArgs e)
{
if (DiscordIsReady == true)
{
DiscordClient.SetGameAsync(e.Simulator.Name, null, ActivityType.Playing);
}
}
protected void LoginEvents()
{
if((AcceptEventsFromSL == true) && (DiscordIsReady == true))
{
GetClient().Self.IM += BotImMessage;
GetClient().Network.SimConnected -= BotCurrentSim;
GetClient().Self.ChatFromSimulator += LocalChat;
GetClient().Groups.CurrentGroups += GroupCurrent;
GetClient().Groups.RequestCurrentGroups();
}
else if(DiscordIsReady == true)
{
DiscordClient.SetGameAsync("Waiting for login", null, ActivityType.Listening);
}
} }
#region discord helper functions #region discord helper functions

View file

@ -60,7 +60,7 @@ namespace SecondBotEvents.Services
protected void BotClientRestart(object o, BotClientNotice e) protected void BotClientRestart(object o, BotClientNotice e)
{ {
Console.WriteLine("Events service [Attached to new client]"); LogFormater.Info("Events service [Attached to new client]");
GetClient().Network.LoggedOut += BotLoggedOut; GetClient().Network.LoggedOut += BotLoggedOut;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
} }
@ -68,7 +68,7 @@ namespace SecondBotEvents.Services
protected void BotLoggedOut(object o, LoggedOutEventArgs e) protected void BotLoggedOut(object o, LoggedOutEventArgs e)
{ {
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
Console.WriteLine("Events service [Bot commands disabled]"); LogFormater.Info("Events service [Bot commands disabled]");
removeEvents(); removeEvents();
} }
@ -340,7 +340,7 @@ namespace SecondBotEvents.Services
{ {
if (myConfig.GetEnabled() == false) if (myConfig.GetEnabled() == false)
{ {
Console.WriteLine("Events service [Disabled]"); LogFormater.Info("Events service [Disabled]");
return; return;
} }
Stop(); Stop();

View file

@ -20,12 +20,18 @@ namespace SecondBotEvents.Services
protected long lastGotoAction = 0; protected long lastGotoAction = 0;
protected bool softDisable = false; protected bool softDisable = false;
protected bool closeToHome = false; protected bool closeToHome = false;
protected bool softDisableSit = false;
public void MarkTeleport() public void MarkTeleport()
{ {
softDisable = true; softDisable = true;
} }
public void MarkStandup()
{
softDisableSit = true;
}
public HomeboundService(EventsSecondBot setMaster) : base(setMaster) public HomeboundService(EventsSecondBot setMaster) : base(setMaster)
{ {
myConfig = new HomeboundConfig(master.fromEnv, master.fromFolder); myConfig = new HomeboundConfig(master.fromEnv, master.fromFolder);
@ -65,7 +71,10 @@ namespace SecondBotEvents.Services
{ {
if (GetClient().Self.SittingOn == 0) if (GetClient().Self.SittingOn == 0)
{ {
GetClient().Self.RequestSit(sitTarget, Vector3.Zero); if (softDisableSit == false)
{
GetClient().Self.RequestSit(sitTarget, Vector3.Zero);
}
} }
} }
if (myConfig.GetAtHomeSeekLocation() == true) if (myConfig.GetAtHomeSeekLocation() == true)
@ -246,7 +255,7 @@ namespace SecondBotEvents.Services
protected void BotClientRestart(object o, BotClientNotice e) protected void BotClientRestart(object o, BotClientNotice e)
{ {
botConnected = false; botConnected = false;
Console.WriteLine("Homebound Service [Attached to new client]"); LogFormater.Info("Homebound Service [Attached to new client]");
GetClient().Network.LoggedOut += BotLoggedOut; GetClient().Network.LoggedOut += BotLoggedOut;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
GetClient().Self.AlertMessage += BotAlertMessage; GetClient().Self.AlertMessage += BotAlertMessage;
@ -264,12 +273,12 @@ namespace SecondBotEvents.Services
softDisable = false; softDisable = false;
closeToHome = false; closeToHome = false;
lastGotoAction = SecondbotHelpers.UnixTimeNow(); lastGotoAction = SecondbotHelpers.UnixTimeNow();
Console.WriteLine("Homebound Service [Standby]"); LogFormater.Info("Homebound Service [Standby]");
} }
protected void BotLoggedIn(object o, SimConnectedEventArgs e) protected void BotLoggedIn(object o, SimConnectedEventArgs e)
{ {
botConnected = true; botConnected = true;
Console.WriteLine("Homebound Service [Active]"); LogFormater.Info("Homebound Service [Active]");
} }
public override void Start() public override void Start()
@ -281,14 +290,14 @@ namespace SecondBotEvents.Services
Stop(); Stop();
running = true; running = true;
master.BotClientNoticeEvent += BotClientRestart; master.BotClientNoticeEvent += BotClientRestart;
Console.WriteLine("Homebound Service [Starting]"); LogFormater.Info("Homebound Service [Starting]");
} }
public override void Stop() public override void Stop()
{ {
if(running == true) if(running == true)
{ {
Console.WriteLine("Homebound Service [Stopping]"); LogFormater.Info("Homebound Service [Stopping]");
} }
running = false; running = false;
master.BotClientNoticeEvent -= BotClientRestart; master.BotClientNoticeEvent -= BotClientRestart;

View file

@ -22,7 +22,7 @@ namespace SecondBotEvents.Services
myConfig = new HttpConfig(master.fromEnv, master.fromFolder); myConfig = new HttpConfig(master.fromEnv, master.fromFolder);
if (myConfig.GetEnabled() == false) if (myConfig.GetEnabled() == false)
{ {
Console.WriteLine(Status()); LogFormater.Info(Status());
return; return;
} }
} }
@ -57,7 +57,7 @@ namespace SecondBotEvents.Services
protected void BotClientRestart(object o, BotClientNotice e) protected void BotClientRestart(object o, BotClientNotice e)
{ {
acceptBotCommands = false; acceptBotCommands = false;
Console.WriteLine("HTTP service [Attached to new client]"); LogFormater.Info("HTTP service [Attached to new client]");
GetClient().Network.LoggedOut += BotLoggedOut; GetClient().Network.LoggedOut += BotLoggedOut;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
} }
@ -66,7 +66,7 @@ namespace SecondBotEvents.Services
{ {
acceptBotCommands = false; acceptBotCommands = false;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
Console.WriteLine("HTTP service [Bot commands disabled]"); LogFormater.Info("HTTP service [Bot commands disabled]");
} }
protected void BotLoggedIn(object o, SimConnectedEventArgs e) protected void BotLoggedIn(object o, SimConnectedEventArgs e)
@ -80,7 +80,7 @@ namespace SecondBotEvents.Services
{ {
if (myConfig.GetEnabled() == false) if (myConfig.GetEnabled() == false)
{ {
Console.WriteLine("HTTP service [Disabled]"); LogFormater.Info("HTTP service [Disabled]");
return; return;
} }
Stop(); Stop();
@ -92,7 +92,7 @@ namespace SecondBotEvents.Services
{ {
if(running == true) if(running == true)
{ {
Console.WriteLine("HTTP service [Stopping]"); LogFormater.Info("HTTP service [Stopping]");
} }
running = false; running = false;
if (myConfig.GetEnabled() == false) if (myConfig.GetEnabled() == false)
@ -119,7 +119,7 @@ namespace SecondBotEvents.Services
.WithModule(new ActionModule("/", HttpVerbs.Any, ctx => ctx.SendDataAsync(new { Message = "Error" })) .WithModule(new ActionModule("/", HttpVerbs.Any, ctx => ctx.SendDataAsync(new { Message = "Error" }))
); );
HTTPendpoint.RunAsync(); HTTPendpoint.RunAsync();
Console.WriteLine("HTTP service [Enabled] on port "+ myConfig.GetPort().ToString()); LogFormater.Info("HTTP service [Enabled] on port "+ myConfig.GetPort().ToString());
} }
} }

View file

@ -17,7 +17,7 @@ namespace SecondBotEvents.Services
myConfig = new InteractionConfig(master.fromEnv,master.fromFolder); myConfig = new InteractionConfig(master.fromEnv,master.fromFolder);
if (myConfig.GetEnabled() == false) if (myConfig.GetEnabled() == false)
{ {
Console.WriteLine(Status()); LogFormater.Info(Status());
return; return;
} }
} }
@ -68,7 +68,7 @@ namespace SecondBotEvents.Services
protected void BotClientRestart(object o, BotClientNotice e) protected void BotClientRestart(object o, BotClientNotice e)
{ {
botConnected = false; botConnected = false;
Console.WriteLine("Interaction Service [Attached to new client]"); LogFormater.Info("Interaction Service [Attached to new client]");
GetClient().Network.LoggedOut += BotLoggedOut; GetClient().Network.LoggedOut += BotLoggedOut;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
} }
@ -168,7 +168,7 @@ namespace SecondBotEvents.Services
{ {
botConnected = false; botConnected = false;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
Console.WriteLine("Interaction Service [Standby]"); LogFormater.Info("Interaction Service [Standby]");
} }
protected void BotLoggedIn(object o, SimConnectedEventArgs e) protected void BotLoggedIn(object o, SimConnectedEventArgs e)
@ -179,27 +179,27 @@ namespace SecondBotEvents.Services
GetClient().Groups.GroupInvitation += BotGroupInviteOffer; GetClient().Groups.GroupInvitation += BotGroupInviteOffer;
GetClient().Self.IM += BotTeleportOffer; GetClient().Self.IM += BotTeleportOffer;
botConnected = true; botConnected = true;
Console.WriteLine("Interaction Service [Active]"); LogFormater.Info("Interaction Service [Active]");
} }
public override void Start() public override void Start()
{ {
if (myConfig.GetEnabled() == false) if (myConfig.GetEnabled() == false)
{ {
Console.WriteLine("Interaction Service [- Not requested -]"); LogFormater.Info("Interaction Service [- Not requested -]");
return; return;
} }
Stop(); Stop();
running = true; running = true;
master.BotClientNoticeEvent += BotClientRestart; master.BotClientNoticeEvent += BotClientRestart;
Console.WriteLine("Interaction Service [Starting]"); LogFormater.Info("Interaction Service [Starting]");
} }
public override void Stop() public override void Stop()
{ {
if(running == true) if(running == true)
{ {
Console.WriteLine("Interaction Service [Stopping]"); LogFormater.Info("Interaction Service [Stopping]");
} }
running = false; running = false;
if (myConfig.GetEnabled() == false) if (myConfig.GetEnabled() == false)

View file

@ -35,7 +35,7 @@ namespace SecondBotEvents.Services
protected void BotClientRestart(object o, BotClientNotice e) protected void BotClientRestart(object o, BotClientNotice e)
{ {
botConnected = false; botConnected = false;
Console.WriteLine("Relay Service [Attached to new client]"); LogFormater.Info("Relay Service [Attached to new client]");
GetClient().Network.LoggedOut += BotLoggedOut; GetClient().Network.LoggedOut += BotLoggedOut;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
} }
@ -44,7 +44,7 @@ namespace SecondBotEvents.Services
{ {
botConnected = false; botConnected = false;
GetClient().Network.SimConnected += BotLoggedIn; GetClient().Network.SimConnected += BotLoggedIn;
Console.WriteLine("Relay Service [Standby]"); LogFormater.Info("Relay Service [Standby]");
} }
protected void BotLoggedIn(object o, SimConnectedEventArgs e) protected void BotLoggedIn(object o, SimConnectedEventArgs e)
@ -53,7 +53,7 @@ namespace SecondBotEvents.Services
GetClient().Self.IM += BotImMessage; GetClient().Self.IM += BotImMessage;
GetClient().Self.ChatFromSimulator += LocalChat; GetClient().Self.ChatFromSimulator += LocalChat;
botConnected = true; botConnected = true;
Console.WriteLine("Relay Service [Active]"); LogFormater.Info("Relay Service [Active]");
} }
readonly string[] hard_blocked_agents = new[] { "secondlife", "second life" }; readonly string[] hard_blocked_agents = new[] { "secondlife", "second life" };
@ -132,14 +132,14 @@ namespace SecondBotEvents.Services
Stop(); Stop();
running = true; running = true;
master.BotClientNoticeEvent += BotClientRestart; master.BotClientNoticeEvent += BotClientRestart;
Console.WriteLine("Relay Service [Starting]"); LogFormater.Info("Relay Service [Starting]");
} }
public override void Stop() public override void Stop()
{ {
if(running == true) if(running == true)
{ {
Console.WriteLine("Relay Service [Stopping]"); LogFormater.Info("Relay Service [Stopping]");
} }
running = false; running = false;
master.BotClientNoticeEvent -= BotClientRestart; master.BotClientNoticeEvent -= BotClientRestart;