Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
melod1n committed Oct 21, 2022
1 parent 7793d44 commit f8bee71
Show file tree
Hide file tree
Showing 47 changed files with 471 additions and 478 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"rules": {
"indent": [
"error",
"tab"
4
],
"linebreak-style": [
"error",
Expand Down
93 changes: 43 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"eslint": "^8.24.0",
"eslint": "8.22.0",
"ts-node-dev": "^2.0.0"
},
"description": "Simple chat bot for VK",
Expand Down
18 changes: 9 additions & 9 deletions src/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {MessageContext} from 'vk-io';
import {TAG_ERROR, vk} from '../index';
import {Utils} from '../util/utils';
import {MessagesEditParams} from 'vk-io/lib/api/schemas/params';
import {MessageContext} from "vk-io";
import {TAG_ERROR, vk} from "../index";
import {Utils} from "../util/utils";
import {MessagesEditParams} from "vk-io/lib/api/schemas/params";

export class Api {

Expand All @@ -13,17 +13,17 @@ export class Api {
}

static async sendMessage(context: MessageContext, message?: string, disableMentions?: boolean,
replyTo?: number, keyboard?: string): Promise<number> {
replyTo?: number, keyboard?: string): Promise<number> {
return new Promise((resolve, reject) => {
const params = {
peer_id: context.peerId,
random_id: 0
};

if (message) params['message'] = message;
if (disableMentions) params['disable_mentions'] = disableMentions ? 1 : 0;
if (replyTo) params['reply_to'] = replyTo;
if (keyboard) params['keyboard'] = keyboard;
if (message) params["message"] = message;
if (disableMentions) params["disable_mentions"] = disableMentions ? 1 : 0;
if (replyTo) params["reply_to"] = replyTo;
if (keyboard) params["keyboard"] = keyboard;

vk.api.messages.send(params).then((id) => resolve(id)).catch(reject);
});
Expand Down
2 changes: 1 addition & 1 deletion src/api/base/errors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const notImplemented = new Error('Not implemented');
const notImplemented = new Error("Not implemented");

export {notImplemented};
6 changes: 3 additions & 3 deletions src/api/load-manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {UsersLoader} from './loader/users-loader';
import {ChatsLoader} from './loader/chats-loader';
import {MessagesLoader} from './loader/messages-loader';
import {UsersLoader} from "./loader/users-loader";
import {ChatsLoader} from "./loader/chats-loader";
import {MessagesLoader} from "./loader/messages-loader";

export class LoadManager {

Expand Down
20 changes: 10 additions & 10 deletions src/api/loader/chats-loader.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {Loader} from '../../model/loader';
import {VkChat} from '../../model/vk-chat';
import {vk} from '../../index';
import {VkUser} from '../../model/vk-user';
import {CacheStorage} from '../../database/cache-storage';
import {MemoryCache} from '../../database/memory-cache';
import {Loader} from "../../model/loader";
import {VkChat} from "../../model/vk-chat";
import {vk} from "../../index";
import {VkUser} from "../../model/vk-user";
import {CacheStorage} from "../../database/cache-storage";
import {MemoryCache} from "../../database/memory-cache";

export class ChatsLoader extends Loader<VkChat> {

Expand All @@ -12,8 +12,8 @@ export class ChatsLoader extends Loader<VkChat> {

return new Promise(async (resolve, reject) => {
try {
const json = (await vk.api.call('messages.getConversationsById', {
peer_ids: peersIds.join(',')
const json = (await vk.api.call("messages.getConversationsById", {
peer_ids: peersIds.join(",")
}));
const jsonChats = json.items;

Expand All @@ -25,10 +25,10 @@ export class ChatsLoader extends Loader<VkChat> {
const membersIds = [];
const members: VkUser[] = [];

const jsonMembers = await vk.api.call('messages.getConversationMembers',
const jsonMembers = await vk.api.call("messages.getConversationMembers",
{
peer_id: chat.id,
fields: 'photo_100,photo_200,online,online_mobile,online_info,sex'
fields: "photo_100,photo_200,online,online_mobile,online_info,sex"
}
);

Expand Down
8 changes: 4 additions & 4 deletions src/api/loader/messages-loader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Loader} from '../../model/loader';
import {VkMessage} from '../../model/vk-message';
import {notImplemented} from '../base/errors';
import {vk} from '../../index';
import {Loader} from "../../model/loader";
import {VkMessage} from "../../model/vk-message";
import {notImplemented} from "../base/errors";
import {vk} from "../../index";

export class MessagesLoader extends Loader<VkMessage> {

Expand Down
12 changes: 6 additions & 6 deletions src/api/loader/users-loader.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Loader} from '../../model/loader';
import {VkUser} from '../../model/vk-user';
import {vk} from '../../index';
import {CacheStorage} from '../../database/cache-storage';
import {MemoryCache} from '../../database/memory-cache';
import {Loader} from "../../model/loader";
import {VkUser} from "../../model/vk-user";
import {vk} from "../../index";
import {CacheStorage} from "../../database/cache-storage";
import {MemoryCache} from "../../database/memory-cache";

export class UsersLoader extends Loader<VkUser> {

Expand All @@ -12,7 +12,7 @@ export class UsersLoader extends Loader<VkUser> {
return new Promise((resolve, reject) => {
vk.api.users.get({
user_ids: usersIds,
fields: ['photo_50', 'photo_100', 'photo_200', 'status', 'screen_name', 'online', 'last_seen', 'verified', 'sex']
fields: ["photo_50", "photo_100", "photo_200", "status", "screen_name", "online", "last_seen", "verified", "sex"]
}).then(async (r) => {
const users = VkUser.parse(r);
resolve(users);
Expand Down
Loading

0 comments on commit f8bee71

Please sign in to comment.