mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
debug+++++
This commit is contained in:
parent
7f4195eb02
commit
9b4c00915f
3 changed files with 35 additions and 8 deletions
|
@ -29,7 +29,6 @@ import { runUpcomingScheduledPostsLoop } from "./data/loops/upcomingScheduledPos
|
|||
import { runExpiringTempbansLoop } from "./data/loops/expiringTempbansLoop";
|
||||
import { runExpiringVCAlertsLoop } from "./data/loops/expiringVCAlertsLoop";
|
||||
import { runExpiredArchiveDeletionLoop } from "./data/loops/expiredArchiveDeletionLoop";
|
||||
import blockedAt from "blocked-at";
|
||||
|
||||
if (!process.env.KEY) {
|
||||
// tslint:disable-next-line:no-console
|
||||
|
@ -337,13 +336,6 @@ connect().then(async () => {
|
|||
logRateLimit(data);
|
||||
});
|
||||
|
||||
blockedAt(
|
||||
(time, stack) => {
|
||||
console.error(`Blocked for ${time}ms, operation started here:`, stack);
|
||||
},
|
||||
{ threshold: 1000 },
|
||||
);
|
||||
|
||||
bot.on("loadingFinished", async () => {
|
||||
runExpiringMutesLoop();
|
||||
await sleep(10 * SECONDS);
|
||||
|
|
|
@ -23,6 +23,7 @@ import { AddServerFromInviteCmd } from "./commands/AddServerFromInviteCmd";
|
|||
import { ChannelToServerCmd } from "./commands/ChannelToServerCmd";
|
||||
import { RestPerformanceCmd } from "./commands/RestPerformanceCmd";
|
||||
import { RateLimitPerformanceCmd } from "./commands/RateLimitPerformanceCmd";
|
||||
import { ToggleBlockDetectionCmd } from "./commands/ToggleBlockDetectionCmd";
|
||||
|
||||
const defaultOptions = {
|
||||
config: {
|
||||
|
@ -58,6 +59,7 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
|
|||
RateLimitPerformanceCmd,
|
||||
AddServerFromInviteCmd,
|
||||
ChannelToServerCmd,
|
||||
ToggleBlockDetectionCmd,
|
||||
],
|
||||
|
||||
async afterLoad(pluginData) {
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { botControlCmd } from "../types";
|
||||
import blockedAt from "blocked-at";
|
||||
|
||||
let stop;
|
||||
|
||||
export const ToggleBlockDetectionCmd = botControlCmd({
|
||||
trigger: ["toggle_block_detection"],
|
||||
permission: "can_performance",
|
||||
|
||||
signature: {
|
||||
threshold: ct.number({ required: false }),
|
||||
},
|
||||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
if (stop) {
|
||||
stop();
|
||||
stop = null;
|
||||
msg.channel.send("Disabled block detection");
|
||||
return;
|
||||
}
|
||||
|
||||
const threshold = args.threshold || 1000;
|
||||
const result = blockedAt(
|
||||
(time, stack) => {
|
||||
console.error(`Blocked for ${time}ms, operation started here:`, stack);
|
||||
},
|
||||
{ threshold },
|
||||
);
|
||||
stop = result.stop;
|
||||
msg.channel.send(`Block detection enabled with ${threshold}ms threshold`);
|
||||
},
|
||||
});
|
Loading…
Add table
Reference in a new issue