

This unofficial TaleSpire plugin is a dependency plugin for creating local chat service functionality. The plugin allows registering of key words with corresponding handlders to create functionality such as whispers or dice rolling functionality.
1.0.0: Initial release
Use R2ModMan or similar installer to install this plugin.
Reference this dependency plugin in the parent plugin and then use the following syntax to add a chat service:
handlers.Add(serviceKey, handler)
Where the service key is a string that must appear at the beginning of the chat message in order to trip the corresponding handler.
Where hander is a function that takes in two string, the message content and the sender, and returns a string, the modified message or null. Returning null prevents the message from being displayed.
Sample hander that implements the whisper function using an inline function:
handlers.Add("/w ", (chatMessage, sender)=>
{
if (chatMessage.StartsWith("/w"))
{
chatMessage = chatMessage.Substring(2).Trim() + " ";
string target = chatMessage.Substring(0, chatMessage.IndexOf(" "));
chatMessage = chatMessage.Substring(chatMessage.IndexOf(" ") + 1);
Debug.Log("Whisper From '"+sender+"' To '" + target + "' Received By '" + CampaignSessionManager.GetPlayerName(LocalPlayer.Id) + "'");
if (CampaignSessionManager.GetPlayerName(LocalPlayer.Id) != target)
{
return null;
}
chatMessage = "(Whisper) " + chatMessage;
}
return chatMessage;
});```