Redacts from matrix and documents from vk
This commit is contained in:
parent
f384ba6584
commit
5c99493052
|
@ -23,20 +23,21 @@ Register that one with synapse and start the bridge with `npm run start`.
|
|||
- [ ] Presence - not possible yet
|
||||
- [ ] Read notifications - not possible yet
|
||||
- [x] Message edits
|
||||
- [ ] Message redacts
|
||||
- [x] Message redacts - only works in 24 hours after message is sent
|
||||
- VK -> Matrix
|
||||
- [x] Text content
|
||||
- [ ] Forwards
|
||||
- [x] Image content
|
||||
- [x] Audio content
|
||||
- [ ] Video content
|
||||
- [x] Stickers
|
||||
- [ ] Other files
|
||||
- [x] Other files
|
||||
- [ ] Presence - not effective to track
|
||||
- [x] Typing notifs
|
||||
- [x] User profiles
|
||||
- [ ] Read notifications - not effective to track
|
||||
- [x] Message edits
|
||||
- [ ] Message redacts
|
||||
- [ ] Message redacts - doesn't work
|
||||
|
||||
## Usage
|
||||
1. Get VK community token (Just open the "Manage community" tab, go to "API usage" tab and click "Create token")
|
||||
|
|
|
@ -89,6 +89,7 @@ async function run() {
|
|||
puppet.on("puppetDelete", vk.deletePuppet.bind(vk));
|
||||
puppet.on("message", vk.handleMatrixMessage.bind(vk));
|
||||
puppet.on("edit", vk.handleMatrixEdit.bind(vk));
|
||||
puppet.on("redact", vk.handleMatrixRedact.bind(vk));
|
||||
puppet.on("reply", vk.handleMatrixReply.bind(vk));
|
||||
puppet.on("image", vk.handleMatrixImage.bind(vk));
|
||||
puppet.on("file", vk.handleMatrixFile.bind(vk));
|
||||
|
|
29
src/vk.ts
29
src/vk.ts
|
@ -214,6 +214,22 @@ export class VkPuppet {
|
|||
}
|
||||
}
|
||||
|
||||
public async handleMatrixRedact(room: IRemoteRoom, eventId: string) {
|
||||
const p = this.puppets[room.puppetId];
|
||||
if (!p) {
|
||||
return;
|
||||
}
|
||||
// usually you'd send it here to the remote protocol via the client object
|
||||
try {
|
||||
await p.client.api.messages.delete({
|
||||
spam: 0,
|
||||
delete_for_all: 1,
|
||||
message_ids: Number(eventId),
|
||||
});
|
||||
} catch (err) {
|
||||
log.error("Error sending edit to vk", err.error || err.body || err);
|
||||
}
|
||||
}
|
||||
|
||||
public async handleMatrixReply(
|
||||
room: IRemoteRoom,
|
||||
|
@ -361,7 +377,7 @@ export class VkPuppet {
|
|||
if (!p) {
|
||||
return;
|
||||
}
|
||||
//log.info("Received new message!", context);
|
||||
log.info("Received new message!", context);
|
||||
if (context.isOutbox) {
|
||||
return; // Deduping
|
||||
}
|
||||
|
@ -399,7 +415,6 @@ export class VkPuppet {
|
|||
switch (f.type) {
|
||||
case AttachmentType.PHOTO:
|
||||
try {
|
||||
// tslint:disable-next-line: no-string-literal
|
||||
await this.puppet.sendFileDetect(params, f["largeSizeUrl"]);
|
||||
} catch (err) {
|
||||
const opts: IMessageEvent = {
|
||||
|
@ -428,6 +443,16 @@ export class VkPuppet {
|
|||
await this.puppet.sendMessage(params, opts);
|
||||
}
|
||||
break;
|
||||
case AttachmentType.DOCUMENT:
|
||||
try {
|
||||
await this.puppet.sendFileDetect(params, f["url"], f["title"]);
|
||||
} catch (err) {
|
||||
const opts: IMessageEvent = {
|
||||
body: `Document was sent: ${f["url"]}`,
|
||||
};
|
||||
await this.puppet.sendMessage(params, opts);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
"curly": true,
|
||||
"no-empty": false,
|
||||
"no-invalid-this": true,
|
||||
"no-string-literal": false,
|
||||
"no-string-throw": {
|
||||
"severity": "warning"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue