diff --git a/package.json b/package.json index 0558cae..3cc3e0f 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "type": "module", "version": "3.2.0", "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.", "imports": { "#root/*": "./build/src/*" diff --git a/src/bot/features/botInfoCommand.ts b/src/bot/features/botInfoCommand.ts index da23a32..1c6ebb8 100644 --- a/src/bot/features/botInfoCommand.ts +++ b/src/bot/features/botInfoCommand.ts @@ -32,7 +32,7 @@ feature.hears( } await urql - .mutation(increment, { command: true, mutationKey }) + .mutation(increment, { command: true, mutationKey }) // Increments the trigger count .toPromise() .then(async () => { if (ctx.msg) { diff --git a/src/bot/features/botStatsSiteCommand.ts b/src/bot/features/botStatsSiteCommand.ts index cb090c2..f71b47a 100644 --- a/src/bot/features/botStatsSiteCommand.ts +++ b/src/bot/features/botStatsSiteCommand.ts @@ -32,7 +32,7 @@ feature.hears( } await urql - .mutation(increment, { command: true, mutationKey }) + .mutation(increment, { command: true, mutationKey }) // Increments the trigger count .toPromise() .then(async () => { if (ctx.msg) { diff --git a/src/bot/features/helpCommand.ts b/src/bot/features/helpCommand.ts index 9381d82..6ee6a05 100644 --- a/src/bot/features/helpCommand.ts +++ b/src/bot/features/helpCommand.ts @@ -18,7 +18,9 @@ feature.hears(/^\/help/, logHandle("help"), async (ctx: Context) => { const mutationKey = process.env.GRAPHQL_MUTATION_KEY || ""; const statsSite = process.env.STATS_SITE || ""; + // Increments the trigger count await urql.mutation(increment, { trigger: true, mutationKey }); + // Retrieve the command list const commandsListArr = await getCommandsList(`${statsSite}api/bot`, apiKey); // 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 { command, description, groups } = curr; diff --git a/src/bot/features/metaBanlist.ts b/src/bot/features/metaBanlist.ts index 5f597cb..24a1760 100644 --- a/src/bot/features/metaBanlist.ts +++ b/src/bot/features/metaBanlist.ts @@ -21,8 +21,10 @@ feature.hears( async (ctx: Context) => { const mutationKey = process.env.GRAPHQL_MUTATION_KEY || ""; + // Increments the trigger count await urql.mutation(increment, { trigger: true, mutationKey }); + // Checks there is a chat and msg property in the context. if (ctx.chat && ctx.msg) { const username = ctx.msg.from?.username; diff --git a/src/bot/features/registerGroupCommand.ts b/src/bot/features/registerGroupCommand.ts index 9bd9ee8..4a25be8 100644 --- a/src/bot/features/registerGroupCommand.ts +++ b/src/bot/features/registerGroupCommand.ts @@ -19,6 +19,7 @@ feature.hears( async (ctx: Context) => { const mutationKey = process.env.GRAPHQL_MUTATION_KEY || ""; + // Increments the trigger count await urql.mutation(increment, { trigger: true, mutationKey }); // Checks if the context includes a message property. diff --git a/src/bot/features/tiktokBanlist.ts b/src/bot/features/tiktokBanlist.ts index 478a811..7449c66 100644 --- a/src/bot/features/tiktokBanlist.ts +++ b/src/bot/features/tiktokBanlist.ts @@ -21,6 +21,7 @@ feature.hears( async (ctx: Context) => { const mutationKey = process.env.GRAPHQL_MUTATION_KEY || ""; + // Increments the trigger count await urql.mutation(increment, { trigger: true, mutationKey }); if (ctx.chat && ctx.msg) { diff --git a/src/bot/features/welcome.ts b/src/bot/features/welcome.ts index 5dfd401..7e5ade2 100644 --- a/src/bot/features/welcome.ts +++ b/src/bot/features/welcome.ts @@ -15,6 +15,7 @@ const feature = composer.chatType("private"); feature.command("start", logHandle("command-start"), async ctx => { const mutationKey = process.env.GRAPHQL_MUTATION_KEY || ""; + // Increments the trigger count await urql.mutation(increment, { trigger: true, mutationKey }); await urql diff --git a/src/lib/getCommandsList.ts b/src/lib/getCommandsList.ts index c5a3b37..ede5310 100644 --- a/src/lib/getCommandsList.ts +++ b/src/lib/getCommandsList.ts @@ -6,6 +6,13 @@ export interface Commands { groups: 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 ( url: string, diff --git a/src/lib/metaLinkCheck.ts b/src/lib/metaLinkCheck.ts index 9e24bd0..f7e463c 100644 --- a/src/lib/metaLinkCheck.ts +++ b/src/lib/metaLinkCheck.ts @@ -6,7 +6,7 @@ const metaRegex = * This function will check if a url matches Meta services links using regex. * * @param linkUrl representing a suspected url on the banlist - * @returns flag + * @returns @type boolean */ const metaLinkCheck = (linkUrl: string): boolean => { let flag = false; diff --git a/src/lib/tiktokLinkCheck.ts b/src/lib/tiktokLinkCheck.ts index 6e72f56..69a0135 100644 --- a/src/lib/tiktokLinkCheck.ts +++ b/src/lib/tiktokLinkCheck.ts @@ -5,7 +5,7 @@ const tiktokRegex = /(tiktok\.com)/gi; * This function will check if a url matches TikTok services links using regex. * * @param linkUrl representing a suspected url on the banlist - * @return flag + * @returns @type boolean */ const tiktokLinkCheck = (linkUrl: string): boolean => { let flag = false; diff --git a/src/lib/twitterLinkCheck.ts b/src/lib/twitterLinkCheck.ts index 4dabde3..43d7b58 100644 --- a/src/lib/twitterLinkCheck.ts +++ b/src/lib/twitterLinkCheck.ts @@ -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. * * @param linkUrl representing a suspected url on the banlist - * @return flag + * @returns @type boolean */ const twitterLinkCheck = (linkUrl: string): boolean => { let flag = false;