allow bot to appear in group logs

This commit is contained in:
Zontreck 2020-04-20 16:37:36 -07:00
parent 004ffd7d5a
commit c390fd0b35
6 changed files with 105 additions and 10 deletions

View file

@ -6,7 +6,7 @@ using System.Reflection;
[assembly: AssemblyCompany("ZNI")] [assembly: AssemblyCompany("ZNI")]
[assembly: AssemblyAlgorithmId(System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5)] [assembly: AssemblyAlgorithmId(System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5)]
[assembly: AssemblyCopyright("© 2020 Tara Piccari")] [assembly: AssemblyCopyright("© 2020 Tara Piccari")]
[assembly: AssemblyFileVersion("5.587")] [assembly: AssemblyFileVersion("5.592")]
[assembly: AssemblyDescription("Second Life Bot - BotCore5")] [assembly: AssemblyDescription("Second Life Bot - BotCore5")]
@ -15,7 +15,7 @@ namespace Bot.Assemble
public class ASMInfo public class ASMInfo
{ {
public static string BotName = "ZBotCore"; public static string BotName = "ZBotCore";
public static double BotVer = 5.587; public static double BotVer = 5.592;
public static string GitPassword public static string GitPassword
{ {
get get

View file

@ -6,6 +6,11 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SignAssembly>false</SignAssembly> <SignAssembly>false</SignAssembly>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release;DebPub</Configurations>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebPub|AnyCPU'">
<OutputPath>bin\debpub</OutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View file

@ -123,5 +123,26 @@ namespace Bot.CommandSystem
MHE(source, client, "secondlife:///app/agent/" + MainConfiguration.Instance.BotAdmins.ElementAt(i).Key.ToString() + "/about [" + MainConfiguration.Instance.BotAdmins.ElementAt(i).Value.ToString() + "] " + MainConfiguration.Instance.BotAdmins.ElementAt(i).Key.ToString()); MHE(source, client, "secondlife:///app/agent/" + MainConfiguration.Instance.BotAdmins.ElementAt(i).Key.ToString() + "/about [" + MainConfiguration.Instance.BotAdmins.ElementAt(i).Value.ToString() + "] " + MainConfiguration.Instance.BotAdmins.ElementAt(i).Key.ToString());
} }
} }
[CommandGroup("terminate_bot", 5, 0, "", MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_CONSOLE_INFO | MessageHandler.Destinations.DEST_DISCORD)]
public void PerformExit(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName)
{
MHE(source, client, "Bot exit initiated.");
MHE(MessageHandler.Destinations.DEST_ACTION, UUID.Zero, "{'type':'exit'}");
}
// !!help
[CommandGroup("!help", 0, 0, "Prints the entire help registry", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_GROUP | MessageHandler.Destinations.DEST_CONSOLE_INFO)]
[CommandGroup("bot.help", 0, 0, "Alias to !help", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_GROUP)]
public void PrintAllHelp(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName)
{
MHE(source, client, "All commands viewable at: https://zontreck.dev:35591/help");
}
// !help "command"
[CommandGroup("help", 0, 1, "Prints help for one command", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_GROUP | MessageHandler.Destinations.DEST_CONSOLE_INFO)]
public void PrintHelp(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName)
{
registry.PrintHelp(source, additionalArgs[0], client);
}
} }
} }

View file

