TheComamba / UnKenny

A FoundryVTT module providing NPCs with artificial intelligence.
MIT License
2 stars 5 forks source link

Can we avoid having to post messages ourselves? #64

Closed TheComamba closed 5 months ago

TheComamba commented 6 months ago

This would be much preferable to the hack we currently use.

There is the ChatMessageRender hook.

One issue is that the text is scanned for chat commands, and our /alias command clashes with that.

So maybe we do the text replacement in ChatMessage, and trigger calculating the response in ChatMessageRender.

How do we know if the text contained an unkenny command?

Maybe we need to rethink if we really want to use the /alias Syntax. We are about to release breaking changes, so now would be the time to do that.

TheComamba commented 6 months ago

I want to remove the chat command feature for the following reasons:

TheComamba commented 6 months ago

I did that in #65.

TheComamba commented 6 months ago

Hjep, getting more complicated again. To post a message, we need to call the processMessage function on ChatLog. For that, we need to get the ChatLog. And as this function only takes the message as argument, setting the speaker will be a small challenge. Maybe we can work with a hook.

KingphilAusti commented 6 months ago

Kinda hacky but works now. In triggerResponse now creates a new ChatLog().processMessage("#TeamEmilia" + JSON.stringify(chatData)), where chatData encodes response + message type + actor name. #TeamEmilia is used as a stop word for triggering logic in our overridden version of ChatMessage._preCreate.