mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-30 05:37:59 +00:00
Streamline .eslintrc
This commit is contained in:
parent
0ab0b582ff
commit
cf56ef66c5
@ -4,12 +4,27 @@
|
||||
"sourceType": "script"
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"commonjs": true,
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.ts",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
"prettier/@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/camelcase": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off"
|
||||
}
|
||||
}
|
||||
],
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
|
5
.vscode/extensions.json
vendored
Normal file
5
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint"
|
||||
]
|
||||
}
|
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"eslint.validate": ["javascript", "typescript"],
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": true
|
||||
}
|
||||
}
|
@ -27,13 +27,14 @@ module.exports = async ({ admin, amend, reason, userToWarn }) => {
|
||||
{ amend }
|
||||
);
|
||||
|
||||
// @ts-ignore
|
||||
const recentWarns = warns.filter(isNewerThan(date - ms(expireWarnsAfter)));
|
||||
const recentWarns = warns.filter(
|
||||
isNewerThan(date.getTime() - ms(expireWarnsAfter))
|
||||
);
|
||||
|
||||
const count = {
|
||||
'-1': recentWarns.length + '/' + numberOfWarnsToBan,
|
||||
0: `${recentWarns.length}/${numberOfWarnsToBan}, <b>last warning!</b>`,
|
||||
1: `<b>banned</b> for receiving ${numberOfWarnsToBan} warnings!`
|
||||
1: `<b>banned</b> for receiving ${numberOfWarnsToBan} warnings!`,
|
||||
}[cmp(recentWarns.length + 1, numberOfWarnsToBan)];
|
||||
|
||||
const warnMessage = dedent(`
|
||||
|
821
package-lock.json
generated
821
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
||||
"scripts": {
|
||||
"postversion": "git push --atomic --follow-tags origin develop develop:master",
|
||||
"start": "node index",
|
||||
"lint": "eslint .",
|
||||
"lint": "eslint --ext .ts --ext .js .",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
@ -49,6 +49,11 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^13.13.2",
|
||||
"eslint": "^6.0.1"
|
||||
"@typescript-eslint/eslint-plugin": "^2.31.0",
|
||||
"@typescript-eslint/parser": "^2.31.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-prettier": "^3.1.3",
|
||||
"prettier": "2.0.5"
|
||||
}
|
||||
}
|
||||
|
16
typings/config.d.ts
vendored
16
typings/config.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
import type { InlineKeyboardMarkup } from 'telegraf/typings/telegram-types';
|
||||
import type { InlineKeyboardMarkup } from "telegraf/typings/telegram-types";
|
||||
|
||||
export type InlineKeyboard = InlineKeyboardMarkup['inline_keyboard'];
|
||||
export type InlineKeyboard = InlineKeyboardMarkup["inline_keyboard"];
|
||||
|
||||
/**
|
||||
* String to be parsed by https://npmjs.com/millisecond,
|
||||
@ -9,7 +9,6 @@ export type InlineKeyboard = InlineKeyboardMarkup['inline_keyboard'];
|
||||
type ms = number | string;
|
||||
|
||||
export interface Config {
|
||||
|
||||
/**
|
||||
* ID (number) or username (string) of master,
|
||||
* the person who can promote and demote admins,
|
||||
@ -23,7 +22,6 @@ export interface Config {
|
||||
token: string;
|
||||
|
||||
chats?: {
|
||||
|
||||
/**
|
||||
* Chat to send member join/leave notifications to.
|
||||
* Pass false to disable this feature.
|
||||
@ -35,18 +33,18 @@ export interface Config {
|
||||
* Pass false to disable this feature.
|
||||
*/
|
||||
report?: number | false;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Which messages with commands should be deleted?
|
||||
* Defaults to 'own' -- don't delete commands meant for other bots.
|
||||
*/
|
||||
deleteCommands?: 'all' | 'own' | 'none';
|
||||
deleteCommands?: "all" | "own" | "none";
|
||||
|
||||
deleteCustom?: {
|
||||
longerThan: number; // UTF-16 characters
|
||||
after: ms;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Timeout before removing join and leave messages.
|
||||
@ -62,7 +60,7 @@ export interface Config {
|
||||
* over which messages get deleted
|
||||
* Pass false to disable this feature.
|
||||
*/
|
||||
deleteWarnsAfter?: ms | { auto: (ms | false), manual: (ms | false) } | false;
|
||||
deleteWarnsAfter?: ms | { auto: ms | false; manual: ms | false } | false;
|
||||
|
||||
/**
|
||||
* Timeout before removing ban messages.
|
||||
@ -109,7 +107,7 @@ export interface Config {
|
||||
spamwatch?: {
|
||||
token: string;
|
||||
host?: string;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Inline keyboard to be added to warn message.
|
||||
|
37
typings/context.d.ts
vendored
37
typings/context.d.ts
vendored
@ -1,31 +1,31 @@
|
||||
import type { Context } from 'telegraf';
|
||||
import type {
|
||||
User,
|
||||
Message,
|
||||
ExtraReplyMessage,
|
||||
} from 'telegraf/typings/telegram-types';
|
||||
Message,
|
||||
User,
|
||||
} from "telegraf/typings/telegram-types";
|
||||
import type { Context } from "telegraf";
|
||||
|
||||
interface DbUser {
|
||||
status: 'member' | 'admin' | 'banned';
|
||||
status: "member" | "admin" | "banned";
|
||||
}
|
||||
|
||||
export interface ContextExtensions {
|
||||
ban(options: {
|
||||
admin: User,
|
||||
reason: string,
|
||||
userToBan: User,
|
||||
admin: User;
|
||||
reason: string;
|
||||
userToBan: User;
|
||||
}): Promise<Message>;
|
||||
batchBan(options: {
|
||||
admin: User,
|
||||
reason: string,
|
||||
targets: User[],
|
||||
admin: User;
|
||||
reason: string;
|
||||
targets: User[];
|
||||
}): Promise<Message>;
|
||||
warn(options: {
|
||||
admin: User,
|
||||
amend?: boolean,
|
||||
reason: string,
|
||||
userToWarn: User,
|
||||
mode: 'auto' | 'manual',
|
||||
admin: User;
|
||||
amend?: boolean;
|
||||
reason: string;
|
||||
userToWarn: User;
|
||||
mode: "auto" | "manual";
|
||||
}): Promise<Message>;
|
||||
replyWithCopy(
|
||||
content: Message,
|
||||
@ -33,6 +33,7 @@ export interface ContextExtensions {
|
||||
): Promise<Message>;
|
||||
}
|
||||
|
||||
export type ExtendedContext = ContextExtensions & Context & {
|
||||
from?: DbUser,
|
||||
export type ExtendedContext = ContextExtensions &
|
||||
Context & {
|
||||
from?: DbUser;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user