@ -78,8 +78,15 @@ namespace Bot.CommandSystem
string GroupName = client.Groups.GroupName2KeyCache[fromID]; string GroupName = client.Groups.GroupName2KeyCache[fromID];
GroupLog.Instance.WriteLogEntry(GroupName, "secondlife:///app/agent/" + agentKey.ToString() + "/about (" + agentName + ") : " + request); GroupLog.Instance.WriteLogEntry(GroupName, "secondlife:///app/agent/" + agentKey.ToString() + "/about (" + agentName + ") : " + request);
if (agentKey == client.Self.AgentID) return false;
}
else {
agentKey = fromID;
if (agentKey == client.Self.AgentID) return false;
} }
else { agentKey = fromID; }
if (request.Substring(0, 1) != "!") if (request.Substring(0, 1) != "!")
{ {

View file

@ -4,8 +4,8 @@ using System.Text;
using System.IO; using System.IO;
using Bot.CommandSystem; using Bot.CommandSystem;
using OpenMetaverse; using OpenMetaverse;
using Bot.WebHookServer;
using System.Collections.Specialized;
namespace Bot namespace Bot
{ {
@ -53,7 +53,7 @@ namespace Bot
private static readonly object _fileRead = new object(); private static readonly object _fileRead = new object();
[CommandGroupMaster("Logging")] [CommandGroupMaster("Logging")]
[CommandGroup("search_log", 5, 2, "search_log [groupName] [search_term] - Searches for the search term in all logs relating to the group name (Use a underscore to show where spaces are!). The search term may also include the pipe (|) delimiter to include more than 1 word.", Bot.MessageHandler.Destinations.DEST_AGENT | Bot.MessageHandler.Destinations.DEST_LOCAL)] [CommandGroup("search_log", 5, 2, "search_log [groupName] [search_term] - Searches for the search term in all logs relating to the group name (Use a underscore to show where spaces are!). The search term may also include the pipe (|) delimiter to include more than 1 word.", Bot.MessageHandler.Destinations.DEST_AGENT | Bot.MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_GROUP | MessageHandler.Destinations.DEST_DISCORD)]
public void search_log(UUID client, int level, GridClient grid, string[] additionalArgs, public void search_log(UUID client, int level, GridClient grid, string[] additionalArgs,
MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source,
CommandRegistry registry, UUID agentKey, string agentName) CommandRegistry registry, UUID agentKey, string agentName)
@ -92,5 +92,68 @@ namespace Bot
MHE(source, client, ".\n \n[Search Completed]"); MHE(source, client, ".\n \n[Search Completed]");
} }
[WebhookAttribs("/viewlog/%", HTTPMethod = "GET")]
public WebhookRegistry.HTTPResponseData View_Log(List<string> arguments, string body, string method, NameValueCollection headers)
{
WebhookRegistry.HTTPResponseData rd = new WebhookRegistry.HTTPResponseData();
string FinalOutput = "";
lock (_fileRead)
{
try
{
foreach (string s in File.ReadLines("GroupChatLogs/" + Uri.UnescapeDataString(arguments[0]) + ".log"))
{
string tmp = s;
string[] Ltmp = tmp.Split(' ');
tmp = "";
foreach (string K in Ltmp)
{
if (K.StartsWith("secondlife://"))
{
// DO NOT ADD TO OUTPUT
}
else
{
tmp += K + " ";
}
}
FinalOutput += tmp + "<br/>";
}
rd.Status = 200;
rd.ReplyString = FinalOutput;
rd.ReturnContentType = "text/html";
}
catch (Exception e)
{
rd.Status = 418;
rd.ReplyString = "You burned... the tea";
}
}
return rd;
}
[WebhookAttribs("/logs", HTTPMethod = "GET")]
public WebhookRegistry.HTTPResponseData List_Logs(List<string> arguments, string body, string method, NameValueCollection headers)
{
WebhookRegistry.HTTPResponseData hrd = new WebhookRegistry.HTTPResponseData();
hrd.Status = 200;
hrd.ReplyString = "<center><h2>Group Chat Logs</h2></center>";
DirectoryInfo di = new DirectoryInfo("GroupChatLogs");
foreach (FileInfo fi in di.GetFiles())
{
hrd.ReplyString += "<br/><a href='/viewlog/" + Path.GetFileNameWithoutExtension(fi.Name) + "'> " + fi.Name + "</a>";
}
hrd.ReturnContentType = "text/html";
return hrd;
}
} }
} }

View file

@ -644,7 +644,7 @@ namespace Bot
*/ */
} }
[CommandGroup("load_dll", 5, 1, "load_dll [DLL_Name] - Loads a DLL and searches for entry points", MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_AGENT)] [CommandGroup("load_dll", 5, 1, "load_dll [DLL_Name] - Loads a DLL and searches for entry points", MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_CONSOLE_INFO)]
public void load_DLL(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName) public void load_DLL(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName)
{ {
// Load DLL // Load DLL
@ -661,7 +661,7 @@ namespace Bot
} }
[CommandGroup("unload_dll", 5, 1, "unload_dll [DLL_Name] - Prevents DLL from reloading at next reboot", MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_AGENT)] [CommandGroup("unload_dll", 5, 1, "unload_dll [DLL_Name] - Prevents DLL from reloading at next reboot", MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_CONSOLE_INFO)]
public void unload_DLL(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName) public void unload_DLL(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName)
{ {
// Load DLL // Load DLL
@ -674,7 +674,7 @@ namespace Bot
cfg.Save(); cfg.Save();
} }
[CommandGroup("assign", 75, 1, "assign [DLL Name] - Sets the active DLL", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL)] [CommandGroup("assign", 75, 1, "assign [DLL Name] - Sets the active DLL", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_CONSOLE_INFO)]
public void SetActiveProgram(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName) public void SetActiveProgram(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName)
{ {
MHE(MessageHandler.Destinations.DEST_ACTION, UUID.Zero, "{\"type\":\"assignProgram\",\"newProgram\":\"" + additionalArgs[0] + "\"}"); MHE(MessageHandler.Destinations.DEST_ACTION, UUID.Zero, "{\"type\":\"assignProgram\",\"newProgram\":\"" + additionalArgs[0] + "\"}");
@ -735,7 +735,6 @@ namespace Bot
private static void onChatRecv(object sender, ChatEventArgs e) private static void onChatRecv(object sender, ChatEventArgs e)
{ {
if (e.Message == "" || e.Message == "typing") return; if (e.Message == "" || e.Message == "typing") return;
if (e.SourceID == client.Self.AgentID) return;
string eMe = e.Message; string eMe = e.Message;
Dictionary<string, string> dstuf = new Dictionary<string, string>(); Dictionary<string, string> dstuf = new Dictionary<string, string>();