Added conditional to respond appositely to private messages. Added documentation. Denoted which commands are only available to admins or in private.

This commit is contained in:
2025-09-29 01:03:15 -04:00
parent 5d5c96147c
commit f061275ce6

View File

@@ -4,25 +4,41 @@ import { logHandle } from "#root/bot/helpers/logging.js";
const composer = new Composer<Context>(); const composer = new Composer<Context>();
const feature = composer.chatType(["group", "supergroup"]); const feature = composer.chatType(["group", "supergroup", "private"]);
feature.hears( /**
"/help", * What triggers this feature and adds to the log when it has been triggered.
logHandle("blacklist-detection"), * The trigger is the command "/help"
async (ctx: Context) => { */
feature.hears("/help", logHandle("help"), async (ctx: Context) => {
const GROUP_IDS = process.env.GROUP_IDS const GROUP_IDS = process.env.GROUP_IDS
? process.env.GROUP_IDS.split(",") ? process.env.GROUP_IDS.split(",")
: undefined; : undefined;
// Checks there is a chat and msg property in the context.
if (ctx.chat && ctx.msg) { if (ctx.chat && ctx.msg) {
// CHecks if the chat is private
if (ctx.chat.type === "private") {
// Responds with the command list.
return await ctx.reply(
`**Here are the available commands you can use:**\n\n/getGroupID _ADMIN ONLY | Only available in groups_\\- Replies with the ID of the group I am in\\.\n\n/isWKCGRoup _ADMIN ONLY_ \\- Checks if this group's ID is on the whitelist and responds accordingly\\.\n\n/botInfo _Private Command_\\- Info about me and how to fork me to deploy for your own use\\.\n\n/help\\- Displays this help message\\.`,
{
parse_mode: "MarkdownV2",
reply_parameters: { message_id: ctx.msg.message_id }
}
);
}
// Checks if the whitelist is set up.
if (GROUP_IDS !== undefined) { if (GROUP_IDS !== undefined) {
const groupID = ctx.chat.id; const groupID = ctx.chat.id;
const flag = GROUP_IDS.includes(`${groupID}`); const flag = GROUP_IDS.includes(`${groupID}`);
// const username = ctx.msg.from?.username;
// Checks if the chat is in the whitelist.
if (flag) { if (flag) {
await ctx.reply( // Responds with the command list.
`**Here are the availible commands you can use:**\n\n/getGroupID \\- replied with the ID of the group I am in\\.\n\n/isLCMGRoup \\- Checks if this group's ID is on the whitelist and responds accordingly\\.\n\n/botInfo \\- Info about me and how to fork me to deploy for your own use\\.\n\n/help \\- Displays this help message\\.`, return await ctx.reply(
`**Here are the available commands you can use:**\n\n/getGroupID _ADMIN ONLY_ \\- Replies with the ID of the group I am in\\.\n\n/isWKCGRoup _ADMIN ONLY_ \\- Checks if this group's ID is on the whitelist and responds accordingly\\.\n\n/botInfo _Private Command_\\- Info about me and how to fork me to deploy for your own use\\.\n\n/help\\- Displays this help message\\.`,
{ {
parse_mode: "MarkdownV2", parse_mode: "MarkdownV2",
reply_parameters: { message_id: ctx.msg.message_id } reply_parameters: { message_id: ctx.msg.message_id }
@@ -30,16 +46,21 @@ feature.hears(
); );
} }
// Checks if the chat is not in the whitelist.
if (!flag) { if (!flag) {
await ctx.reply( await ctx
`**Since this is not a whitelisted group the features are limited\\!\\!**\n\nHere are the availible commands you can use:\n\n/isLCMGRoup \\- Checks if this group's ID is on the whitelist and responds accordingly\\.\n\n/botInfo \\- Info about me and how to fork me to deploy for your own use\\.\n\n/help \\- Displays this help message\\.`, // Responds with the command list with a warning that the available commands are limited.
.reply(
`**Since this is not a whitelisted group the features are limited\\!\\!**\n\nHere are the available commands you can use:\n\n/isWKCGRoup _ADMIN ONLY_\\- Checks if this group's ID is on the whitelist and responds accordingly\\.\n\n/botInfo _Private Command_\\- Info about me and how to fork me to deploy for your own use\\.\n\n/help \\- Displays this help message\\.`,
{ {
parse_mode: "MarkdownV2", parse_mode: "MarkdownV2",
reply_parameters: { message_id: ctx.msg.message_id } reply_parameters: { message_id: ctx.msg.message_id }
} }
); )
await ctx.reply( .then(() => {});
`This group is NOT in the whitelisted and is NOT a part of the LCM Telegram groups/communities\\. I am a bot designed to delete any Twitter/X links and reformatting services within groups\\. You can fork me from this link: https://github\\.com/lucid\\-creations\\-media/no\\-twitter\\-bot and deploy me for use in your own groups\\!`, // Sends a follow-up message with information about the bot.
return await ctx.reply(
`This group is NOT in the whitelisted and is NOT a part of the WKC Telegram groups/communities\\. I am a bot designed to delete any Twitter/X and Meta links along with corresponding reformatting services within whitelisted groups\\. You can fork me from this link: https://github\\.com/lucid\\-creations\\-media/no\\-twitter\\-bot and deploy me for use in your own groups\\!`,
{ {
parse_mode: "MarkdownV2", parse_mode: "MarkdownV2",
reply_parameters: { message_id: ctx.msg.message_id } reply_parameters: { message_id: ctx.msg.message_id }
@@ -48,9 +69,11 @@ feature.hears(
} }
} }
// Checks if the whitelist is not set up.
if (!GROUP_IDS) { if (!GROUP_IDS) {
await ctx.reply( // Sends a warning that the whitelist is not set up or the bot cannot access it.
`There was a problem retrieving the whitelist. Check the env variables and try again\\.`, return await ctx.reply(
`There was a problem retrieving the whitelist\\. Check the env variables and try again\\.`,
{ {
parse_mode: "MarkdownV2", parse_mode: "MarkdownV2",
reply_parameters: { message_id: ctx.msg.message_id } reply_parameters: { message_id: ctx.msg.message_id }
@@ -58,7 +81,6 @@ feature.hears(
); );
} }
} }
} });
);
export { composer as helpCommand }; export { composer as helpCommand };