2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-30 21:55:17 +00:00

Merge pull request #150 from C0rn3j/develop

Replace node-fetch, add originating room name to warns/bans
This commit is contained in:
Martin
2022-03-29 15:35:20 +02:00
committed by GitHub
6 changed files with 49 additions and 36 deletions

View File

@@ -65,7 +65,7 @@ const banHandler = async (ctx) => {
return ctx.ban({
admin: ctx.from,
reason: await substom(reason),
reason: '[' + ctx.chat.title + '] ' + await substom(reason),
userToBan,
});
};

View File

@@ -100,7 +100,7 @@ const getWarnsHandler = async (ctx) => {
formatDate(theUser.createdAt),
);
const permitS = permit.isValid(theUser.permit)
const permits = permit.isValid(theUser.permit)
// eslint-disable-next-line max-len
? `🎟 ${(await getUser({ id: theUser.permit.by_id })).first_name}, ${formatDate(theUser.permit.date)}`
: '';
@@ -108,7 +108,7 @@ const getWarnsHandler = async (ctx) => {
const oneliners = TgHtml.join('\n', [
header,
firstSeen,
permitS,
permits,
].filter(isNotEmpty));
return ctx.replyWithHTML(TgHtml.join('\n\n', [

View File

@@ -53,7 +53,7 @@ const warnHandler = async (ctx) => {
return ctx.warn({
admin: ctx.from,
amend: flags.has('amend'),
reason: await substom(reason),
reason: '[' + ctx.chat.title + '] ' + await substom(reason),
userToWarn,
mode: 'manual',
});

View File

@@ -5,7 +5,6 @@ import { html, lrm } from "../../utils/html";
import { isAdmin, permit } from "../../stores/user";
import { config } from "../../utils/config";
import type { ExtendedContext } from "../../typings/context";
import fetch from "node-fetch";
import { jspack } from "jspack";
import { managesGroup } from "../../stores/group";
import type { MessageEntity } from "telegraf/typings/telegram-types";
@@ -15,6 +14,7 @@ import { URL } from "url";
import XRegExp = require("xregexp");
const { excludeLinks = [], blacklistedDomains = [] } = config;
const { fetch } = require('undici');
if (excludeLinks === false) {
module.exports = (ctx, next) => next();

71
package-lock.json generated
View File

@@ -13,7 +13,6 @@
"jspack": "0.0.4",
"millisecond": "^0.1.2",
"nedb-promise": "^2.0.1",
"node-fetch": "^2.2.0",
"ramda": "^0.25.0",
"require-directory": "^2.1.1",
"spamwatch": "^0.4.0",
@@ -21,6 +20,7 @@
"telegraf": "^4.7.0",
"ts-node": "^10.7.0",
"typescript": "^4.6.3",
"undici": "^4.16.0",
"xregexp": "^5.1.0"
},
"devDependencies": {
@@ -36,7 +36,7 @@
"prettier": "2.0.5"
},
"engines": {
"node": ">=12.3.1"
"node": ">=12.20.2"
}
},
"node_modules/@babel/code-frame": {
@@ -1480,25 +1480,6 @@
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
"dev": true
},
"node_modules/node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
@@ -1978,6 +1959,25 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/telegraf/node_modules/node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/text-table": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
@@ -2132,6 +2132,14 @@
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz",
"integrity": "sha1-YaajIBBiKvoHljvzJSA88SI51gQ="
},
"node_modules/undici": {
"version": "4.16.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-4.16.0.tgz",
"integrity": "sha512-tkZSECUYi+/T1i4u+4+lwZmQgLXd4BLGlrc7KZPcLIW7Jpq99+Xpc30ONv7nS6F5UNOxp/HBZSSL9MafUrvJbw==",
"engines": {
"node": ">=12.18"
}
},
"node_modules/uri-js": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
@@ -3364,14 +3372,6 @@
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
"dev": true
},
"node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"requires": {
"whatwg-url": "^5.0.0"
}
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
@@ -3733,6 +3733,14 @@
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"requires": {
"whatwg-url": "^5.0.0"
}
}
}
},
@@ -3842,6 +3850,11 @@
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz",
"integrity": "sha1-YaajIBBiKvoHljvzJSA88SI51gQ="
},
"undici": {
"version": "4.16.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-4.16.0.tgz",
"integrity": "sha512-tkZSECUYi+/T1i4u+4+lwZmQgLXd4BLGlrc7KZPcLIW7Jpq99+Xpc30ONv7nS6F5UNOxp/HBZSSL9MafUrvJbw=="
},
"uri-js": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",

View File

@@ -37,7 +37,6 @@
"jspack": "0.0.4",
"millisecond": "^0.1.2",
"nedb-promise": "^2.0.1",
"node-fetch": "^2.2.0",
"ramda": "^0.25.0",
"require-directory": "^2.1.1",
"spamwatch": "^0.4.0",
@@ -45,10 +44,11 @@
"telegraf": "^4.7.0",
"ts-node": "^10.7.0",
"typescript": "^4.6.3",
"undici": "^4.16.0",
"xregexp": "^5.1.0"
},
"engines": {
"node": ">=12.3.1"
"node": ">=12.20.2"
},
"devDependencies": {
"@types/node": "^13.13.2",