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,53 +4,63 @@ 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) => { */
const GROUP_IDS = process.env.GROUP_IDS feature.hears("/help", logHandle("help"), async (ctx: Context) => {
? process.env.GROUP_IDS.split(",") const GROUP_IDS = process.env.GROUP_IDS
: undefined; ? process.env.GROUP_IDS.split(",")
: undefined;
if (ctx.chat && ctx.msg) { // Checks there is a chat and msg property in the context.
if (GROUP_IDS !== undefined) { if (ctx.chat && ctx.msg) {
const groupID = ctx.chat.id; // CHecks if the chat is private
const flag = GROUP_IDS.includes(`${groupID}`); if (ctx.chat.type === "private") {
// const username = ctx.msg.from?.username; // Responds with the command list.
return await ctx.reply(
if (flag) { `**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\\.`,
await ctx.reply( {
`**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\\.`, parse_mode: "MarkdownV2",
{ reply_parameters: { message_id: ctx.msg.message_id }
parse_mode: "MarkdownV2",
reply_parameters: { message_id: ctx.msg.message_id }
}
);
} }
);
}
if (!flag) { // Checks if the whitelist is set up.
await ctx.reply( if (GROUP_IDS !== undefined) {
`**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\\.`, const groupID = ctx.chat.id;
{ const flag = GROUP_IDS.includes(`${groupID}`);
parse_mode: "MarkdownV2",
reply_parameters: { message_id: ctx.msg.message_id } // Checks if the chat is in the whitelist.
} if (flag) {
); // Responds with the command list.
await ctx.reply( return await ctx.reply(
`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\\!`, `**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 }
} }
); );
}
} }
if (!GROUP_IDS) { // Checks if the chat is not in the whitelist.
await ctx.reply( if (!flag) {
`There was a problem retrieving the whitelist. Check the env variables and try again\\.`, await ctx
// 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",
reply_parameters: { message_id: ctx.msg.message_id }
}
)
.then(() => {});
// 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 }
@@ -58,7 +68,19 @@ feature.hears(
); );
} }
} }
// Checks if the whitelist is not set up.
if (!GROUP_IDS) {
// Sends a warning that the whitelist is not set up or the bot cannot access it.
return await ctx.reply(
`There was a problem retrieving the whitelist\\. Check the env variables and try again\\.`,
{
parse_mode: "MarkdownV2",
reply_parameters: { message_id: ctx.msg.message_id }
}
);
}
} }
); });
export { composer as helpCommand }; export { composer as helpCommand };