From 2477e4bb8846d97feeebb6d91a63906326e87a99 Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Wed, 16 Mar 2022 14:15:42 +0000 Subject: [PATCH] starting finaly --- BetterSecondBot.sln | 25 ++++- BetterSecondbot/Cli.cs | 104 +++++++++---------- SecondBotEvents/EventsSecondBot.cs | 47 +++++++++ SecondBotEvents/SecondBotEvents.csproj | 9 ++ SecondBotEvents/Services/HTTP/http.cs | 16 +++ SecondBotEvents/Services/HTTP/http_config.cs | 12 +++ 6 files changed, 159 insertions(+), 54 deletions(-) create mode 100644 SecondBotEvents/EventsSecondBot.cs create mode 100644 SecondBotEvents/SecondBotEvents.csproj create mode 100644 SecondBotEvents/Services/HTTP/http.cs create mode 100644 SecondBotEvents/Services/HTTP/http_config.cs diff --git a/BetterSecondBot.sln b/BetterSecondBot.sln index 13b11eb..7ff6317 100644 --- a/BetterSecondBot.sln +++ b/BetterSecondBot.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30907.101 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32228.430 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Secondbot", "Secondbot", "{4388BA41-F3FC-4A0E-AA00-50E9ED45A027}" EndProject @@ -27,6 +27,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibreMetaverse.StructuredDa EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibreMetaverse.Types", "LibreMetaverse.Types\LibreMetaverse.Types.csproj", "{B37B02AD-0000-0000-0000-000000000000}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecondBotEvents", "SecondBotEvents\SecondBotEvents.csproj", "{571AB1AF-4C74-4C37-AC5B-9B63383AC791}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -148,6 +150,24 @@ Global {B37B02AD-0000-0000-0000-000000000000}.Release|x64.Build.0 = Release|x64 {B37B02AD-0000-0000-0000-000000000000}.Release|x86.ActiveCfg = Release|x86 {B37B02AD-0000-0000-0000-000000000000}.Release|x86.Build.0 = Release|x86 + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Debug|Any CPU.Build.0 = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Debug|x64.ActiveCfg = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Debug|x64.Build.0 = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Debug|x86.ActiveCfg = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Debug|x86.Build.0 = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.DockerBuild|Any CPU.ActiveCfg = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.DockerBuild|Any CPU.Build.0 = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.DockerBuild|x64.ActiveCfg = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.DockerBuild|x64.Build.0 = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.DockerBuild|x86.ActiveCfg = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.DockerBuild|x86.Build.0 = Debug|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Release|Any CPU.ActiveCfg = Release|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Release|Any CPU.Build.0 = Release|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Release|x64.ActiveCfg = Release|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Release|x64.Build.0 = Release|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Release|x86.ActiveCfg = Release|Any CPU + {571AB1AF-4C74-4C37-AC5B-9B63383AC791}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -159,6 +179,7 @@ Global {27C70F3A-0000-0000-0000-000000000000} = {E9B97D05-D5FB-4CA9-99C3-839248621C21} {89D7A3E5-0000-0000-0000-000000000000} = {E9B97D05-D5FB-4CA9-99C3-839248621C21} {B37B02AD-0000-0000-0000-000000000000} = {E9B97D05-D5FB-4CA9-99C3-839248621C21} + {571AB1AF-4C74-4C37-AC5B-9B63383AC791} = {4388BA41-F3FC-4A0E-AA00-50E9ED45A027} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {EC43F382-FAF2-49CC-8E23-5DDF87592DFA} diff --git a/BetterSecondbot/Cli.cs b/BetterSecondbot/Cli.cs index c73a226..3f3d7cb 100644 --- a/BetterSecondbot/Cli.cs +++ b/BetterSecondbot/Cli.cs @@ -5,12 +5,12 @@ using BetterSecondBotShared.Static; using BetterSecondBot.bottypes; using System.Threading; using static BetterSecondBot.Program; -using BetterSecondbot.BetterAtHome; -using BetterSecondbot.DataStorage; -using BetterSecondbot.Tracking; -using BetterSecondbot.Adverts; -using BetterSecondbot.OnEvents; - +using BetterSecondbot.BetterAtHome; +using BetterSecondbot.DataStorage; +using BetterSecondbot.Tracking; +using BetterSecondbot.Adverts; +using BetterSecondbot.OnEvents; + namespace BetterSecondBot { public class Cli @@ -25,39 +25,39 @@ namespace BetterSecondBot protected onevent Events; protected Datastorage datastorage; - public SecondBot getBot() - { - return Bot; + public SecondBot getBot() + { + return Bot; } - public bool BotReady() - { - if (getBot() == null) - { - return false; - } - else if (getBot().GetClient == null) - { - return false; - } - else if (getBot().GetClient.Network == null) - { - return false; - } - else if (getBot().GetClient.Network.Connected == false) - { - return false; - } - else if (getBot().GetClient.Network.CurrentSim == null) - { - return false; - } - return getBot()._AllowActions; + public bool BotReady() + { + if (getBot() == null) + { + return false; + } + else if (getBot().GetClient == null) + { + return false; + } + else if (getBot().GetClient.Network == null) + { + return false; + } + else if (getBot().GetClient.Network.Connected == false) + { + return false; + } + else if (getBot().GetClient.Network.CurrentSim == null) + { + return false; + } + return getBot()._AllowActions; } - public string getFolderUsed() - { - return use_folder; + public string getFolderUsed() + { + return use_folder; } protected void keep_alive() @@ -85,21 +85,21 @@ namespace BetterSecondBot exitBot = true; } - public void attachEventListenerObjects(JsonConfig Config, bool as_docker) - { - LogFormater.Info("HTTP service requested:" + Config.Http_Enable.ToString()); - if (Config.Http_Enable == true) - { - new Thread(() => - { - new HttpAsService(Bot, Config, as_docker); - }).Start(); - } - Adverts = new advertsService(this, as_docker); - Events = new onevent(this, as_docker); - betterAtHomeService = new BetterAtHome(this, Config); - betterTracking = new BetterTracking(this); - datastorage = new Datastorage(this); + public void attachEventListenerObjects(JsonConfig Config, bool as_docker) + { + LogFormater.Info("HTTP service requested:" + Config.Http_Enable.ToString()); + if (Config.Http_Enable == true) + { + new Thread(() => + { + new HttpAsService(Bot, Config, as_docker); + }).Start(); + } + Adverts = new advertsService(this, as_docker); + Events = new onevent(this, as_docker); + betterAtHomeService = new BetterAtHome(this, Config); + betterTracking = new BetterTracking(this); + datastorage = new Datastorage(this); } public Cli(JsonConfig Config, bool as_docker, bool use_self_keep_alive, string loadingFromFolder) { @@ -110,13 +110,13 @@ namespace BetterSecondBot { Bot = new SecondBot(); Bot.setFolder(use_folder); - Bot.Setup(Config, AssemblyInfo.GetGitHash()); + Bot.Setup(Config, AssemblyInfo.GetGitHash()); if (as_docker == true) { Bot.AsDocker(); } - + Bot.Start(false); attachEventListenerObjects(Config, as_docker); diff --git a/SecondBotEvents/EventsSecondBot.cs b/SecondBotEvents/EventsSecondBot.cs new file mode 100644 index 0000000..98439ba --- /dev/null +++ b/SecondBotEvents/EventsSecondBot.cs @@ -0,0 +1,47 @@ +using SecondBotEvents.Services; +using System; +using System.Linq; +using System.Reflection; +using System.Threading; + +namespace SecondBotEvents +{ + internal class Startup + { + static void Main(string[] args) + { + Console.WriteLine("Welcome to Secondbot [Events build] version: " + AssemblyInfo.GetGitHash()); + EventsSecondBot worker = new EventsSecondBot(); + + while(worker.exit() == false) + { + Thread.Sleep(1000); + } + } + } + + internal class EventsSecondBot + { + protected http HttpService = null; + public EventsSecondBot() + { + HttpService = new http(this); + } + public bool exit() + { + return false; + } + } + + public static class AssemblyInfo + { + /// Gets the git hash value from the assembly + /// or null if it cannot be found. + public static string GetGitHash() + { + var asm = typeof(AssemblyInfo).Assembly; + var attrs = asm.GetCustomAttributes(); + return attrs.FirstOrDefault(a => a.Key == "GitHash")?.Value; + } + } +} diff --git a/SecondBotEvents/SecondBotEvents.csproj b/SecondBotEvents/SecondBotEvents.csproj new file mode 100644 index 0000000..08a0556 --- /dev/null +++ b/SecondBotEvents/SecondBotEvents.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp3.1 + SecondBotEvents.Startup + + + diff --git a/SecondBotEvents/Services/HTTP/http.cs b/SecondBotEvents/Services/HTTP/http.cs new file mode 100644 index 0000000..95a9f83 --- /dev/null +++ b/SecondBotEvents/Services/HTTP/http.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SecondBotEvents.Services +{ + internal class http + { + protected EventsSecondBot master; + public http(EventsSecondBot setMaster) + { + master = setMaster; + Console.WriteLine("Starting HTTP service"); + } + } +} diff --git a/SecondBotEvents/Services/HTTP/http_config.cs b/SecondBotEvents/Services/HTTP/http_config.cs new file mode 100644 index 0000000..bbafe8b --- /dev/null +++ b/SecondBotEvents/Services/HTTP/http_config.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SecondBotEvents.Services.HTTP +{ + public class http_config + { + public int port = 8080; + public bool enabled = false; + } +}