Linting
This commit is contained in:
parent
9b826748ea
commit
757badde67
|
@ -94,9 +94,9 @@ async function run() {
|
|||
puppet.on("image", vk.handleMatrixImage.bind(vk));
|
||||
puppet.on("file", vk.handleMatrixFile.bind(vk));
|
||||
|
||||
|
||||
puppet.setCreateRoomHook(vk.createRoom.bind(vk));
|
||||
// required: get description hook
|
||||
// tslint:disable-next-line: no-any
|
||||
puppet.setGetDescHook(async (puppetId: number, data: any): Promise<string> => {
|
||||
// here we receive the puppet ID and the data associated with that puppet
|
||||
// we are expected to return a displayable name for that particular puppet
|
||||
|
|
18
src/vk.ts
18
src/vk.ts
|
@ -24,6 +24,7 @@ interface IEchoPuppet {
|
|||
// this is usually a client class that connects to the remote protocol
|
||||
// as we just echo back, unneeded in our case
|
||||
client: VK;
|
||||
// tslint:disable-next-line: no-any
|
||||
data: any; // and let's keep a copy of the data associated with a puppet
|
||||
}
|
||||
|
||||
|
@ -82,6 +83,7 @@ export class VkPuppet {
|
|||
let response: IRemoteRoom;
|
||||
switch (info.items[0].peer.type) {
|
||||
case "user":
|
||||
// tslint:disable-next-line: no-shadowed-variable
|
||||
const userInfo = await p.client.api.users.get({ user_ids: info.items[0].peer.id, fields: ["photo_max"] });
|
||||
response = {
|
||||
puppetId,
|
||||
|
@ -113,6 +115,7 @@ export class VkPuppet {
|
|||
return response;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line: no-any
|
||||
public async newPuppet(puppetId: number, data: any) {
|
||||
// this is called when we need to create a new puppet
|
||||
// the puppetId is the ID associated with that puppet and the data its data
|
||||
|
@ -173,6 +176,7 @@ export class VkPuppet {
|
|||
// Matrix -> VK section //
|
||||
//////////////////////////
|
||||
|
||||
// tslint:disable-next-line: no-any
|
||||
public async handleMatrixMessage(room: IRemoteRoom, data: IMessageEvent, event: any) {
|
||||
// this is called every time we receive a message from matrix and need to
|
||||
// forward it to the remote protocol.
|
||||
|
@ -235,6 +239,7 @@ export class VkPuppet {
|
|||
room: IRemoteRoom,
|
||||
eventId: string,
|
||||
data: IMessageEvent,
|
||||
// tslint:disable-next-line: no-any
|
||||
event: any,
|
||||
) {
|
||||
const p = this.puppets[room.puppetId];
|
||||
|
@ -259,6 +264,7 @@ export class VkPuppet {
|
|||
room: IRemoteRoom,
|
||||
data: IFileEvent,
|
||||
asUser: ISendingUser | null,
|
||||
// tslint:disable-next-line: no-any
|
||||
event: any,
|
||||
) {
|
||||
const p = this.puppets[room.puppetId];
|
||||
|
@ -305,6 +311,7 @@ export class VkPuppet {
|
|||
room: IRemoteRoom,
|
||||
data: IFileEvent,
|
||||
asUser: ISendingUser | null,
|
||||
// tslint:disable-next-line: no-any
|
||||
event: any,
|
||||
) {
|
||||
const p = this.puppets[room.puppetId];
|
||||
|
@ -357,7 +364,6 @@ export class VkPuppet {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public async createRoom(room: IRemoteRoom): Promise<IRemoteRoom | null> {
|
||||
const p = this.puppets[room.puppetId];
|
||||
if (!p) {
|
||||
|
@ -460,22 +466,17 @@ export class VkPuppet {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public async handleVkEdit(puppetId: number, context: MessageContext) {
|
||||
log.error("OwO", context);
|
||||
const p = this.puppets[puppetId];
|
||||
if (!p) {
|
||||
return;
|
||||
}
|
||||
// As VK always sends edit as outbox, we won't work with any edits from groups
|
||||
if (context.senderType == "group") {
|
||||
log.error("oh no no");
|
||||
|
||||
if (context.senderType === "group") {
|
||||
return; // Deduping
|
||||
}
|
||||
|
||||
const params = await this.getSendParams(puppetId, context.peerId, context.senderId, context.id.toString());
|
||||
log.error("UWU", context.hasText);
|
||||
if (context.hasText) {
|
||||
const opts: IMessageEvent = {
|
||||
body: context.text || "Attachment",
|
||||
|
@ -500,6 +501,7 @@ export class VkPuppet {
|
|||
}
|
||||
|
||||
public async stripReply(body: string) {
|
||||
// tslint:disable-next-line: prefer-const
|
||||
let splitted = body.split("\n");
|
||||
let isCitate = true;
|
||||
while (isCitate) {
|
||||
|
@ -509,6 +511,6 @@ export class VkPuppet {
|
|||
isCitate = false;
|
||||
}
|
||||
}
|
||||
return(splitted.join('\n').trim());
|
||||
return (splitted.join("\n").trim());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"severity": "warning"
|
||||
},
|
||||
"arrow-return-shorthand": true,
|
||||
"no-magic-numbers": [true, -1, 0, 1, 1000],
|
||||
"no-magic-numbers": [true, -1, 0, 1, 1000, 2000000000, 4],
|
||||
"prefer-for-of": true,
|
||||
"typedef": {
|
||||
"severity": "warning"
|
||||
|
|
Loading…
Reference in a new issue