If you are able to fetch the UUID of said object, using the following can help:
default
{
state_entry()
{
list info = llGetObjectDetails(uuidHere,[OBJECT_OWNER]);
llOwnerSay((string)llList2String(info,0));
}
}
However alot of clients support the ability to click on the name of the object (which is most of the time a link to the profile of the owner)
Another way of doing it, is if it is a chat spammer, is to set up a listener on Channel 0, using listen()'s built in key id, will return the objects UUID automaticly, see below.
key uuid;
default
{
state_entry()
{
llListen(0,"","","");
}
listen(integer chan, string objectName, key objectKey, string msg)
{
uuid = objectKey;
list info = llGetObjectDetails(uuid,[OBJECT_OWNER]);
llOwnerSay((string)llKey2Name(llList2String(info,0)) + " Said: " + (string)msg);
}
}
^^Copy and paste that into an object, anything sent over channel 0 will display the message and who sent it.