Update imports and group info extraction from context.
This commit is contained in:
@@ -2,7 +2,7 @@ import { Composer } from "grammy";
|
|||||||
import type { Context } from "#root/bot/context.js";
|
import type { Context } from "#root/bot/context.js";
|
||||||
import { logHandle } from "#root/bot/helpers/logging.js";
|
import { logHandle } from "#root/bot/helpers/logging.js";
|
||||||
import { urql } from "#root/main.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrementMutation.js";
|
||||||
|
|
||||||
const composer = new Composer<Context>();
|
const composer = new Composer<Context>();
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { logHandle } from "#root/bot/helpers/logging.js";
|
|||||||
import metaLinkCheck from "#root/lib/metaLinkCheck.js";
|
import metaLinkCheck from "#root/lib/metaLinkCheck.js";
|
||||||
import twitterLinkCheck from "#root/lib/twitterLinkCheck.js";
|
import twitterLinkCheck from "#root/lib/twitterLinkCheck.js";
|
||||||
import { urql } from "#root/main.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrementMutation.js";
|
||||||
import addGroup from "#root/lib/graphql/mutations/addGroupMutation.js";
|
import addGroup from "#root/lib/graphql/mutations/addGroupMutation.js";
|
||||||
import incrementGroup from "#root/lib/graphql/mutations/incrementGroupMutation.js";
|
import incrementGroup from "#root/lib/graphql/mutations/incrementGroupMutation.js";
|
||||||
|
|
||||||
@@ -22,9 +22,9 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
|
|||||||
await urql.mutation(increment, { trigger: true, mutationKey });
|
await urql.mutation(increment, { trigger: true, mutationKey });
|
||||||
|
|
||||||
if (ctx.chat && ctx.msg) {
|
if (ctx.chat && ctx.msg) {
|
||||||
const groupName = ctx.chat?.title;
|
const groupName = ctx.chat?.title || "";
|
||||||
const groupID = ctx.chat?.id;
|
const groupID = ctx.chat?.id.toString() || "";
|
||||||
const groupUsername = ctx.chat?.username;
|
const groupUsername = ctx.chat?.username || "";
|
||||||
let deletedLinks = 0;
|
let deletedLinks = 0;
|
||||||
|
|
||||||
const username = ctx.msg.from?.username;
|
const username = ctx.msg.from?.username;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Composer } from "grammy";
|
|||||||
import type { Context } from "#root/bot/context.js";
|
import type { Context } from "#root/bot/context.js";
|
||||||
import { logHandle } from "#root/bot/helpers/logging.js";
|
import { logHandle } from "#root/bot/helpers/logging.js";
|
||||||
import { urql } from "#root/main.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrementMutation.js";
|
||||||
|
|
||||||
const composer = new Composer<Context>();
|
const composer = new Composer<Context>();
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { Context } from "#root/bot/context.js";
|
|||||||
import { logHandle } from "#root/bot/helpers/logging.js";
|
import { logHandle } from "#root/bot/helpers/logging.js";
|
||||||
import { metaRegex } from "#root/lib/metaLinkCheck.js";
|
import { metaRegex } from "#root/lib/metaLinkCheck.js";
|
||||||
import { urql } from "#root/main.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrementMutation.js";
|
||||||
import addGroup from "#root/lib/graphql/mutations/addGroupMutation.js";
|
import addGroup from "#root/lib/graphql/mutations/addGroupMutation.js";
|
||||||
import incrementGroup from "#root/lib/graphql/mutations/incrementGroupMutation.js";
|
import incrementGroup from "#root/lib/graphql/mutations/incrementGroupMutation.js";
|
||||||
|
|
||||||
@@ -32,16 +32,16 @@ feature.hears(
|
|||||||
.mutation(increment, { link: true, mutationKey })
|
.mutation(increment, { link: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg && ctx.chat) {
|
||||||
// Replies to the user informing them of the action.
|
// Replies to the user informing them of the action.
|
||||||
await ctx.reply(
|
await ctx.reply(
|
||||||
`@${username} Facebook and meta links along with with links to meta\\-owned services are not allowed here\\. Please consider sharing the media directly or from other social media sources or websites\\. No administration action was taken against you other than the message being deleted\\.`,
|
`@${username} Facebook and meta links along with with links to meta\\-owned services are not allowed here\\. Please consider sharing the media directly or from other social media sources or websites\\. No administration action was taken against you other than the message being deleted\\.`,
|
||||||
{ parse_mode: "MarkdownV2" }
|
{ parse_mode: "MarkdownV2" }
|
||||||
);
|
);
|
||||||
|
|
||||||
const groupName = ctx.chat?.title;
|
const groupName = ctx.chat?.title || "";
|
||||||
const groupID = ctx.chat?.id;
|
const groupID = ctx.chat?.id.toString() || "";
|
||||||
const groupUsername = ctx.chat?.username;
|
const groupUsername = ctx.chat?.username || "";
|
||||||
|
|
||||||
return await urql
|
return await urql
|
||||||
.mutation(addGroup, {
|
.mutation(addGroup, {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { Context } from "#root/bot/context.js";
|
|||||||
import { logHandle } from "#root/bot/helpers/logging.js";
|
import { logHandle } from "#root/bot/helpers/logging.js";
|
||||||
import { twitterRegex } from "#root/lib/twitterLinkCheck.js";
|
import { twitterRegex } from "#root/lib/twitterLinkCheck.js";
|
||||||
import { urql } from "#root/main.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrementMutation.js";
|
||||||
import addGroup from "#root/lib/graphql/mutations/addGroupMutation.js";
|
import addGroup from "#root/lib/graphql/mutations/addGroupMutation.js";
|
||||||
import incrementGroup from "#root/lib/graphql/mutations/incrementGroupMutation.js";
|
import incrementGroup from "#root/lib/graphql/mutations/incrementGroupMutation.js";
|
||||||
|
|
||||||
@@ -32,16 +32,16 @@ feature.hears(
|
|||||||
.mutation(increment, { link: true, mutationKey })
|
.mutation(increment, { link: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg && ctx.chat) {
|
||||||
// Replies to the user informing them of the action.
|
// Replies to the user informing them of the action.
|
||||||
await ctx.reply(
|
await ctx.reply(
|
||||||
`@${username} Twitter and X links along with reformatting services for Twitter posts are not allowed here\\. Please consider sharing the media directly or from other social media sources or websites\\. No administration action was taken against you other than the message being deleted\\.`,
|
`@${username} Twitter and X links along with reformatting services for Twitter posts are not allowed here\\. Please consider sharing the media directly or from other social media sources or websites\\. No administration action was taken against you other than the message being deleted\\.`,
|
||||||
{ parse_mode: "MarkdownV2" }
|
{ parse_mode: "MarkdownV2" }
|
||||||
);
|
);
|
||||||
|
|
||||||
const groupName = ctx.chat?.title;
|
const groupName = ctx.chat?.title || "";
|
||||||
const groupID = ctx.chat?.id;
|
const groupID = ctx.chat?.id.toString() || "";
|
||||||
const groupUsername = ctx.chat?.username;
|
const groupUsername = ctx.chat?.username || "";
|
||||||
|
|
||||||
return await urql
|
return await urql
|
||||||
.mutation(addGroup, {
|
.mutation(addGroup, {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Composer } from "grammy";
|
|||||||
import type { Context } from "#root/bot/context.js";
|
import type { Context } from "#root/bot/context.js";
|
||||||
import { logHandle } from "#root/bot/helpers/logging.js";
|
import { logHandle } from "#root/bot/helpers/logging.js";
|
||||||
import { urql } from "#root/main.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrementMutation.js";
|
||||||
|
|
||||||
const composer = new Composer<Context>();
|
const composer = new Composer<Context>();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user