diff --git a/src/index.ts b/src/index.ts index 9c724e8..ab30f9a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,4 @@ -import { HexColorString } from 'discord.js'; - -import { AttachmentTypeUnion, Handler, Storage, VK } from './modules'; +import { Handler, ICluster, Storage } from './modules'; // @ts-ignore import config from '../config.json'; @@ -10,46 +8,6 @@ export interface IConfig { version_dont_modify_me: number; } -export interface IVKParams { - token: string; - group_id: string; - keywords: string[]; - words_blacklist: string[]; - filter: boolean; - donut: boolean; - ads: boolean; - longpoll: boolean; - interval: number; -} - -export enum Exclude { - TEXT = 'text', - ATTACHMENTS = 'attachments', - REPOST_TEXT = 'repost_text', - REPOST_ATTACHMENTS = 'repost_attachments' -} - -export interface IDiscordParams { - webhook_urls: string[]; - username: string; - avatar_url: string; - content: string; - color: HexColorString; - author: boolean; - copyright: boolean; - date: boolean; - exclude_content: (AttachmentTypeUnion | Exclude)[]; -} - -export interface ICluster { - vk: IVKParams; - discord: IDiscordParams; - - VK: VK; - storage: Storage; - index: number; -} - const { clusters } = config as unknown as IConfig; console.log('[VK2Discord] Запущен.'); diff --git a/src/modules/Attachments.ts b/src/modules/Attachments.ts index d900af9..64f87b6 100644 --- a/src/modules/Attachments.ts +++ b/src/modules/Attachments.ts @@ -1,8 +1,8 @@ import { MessageEmbed, MessageAttachment } from 'discord.js'; import { AttachmentType, ISharedAttachmentPayload, AttachmentTypeString } from 'vk-io'; -import { Message } from './'; -import { ICluster } from '../'; +import { Message } from './Message'; +import { ICluster } from './Handler'; import { generateRandomString, LINK_PREFIX } from '../utils'; @@ -18,7 +18,7 @@ const { AUDIO, DOCUMENT, LINK, PHOTO, POLL, VIDEO, ALBUM, MARKET, MARKET_ALBUM } export class Attachments { - private cluster: ICluster; + private readonly cluster: ICluster; constructor(cluster: Attachments['cluster']) { this.cluster = cluster; diff --git a/src/modules/Handler.ts b/src/modules/Handler.ts index 4e4a531..0211c13 100644 --- a/src/modules/Handler.ts +++ b/src/modules/Handler.ts @@ -1,12 +1,53 @@ import { IWallPostContextPayload } from 'vk-io'; import { GroupsGetByIdObjectLegacyResponse, UsersGetResponse } from 'vk-io/lib/api/schemas/responses'; -import { MessageEmbed } from 'discord.js'; +import { HexColorString, MessageEmbed } from 'discord.js'; -import { Sender, Storage, TokenType, VK } from './'; +import { Sender } from './Sender'; +import { Storage } from './Storage'; +import { VK, TokenType } from './VK'; +import { AttachmentTypeUnion } from './Attachments'; import { getById, getPostAuthor, getPostLink, getResourceId, IGetPostLinkOptions } from '../utils'; -import { ICluster } from '../'; +export interface IVKParams { + token: string; + group_id: string; + keywords: string[]; + words_blacklist: string[]; + filter: boolean; + donut: boolean; + ads: boolean; + longpoll: boolean; + interval: number; +} + +export enum Exclude { + TEXT = 'text', + ATTACHMENTS = 'attachments', + REPOST_TEXT = 'repost_text', + REPOST_ATTACHMENTS = 'repost_attachments' +} + +export interface IDiscordParams { + webhook_urls: string[]; + username: string; + avatar_url: string; + content: string; + color: HexColorString; + author: boolean; + copyright: boolean; + date: boolean; + exclude_content: (AttachmentTypeUnion | Exclude)[]; +} + +export interface ICluster { + vk: IVKParams; + discord: IDiscordParams; + + VK: VK; + storage: Storage; + index: number; +} export class Handler { diff --git a/src/modules/Markdown.ts b/src/modules/Markdown.ts index bd39fc4..2f31b3b 100644 --- a/src/modules/Markdown.ts +++ b/src/modules/Markdown.ts @@ -1,6 +1,6 @@ import replaceAsync from 'string-replace-async'; -import { VK } from './'; +import { VK } from './VK'; import { LINK_PREFIX } from '../utils'; diff --git a/src/modules/Message.ts b/src/modules/Message.ts index a419612..689750b 100644 --- a/src/modules/Message.ts +++ b/src/modules/Message.ts @@ -1,9 +1,9 @@ import { MessageAttachment, MessageEmbed } from 'discord.js'; import { IWallPostContextPayload } from 'vk-io'; -import { Attachment, Attachments, Markdown } from './'; - -import { Exclude, ICluster } from '../'; +import { Attachment, Attachments } from './Attachments'; +import { Markdown } from './Markdown'; +import { Exclude, ICluster } from './Handler'; export enum PostType { POST = 'post', diff --git a/src/modules/Sender.ts b/src/modules/Sender.ts index 846be18..e5551a2 100644 --- a/src/modules/Sender.ts +++ b/src/modules/Sender.ts @@ -1,9 +1,10 @@ import { WebhookClient } from 'discord.js'; import { IWallPostContextPayload } from 'vk-io'; -import { FieldType, Keywords, KeywordsType, Message } from './'; - -import { ICluster } from '../'; +import { Keywords, KeywordsType } from './Keywords'; +import { Message } from './Message'; +import { FieldType } from './Storage'; +import { ICluster } from './Handler'; export class Sender extends Message { diff --git a/src/modules/index.ts b/src/modules/index.ts index 2b7a9f6..b2509f4 100644 --- a/src/modules/index.ts +++ b/src/modules/index.ts @@ -1,5 +1,5 @@ -export * from './Attachments'; export * from './Handler'; +export * from './Attachments'; export * from './Keywords'; export * from './Markdown'; export * from './Message';