public override string Process(RestBot b, Dictionary<string, string> Parameters)
{
string message;
string subject;
UUID groupUUID = UUID.Zero;
UUID attachmentUUID = UUID.Zero;
GroupNotice notice;
try
{
if ( Parameters.ContainsKey("subject") )
{
subject = Parameters["subject"].ToString().Replace("%20"," ").Replace("+"," ");
}
else
{
return "<error>No notice subject</error>";
}
if ( Parameters.ContainsKey("message") )
{
message = Parameters["message"].ToString().Replace("%20"," ").Replace("+"," ");
}
else
{
return "<error>No notice message</error>";
}
if ( Parameters.ContainsKey("group") )
{
if (! UUID.TryParse(Parameters["group"].ToString().Replace("_"," "), out groupUUID) )
{
return "<error>parsekey group</error>";
}
}
else
{
return "<error>arguments: no group key</error>";
}
if ( Parameters.ContainsKey("attachment") )
{
if (! UUID.TryParse(Parameters["attachment"].ToString().Replace("_"," "), out attachmentUUID) )
{
return "<error>parsekey attachment</error>";
}
}
else
{
// just a warning, attachment can be empty
DebugUtilities.WriteWarning(session + " " + MethodName + " Notice has no attachment (no problem)");
}
DebugUtilities.WriteDebug(session + " " + MethodName + " Attempting to create a notice");
/* This doesn't work as it should!
if (! b.Client.Inventory.Store.Contains(attachmentUUID))
{
DebugUtilities.WriteWarning(session + " " + MethodName + " Item UUID " + attachmentUUID.ToString() + " not found on inventory (are you using an Asset UUID by mistake?)");
attachmentUUID = UUID.Zero;
}
*/
notice = new GroupNotice();
notice.Subject = subject;
notice.Message = message;
notice.AttachmentID = attachmentUUID; // this is the inventory UUID, not the asset UUID
notice.OwnerID = b.Client.Self.AgentID;
b.Client.Groups.SendGroupNotice(groupUUID, notice);
DebugUtilities.WriteDebug(session + " " + MethodName + " Sent Notice from avatar " + notice.OwnerID.ToString() + " to group: " + groupUUID.ToString() + " subject: '" + notice.Subject.ToString() + "' message: '" + notice.Message.ToString() + "' Optional attachment: " + notice.AttachmentID.ToString() + " Serialisation: " + Utils.BytesToString(notice.SerializeAttachment()));
return "<notice>sent</notice>\n";
}
catch ( Exception e )
{
DebugUtilities.WriteError(e.Message);
return "<error>loads of errors</error>";
}
}