Fix bug preventing all non-image messages from being sent (closes #30)
This commit is contained in:
parent
455a301875
commit
1ce2e01f5c
1 changed files with 8 additions and 11 deletions
|
|
@ -28,7 +28,7 @@ export function chatImageLinks() {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
config: true,
|
config: true,
|
||||||
requiresReload: true,
|
requiresReload: false,
|
||||||
onChange: (newValue) => {
|
onChange: (newValue) => {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
hookID = Hooks.on(`chatMessage`, chatMessageHandler);
|
hookID = Hooks.on(`chatMessage`, chatMessageHandler);
|
||||||
|
|
@ -37,13 +37,6 @@ export function chatImageLinks() {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
game.settings.register(__ID__, key + `-showPromptAgain`, {
|
|
||||||
scope: `user`,
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
config: false,
|
|
||||||
});
|
|
||||||
// #endregion Registration
|
// #endregion Registration
|
||||||
|
|
||||||
// #region Implementation
|
// #region Implementation
|
||||||
|
|
@ -65,9 +58,6 @@ const pattern = new RegExp(
|
||||||
// MARK: Mutate & Resend
|
// MARK: Mutate & Resend
|
||||||
const handled = new Set();
|
const handled = new Set();
|
||||||
async function mutateAndResendMessage(chatLog, message, options) {
|
async function mutateAndResendMessage(chatLog, message, options) {
|
||||||
const match = message.match(pattern);
|
|
||||||
if (!match) { return };
|
|
||||||
|
|
||||||
const validMatches = new Set();
|
const validMatches = new Set();
|
||||||
|
|
||||||
const matches = message.match(pattern);
|
const matches = message.match(pattern);
|
||||||
|
|
@ -99,7 +89,14 @@ async function mutateAndResendMessage(chatLog, message, options) {
|
||||||
*/
|
*/
|
||||||
function chatMessageHandler(chatLog, message, options) {
|
function chatMessageHandler(chatLog, message, options) {
|
||||||
if (!game.settings.get(__ID__, key)) { return };
|
if (!game.settings.get(__ID__, key)) { return };
|
||||||
|
|
||||||
|
// Don't re-process the same message
|
||||||
if (handled.has(message)) { return };
|
if (handled.has(message)) { return };
|
||||||
|
|
||||||
|
// Prevent cancellation for non-matching messages
|
||||||
|
const match = message.match(pattern);
|
||||||
|
if (!match) { return };
|
||||||
|
|
||||||
mutateAndResendMessage(chatLog, message, options);
|
mutateAndResendMessage(chatLog, message, options);
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue