mx-puppet-bridge
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -32,2 +32,3 @@ export declare class Config { | ||
enableGroupSync: boolean; | ||
stripHomeservers: string[]; | ||
} | ||
@@ -34,0 +35,0 @@ export declare class LoggingConfig { |
@@ -51,2 +51,3 @@ "use strict"; | ||
this.enableGroupSync = false; | ||
this.stripHomeservers = []; | ||
} | ||
@@ -53,0 +54,0 @@ } |
@@ -68,13 +68,18 @@ "use strict"; | ||
this.bridge.AS.on("ephemeral.event", (rawEvent) => __awaiter(this, void 0, void 0, function* () { | ||
switch (rawEvent.type) { | ||
case "m.presence": | ||
yield this.handlePresence(rawEvent); | ||
break; | ||
case "m.typing": | ||
yield this.handleTyping(rawEvent.room_id, rawEvent); | ||
break; | ||
case "m.receipt": | ||
yield this.handleReceipt(rawEvent.room_id, rawEvent); | ||
break; | ||
try { | ||
switch (rawEvent.type) { | ||
case "m.presence": | ||
yield this.handlePresence(rawEvent); | ||
break; | ||
case "m.typing": | ||
yield this.handleTyping(rawEvent.room_id, rawEvent); | ||
break; | ||
case "m.receipt": | ||
yield this.handleReceipt(rawEvent.room_id, rawEvent); | ||
break; | ||
} | ||
} | ||
catch (err) { | ||
log.error("Error handling appservice ephemeral.event", err.error || err.body || err); | ||
} | ||
})); | ||
@@ -81,0 +86,0 @@ } |
@@ -66,2 +66,5 @@ "use strict"; | ||
} | ||
if (key.startsWith("mxc://")) { | ||
send.url = key; | ||
} | ||
const matrixEventId = yield client.sendEvent(mxid, "m.reaction", send); | ||
@@ -68,0 +71,0 @@ if (matrixEventId && params.eventId) { |
@@ -624,2 +624,6 @@ "use strict"; | ||
preprocessMessageEvent(opts) { | ||
for (const homeserver of this.bridge.config.bridge.stripHomeservers) { | ||
const urlRegex = homeserver.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); | ||
opts.body = opts.body.replace(new RegExp(`@([\x21-\x39\x3b-\x7e]+):${urlRegex}`, "g"), "@$1"); | ||
} | ||
if (!opts.formattedBody) { | ||
@@ -626,0 +630,0 @@ return; |
{ | ||
"name": "mx-puppet-bridge", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Matrix Puppeting Bridge library", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -26,2 +26,3 @@ [Support Chat](https://matrix.to/#/#mx-puppet-bridge:sorunome.de) [![donate](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/Sorunome/donate) | ||
- [VK](https://github.com/innereq/mx-puppet-vk) | ||
- [GroupMe](https://gitlab.com/robintown/mx-puppet-groupme) | ||
@@ -28,0 +29,0 @@ ## Docs |
@@ -54,2 +54,3 @@ /* | ||
public enableGroupSync: boolean = false; | ||
public stripHomeservers: string[] = []; | ||
} | ||
@@ -56,0 +57,0 @@ |
@@ -70,12 +70,16 @@ /* | ||
this.bridge.AS.on("ephemeral.event", async (rawEvent: any) => { | ||
switch (rawEvent.type) { | ||
case "m.presence": | ||
await this.handlePresence(rawEvent); | ||
break; | ||
case "m.typing": | ||
await this.handleTyping(rawEvent.room_id, rawEvent); | ||
break; | ||
case "m.receipt": | ||
await this.handleReceipt(rawEvent.room_id, rawEvent); | ||
break; | ||
try { | ||
switch (rawEvent.type) { | ||
case "m.presence": | ||
await this.handlePresence(rawEvent); | ||
break; | ||
case "m.typing": | ||
await this.handleTyping(rawEvent.room_id, rawEvent); | ||
break; | ||
case "m.receipt": | ||
await this.handleReceipt(rawEvent.room_id, rawEvent); | ||
break; | ||
} | ||
} catch (err) { | ||
log.error("Error handling appservice ephemeral.event", err.error || err.body || err); | ||
} | ||
@@ -82,0 +86,0 @@ }); |
@@ -64,2 +64,5 @@ /* | ||
} | ||
if (key.startsWith("mxc://")) { | ||
send.url = key; | ||
} | ||
const matrixEventId = await client.sendEvent(mxid, "m.reaction", send); | ||
@@ -66,0 +69,0 @@ if (matrixEventId && params.eventId) { |
@@ -614,2 +614,6 @@ /* | ||
private preprocessMessageEvent(opts: IMessageEvent) { | ||
for (const homeserver of this.bridge.config.bridge.stripHomeservers) { | ||
const urlRegex = homeserver.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); | ||
opts.body = opts.body.replace(new RegExp(`@([\x21-\x39\x3b-\x7e]+):${urlRegex}`, "g"), "@$1"); | ||
} | ||
if (!opts.formattedBody) { | ||
@@ -616,0 +620,0 @@ return; |
889024
22616
109