Skip to content

Commit

Permalink
chore: move cluster types
Browse files Browse the repository at this point in the history
  • Loading branch information
egorprnn committed Oct 9, 2021
1 parent ef79d26 commit 1d521c7
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 57 deletions.
44 changes: 1 addition & 43 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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] Запущен.');
Expand Down
6 changes: 3 additions & 3 deletions src/modules/Attachments.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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;
Expand Down
47 changes: 44 additions & 3 deletions src/modules/Handler.ts
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion src/modules/Markdown.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import replaceAsync from 'string-replace-async';

import { VK } from './';
import { VK } from './VK';

import { LINK_PREFIX } from '../utils';

Expand Down
6 changes: 3 additions & 3 deletions src/modules/Message.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
7 changes: 4 additions & 3 deletions src/modules/Sender.ts
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion src/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './Attachments';
export * from './Handler';
export * from './Attachments';
export * from './Keywords';
export * from './Markdown';
export * from './Message';
Expand Down

0 comments on commit 1d521c7

Please sign in to comment.