mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-30 05:37:59 +00:00
Misc
This commit is contained in:
parent
1074615927
commit
1fc8938ed4
@ -146,7 +146,8 @@
|
||||
"allowArrowFunctions": true
|
||||
}
|
||||
],
|
||||
"function-paren-newline": ["error", "multiline"],
|
||||
"function-paren-newline": ["error", "multiline-arguments"],
|
||||
"comma-dangle": ["warn", "always-multiline"],
|
||||
"key-spacing": "error",
|
||||
"keyword-spacing": "error",
|
||||
"lines-around-comment": "error",
|
||||
|
@ -1,30 +1,29 @@
|
||||
// @ts-check
|
||||
'use strict';
|
||||
|
||||
const { isMaster } = require('../../utils/config');
|
||||
const { managesGroup, removeGroup } = require('../../stores/group');
|
||||
|
||||
/** @param { import('../../typings/context').ExtendedContext } ctx */
|
||||
const leaveCommandHandler = async ctx => {
|
||||
const { chat, message, telegram, state, replyWithHTML } = ctx;
|
||||
const { isMaster } = state;
|
||||
if (!isMaster) return null;
|
||||
const { chat, message, telegram, replyWithHTML } = ctx;
|
||||
if (!isMaster(ctx.from)) return null;
|
||||
|
||||
const groupName = message.text.split(' ').slice(1).join(' ');
|
||||
|
||||
if (groupName) {
|
||||
const group = /^-?\d+/.test(groupName)
|
||||
? { id: Number(groupName) }
|
||||
: { title: groupName };
|
||||
: { title: groupName };
|
||||
const isGroup = await managesGroup(group);
|
||||
if (!isGroup) {
|
||||
// eslint-disable-next-line function-paren-newline
|
||||
return replyWithHTML(
|
||||
'ℹ️ <b>Couldn\'t find a group with that ID/name.</b>'
|
||||
// eslint-disable-next-line function-paren-newline
|
||||
);
|
||||
}
|
||||
await Promise.all([
|
||||
removeGroup(isGroup),
|
||||
telegram.leaveChat(isGroup.id)
|
||||
telegram.leaveChat(isGroup.id),
|
||||
]);
|
||||
return replyWithHTML('✅ <b>I no longer manage that group.</b>');
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
'use strict';
|
||||
|
||||
// Bot
|
||||
@ -7,7 +8,7 @@ const { admin } = require('../../stores/user');
|
||||
const { addGroup } = require('../../stores/group');
|
||||
const { isMaster } = require('../../utils/config');
|
||||
|
||||
/** @param { import('telegraf').ContextMessageUpdate } ctx */
|
||||
/** @param { import('telegraf').Context } ctx */
|
||||
const addedToGroupHandler = async (ctx, next) => {
|
||||
const msg = ctx.message;
|
||||
|
||||
@ -19,14 +20,14 @@ const addedToGroupHandler = async (ctx, next) => {
|
||||
? `https://t.me/${ctx.chat.username.toLowerCase()}`
|
||||
: await ctx.exportChatInviteLink().catch(() => '');
|
||||
if (!link) {
|
||||
// eslint-disable-next-line function-paren-newline
|
||||
await ctx.replyWithHTML(
|
||||
'⚠️ <b>Failed to export chat invite link.</b>\n' +
|
||||
'Group won\'t be visible in /groups list.\n' +
|
||||
'\n' +
|
||||
'If this isn\'t your intention, ' +
|
||||
'make sure I am permitted to export chat invite link, ' +
|
||||
'and then run /showgroup.');
|
||||
'and then run /showgroup.'
|
||||
);
|
||||
}
|
||||
const { id, title, type } = ctx.chat;
|
||||
await addGroup({ id, link, title, type });
|
||||
|
@ -5,6 +5,7 @@
|
||||
"noImplicitAny": false,
|
||||
"noEmit": true,
|
||||
"resolveJsonModule": true,
|
||||
"strictNullChecks": false,
|
||||
"strict": true,
|
||||
"target": "ES2020"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user