public DateTime llInstantMessage(string user, string message)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return DateTime.Now;
// We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
// InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent,
// but I don't think we have a list of scenes available from here.
// (We also don't want to duplicate the code in OnInstantMessage if we can avoid it.)
UUID friendTransactionID = UUID.Random();
GridInstantMessage msg = new GridInstantMessage
{
fromAgentID = m_host.UUID,
toAgentID = UUID.Parse(user),
imSessionID = friendTransactionID,
fromAgentName = m_host.Name
};
// This is the item we're mucking with here
// Cap the message length at 1024.
if (message != null && message.Length > 1024)
msg.message = message.Substring(0, 1024);
else
msg.message = message;
msg.dialog = (byte)InstantMessageDialog.MessageFromObject;
msg.fromGroup = false;
msg.offline = 0;
msg.ParentEstateID = 0;
msg.Position = m_host.AbsolutePosition;
msg.RegionID = World.RegionInfo.RegionID;
msg.binaryBucket
= Util.StringToBytes256(
"{0}/{1}/{2}/{3}",
World.RegionInfo.RegionName,
(int)Math.Floor(m_host.AbsolutePosition.X),
(int)Math.Floor(m_host.AbsolutePosition.Y),
(int)Math.Floor(m_host.AbsolutePosition.Z));
if (m_TransferModule != null)
{
m_TransferModule.SendInstantMessage(msg);
}
return PScriptSleep(2000);
}