Added comments.

This commit is contained in:
2026-04-14 18:01:44 -04:00
parent 547fef9c75
commit aaac8c3aa7
12 changed files with 21 additions and 6 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
"type": "module", "type": "module",
"version": "3.2.0", "version": "3.2.0",
"private": true, "private": true,
"packageManager": "yarn@4.12.0", "packageManager": "yarn@4.13.0",
"description": "This grammY powered Telegram bot is designed to delete Twitter/X links and reformat services from whitelisted groups. This one is the main bot for the LCM Telegram groups/communities.", "description": "This grammY powered Telegram bot is designed to delete Twitter/X links and reformat services from whitelisted groups. This one is the main bot for the LCM Telegram groups/communities.",
"imports": { "imports": {
"#root/*": "./build/src/*" "#root/*": "./build/src/*"
+1 -1
View File
@@ -32,7 +32,7 @@ feature.hears(
} }
await urql await urql
.mutation(increment, { command: true, mutationKey }) .mutation(increment, { command: true, mutationKey }) // Increments the trigger count
.toPromise() .toPromise()
.then(async () => { .then(async () => {
if (ctx.msg) { if (ctx.msg) {
+1 -1
View File
@@ -32,7 +32,7 @@ feature.hears(
} }
await urql await urql
.mutation(increment, { command: true, mutationKey }) .mutation(increment, { command: true, mutationKey }) // Increments the trigger count
.toPromise() .toPromise()
.then(async () => { .then(async () => {
if (ctx.msg) { if (ctx.msg) {
+3
View File
@@ -18,7 +18,9 @@ feature.hears(/^\/help/, logHandle("help"), async (ctx: Context) => {
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || ""; const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
const statsSite = process.env.STATS_SITE || ""; const statsSite = process.env.STATS_SITE || "";
// Increments the trigger count
await urql.mutation(increment, { trigger: true, mutationKey }); await urql.mutation(increment, { trigger: true, mutationKey });
// Retrieve the command list
const commandsListArr = await getCommandsList(`${statsSite}api/bot`, apiKey); const commandsListArr = await getCommandsList(`${statsSite}api/bot`, apiKey);
// const GROUP_IDS = process.env.GROUP_IDS // const GROUP_IDS = process.env.GROUP_IDS
@@ -67,6 +69,7 @@ feature.hears(/^\/help/, logHandle("help"), async (ctx: Context) => {
} }
} }
// Create a readable command list string.
const commandsListStr = commandsListArr.reduce((prev, curr) => { const commandsListStr = commandsListArr.reduce((prev, curr) => {
const { command, description, groups } = curr; const { command, description, groups } = curr;
+2
View File
@@ -21,8 +21,10 @@ feature.hears(
async (ctx: Context) => { async (ctx: Context) => {
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || ""; const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
// Increments the trigger count
await urql.mutation(increment, { trigger: true, mutationKey }); await urql.mutation(increment, { trigger: true, mutationKey });
// Checks there is a chat and msg property in the context.
if (ctx.chat && ctx.msg) { if (ctx.chat && ctx.msg) {
const username = ctx.msg.from?.username; const username = ctx.msg.from?.username;
+1
View File
@@ -19,6 +19,7 @@ feature.hears(
async (ctx: Context) => { async (ctx: Context) => {
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || ""; const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
// Increments the trigger count
await urql.mutation(increment, { trigger: true, mutationKey }); await urql.mutation(increment, { trigger: true, mutationKey });
// Checks if the context includes a message property. // Checks if the context includes a message property.
+1
View File
@@ -21,6 +21,7 @@ feature.hears(
async (ctx: Context) => { async (ctx: Context) => {
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || ""; const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
// Increments the trigger count
await urql.mutation(increment, { trigger: true, mutationKey }); await urql.mutation(increment, { trigger: true, mutationKey });
if (ctx.chat && ctx.msg) { if (ctx.chat && ctx.msg) {
+1
View File
@@ -15,6 +15,7 @@ const feature = composer.chatType("private");
feature.command("start", logHandle("command-start"), async ctx => { feature.command("start", logHandle("command-start"), async ctx => {
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || ""; const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
// Increments the trigger count
await urql.mutation(increment, { trigger: true, mutationKey }); await urql.mutation(increment, { trigger: true, mutationKey });
await urql await urql
+7
View File
@@ -6,6 +6,13 @@ export interface Commands {
groups: boolean; groups: boolean;
private: boolean; private: boolean;
} }
/**
* Fetched a list of commands with a provided url and API key.
* @param url The url to query.
* @interface Commands
* @param apiKey The api for the url.
* @returns Array of Commands object.
*/
const fetchCommandsList = async ( const fetchCommandsList = async (
url: string, url: string,
+1 -1
View File
@@ -6,7 +6,7 @@ const metaRegex =
* This function will check if a url matches Meta services links using regex. * This function will check if a url matches Meta services links using regex.
* *
* @param linkUrl representing a suspected url on the banlist * @param linkUrl representing a suspected url on the banlist
* @returns flag * @returns @type boolean
*/ */
const metaLinkCheck = (linkUrl: string): boolean => { const metaLinkCheck = (linkUrl: string): boolean => {
let flag = false; let flag = false;
+1 -1
View File
@@ -5,7 +5,7 @@ const tiktokRegex = /(tiktok\.com)/gi;
* This function will check if a url matches TikTok services links using regex. * This function will check if a url matches TikTok services links using regex.
* *
* @param linkUrl representing a suspected url on the banlist * @param linkUrl representing a suspected url on the banlist
* @return flag * @returns @type boolean
*/ */
const tiktokLinkCheck = (linkUrl: string): boolean => { const tiktokLinkCheck = (linkUrl: string): boolean => {
let flag = false; let flag = false;
+1 -1
View File
@@ -5,7 +5,7 @@ const twitterRegex = /(x\.com|twitter\.com)/gi;
* This function will check if a url matches Twitter/X services links using regex. * This function will check if a url matches Twitter/X services links using regex.
* *
* @param linkUrl representing a suspected url on the banlist * @param linkUrl representing a suspected url on the banlist
* @return flag * @returns @type boolean
*/ */
const twitterLinkCheck = (linkUrl: string): boolean => { const twitterLinkCheck = (linkUrl: string): boolean => {
let flag = false; let flag = false;