allow bot to appear in group logs
This commit is contained in:
parent
004ffd7d5a
commit
c390fd0b35
6 changed files with 105 additions and 10 deletions
69
GroupLog.cs
69
GroupLog.cs
|
@ -4,8 +4,8 @@ using System.Text;
|
|||
using System.IO;
|
||||
using Bot.CommandSystem;
|
||||
using OpenMetaverse;
|
||||
|
||||
|
||||
using Bot.WebHookServer;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace Bot
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ namespace Bot
|
|||
|
||||
private static readonly object _fileRead = new object();
|
||||
[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,
|
||||
MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source,
|
||||
CommandRegistry registry, UUID agentKey, string agentName)
|
||||
|
@ -92,5 +92,68 @@ namespace Bot
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue