Compare commits
3 Commits
graphql
...
2050e61706
| Author | SHA1 | Date | |
|---|---|---|---|
| 2050e61706 | |||
| 465fbf96c9 | |||
| 30546606d7 |
@@ -1,13 +1,15 @@
|
|||||||
import { Composer } from "grammy";
|
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/lib/urql.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
||||||
|
|
||||||
const composer = new Composer<Context>();
|
const composer = new Composer<Context>();
|
||||||
|
|
||||||
const feature = composer.chatType(["private", "group", "supergroup"]);
|
const feature = composer.chatType(["private", "group", "supergroup"]);
|
||||||
|
|
||||||
|
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What triggers this feature and adds to the log when it has been triggered.
|
* What triggers this feature and adds to the log when it has been triggered.
|
||||||
* The trigger is the command "/botInfo"
|
* The trigger is the command "/botInfo"
|
||||||
@@ -16,7 +18,7 @@ feature.hears(
|
|||||||
/^\/botInfo/,
|
/^\/botInfo/,
|
||||||
logHandle("bot-info-command"),
|
logHandle("bot-info-command"),
|
||||||
async (ctx: Context) => {
|
async (ctx: Context) => {
|
||||||
await urql.mutation(increment, { trigger: true });
|
await urql.mutation(increment, { trigger: true, mutationKey });
|
||||||
|
|
||||||
// Checks if the context includes a message property.
|
// Checks if the context includes a message property.
|
||||||
if (ctx.msg && ctx.chat && ctx.msg.from) {
|
if (ctx.msg && ctx.chat && ctx.msg.from) {
|
||||||
@@ -30,7 +32,7 @@ feature.hears(
|
|||||||
}
|
}
|
||||||
|
|
||||||
await urql
|
await urql
|
||||||
.mutation(increment, { command: true })
|
.mutation(increment, { command: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg) {
|
||||||
|
|||||||
@@ -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 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/lib/urql.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrimentMutation.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";
|
||||||
@@ -12,12 +12,14 @@ const composer = new Composer<Context>();
|
|||||||
|
|
||||||
const feature = composer.chatType(["group", "supergroup"]);
|
const feature = composer.chatType(["group", "supergroup"]);
|
||||||
|
|
||||||
|
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What triggers this feature and adds to the log when it has been triggered.
|
* What triggers this feature and adds to the log when it has been triggered.
|
||||||
* The trigger is anytime an embedded url is detected.
|
* The trigger is anytime an embedded url is detected.
|
||||||
*/
|
*/
|
||||||
feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
|
feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
|
||||||
await urql.mutation(increment, { trigger: true });
|
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;
|
||||||
@@ -49,7 +51,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
|
|||||||
deletedLinks++;
|
deletedLinks++;
|
||||||
|
|
||||||
await urql
|
await urql
|
||||||
.mutation(increment, { link: true })
|
.mutation(increment, { link: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg) {
|
||||||
@@ -69,7 +71,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
|
|||||||
deletedLinks++;
|
deletedLinks++;
|
||||||
|
|
||||||
await urql
|
await urql
|
||||||
.mutation(increment, { link: true })
|
.mutation(increment, { link: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg) {
|
||||||
@@ -89,7 +91,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
|
|||||||
deletedLinks++;
|
deletedLinks++;
|
||||||
|
|
||||||
await urql
|
await urql
|
||||||
.mutation(increment, { link: true })
|
.mutation(increment, { link: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg) {
|
||||||
@@ -114,7 +116,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
|
|||||||
deletedLinks++;
|
deletedLinks++;
|
||||||
|
|
||||||
await urql
|
await urql
|
||||||
.mutation(increment, { link: true })
|
.mutation(increment, { link: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg) {
|
||||||
@@ -134,7 +136,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
|
|||||||
deletedLinks++;
|
deletedLinks++;
|
||||||
|
|
||||||
await urql
|
await urql
|
||||||
.mutation(increment, { link: true })
|
.mutation(increment, { link: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg) {
|
||||||
@@ -154,7 +156,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
|
|||||||
deletedLinks++;
|
deletedLinks++;
|
||||||
|
|
||||||
await urql
|
await urql
|
||||||
.mutation(increment, { link: true })
|
.mutation(increment, { link: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg) {
|
||||||
@@ -169,12 +171,18 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
|
|||||||
|
|
||||||
if (deletedLinks) {
|
if (deletedLinks) {
|
||||||
return await urql
|
return await urql
|
||||||
.mutation(addGroup, { groupID, groupName, groupUsername })
|
.mutation(addGroup, {
|
||||||
|
groupID,
|
||||||
|
groupName,
|
||||||
|
groupUsername,
|
||||||
|
mutationKey
|
||||||
|
})
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(() =>
|
.then(() =>
|
||||||
urql.mutation(incrementGroup, {
|
urql.mutation(incrementGroup, {
|
||||||
groupID,
|
groupID,
|
||||||
linksDeleted: deletedLinks
|
linksDeleted: deletedLinks,
|
||||||
|
mutationKey
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
import { Composer } from "grammy";
|
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/lib/urql.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
||||||
|
|
||||||
const composer = new Composer<Context>();
|
const composer = new Composer<Context>();
|
||||||
|
|
||||||
const feature = composer.chatType(["group", "supergroup", "private"]);
|
const feature = composer.chatType(["group", "supergroup", "private"]);
|
||||||
|
|
||||||
|
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What triggers this feature and adds to the log when it has been triggered.
|
* What triggers this feature and adds to the log when it has been triggered.
|
||||||
* The trigger is the command "/help"
|
* The trigger is the command "/help"
|
||||||
*/
|
*/
|
||||||
feature.hears(/^\/help/, logHandle("help"), async (ctx: Context) => {
|
feature.hears(/^\/help/, logHandle("help"), async (ctx: Context) => {
|
||||||
await urql.mutation(increment, { trigger: true });
|
await urql.mutation(increment, { trigger: true, mutationKey });
|
||||||
|
|
||||||
// const GROUP_IDS = process.env.GROUP_IDS
|
// const GROUP_IDS = process.env.GROUP_IDS
|
||||||
// ? process.env.GROUP_IDS.split(",")
|
// ? process.env.GROUP_IDS.split(",")
|
||||||
@@ -22,7 +24,7 @@ feature.hears(/^\/help/, logHandle("help"), async (ctx: Context) => {
|
|||||||
// Checks there is a chat and msg property in the context.
|
// Checks there is a chat and msg property in the context.
|
||||||
if (ctx.chat && ctx.msg && ctx.msg.from) {
|
if (ctx.chat && ctx.msg && ctx.msg.from) {
|
||||||
await urql
|
await urql
|
||||||
.mutation(increment, { command: true })
|
.mutation(increment, { command: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg && ctx.chat && ctx.msg.from) {
|
if (ctx.msg && ctx.chat && ctx.msg.from) {
|
||||||
|
|||||||
@@ -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 { metaRegex } from "#root/lib/metaLinkCheck.js";
|
import { metaRegex } from "#root/lib/metaLinkCheck.js";
|
||||||
import urql from "#root/lib/urql.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrimentMutation.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";
|
||||||
@@ -11,6 +11,8 @@ const composer = new Composer<Context>();
|
|||||||
|
|
||||||
const feature = composer.chatType(["group", "supergroup"]);
|
const feature = composer.chatType(["group", "supergroup"]);
|
||||||
|
|
||||||
|
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What triggers this feature and adds to the log when it has been triggered.
|
* What triggers this feature and adds to the log when it has been triggered.
|
||||||
* The trigger uses the global Twitter regex to detect Twitter and X links within messages.
|
* The trigger uses the global Twitter regex to detect Twitter and X links within messages.
|
||||||
@@ -19,7 +21,7 @@ feature.hears(
|
|||||||
metaRegex,
|
metaRegex,
|
||||||
logHandle("blacklist-detection-meta"),
|
logHandle("blacklist-detection-meta"),
|
||||||
async (ctx: Context) => {
|
async (ctx: Context) => {
|
||||||
await urql.mutation(increment, { trigger: true });
|
await urql.mutation(increment, { trigger: true, mutationKey });
|
||||||
|
|
||||||
if (ctx.chat && ctx.msg) {
|
if (ctx.chat && ctx.msg) {
|
||||||
const username = ctx.msg.from?.username;
|
const username = ctx.msg.from?.username;
|
||||||
@@ -27,7 +29,7 @@ feature.hears(
|
|||||||
ctx.msg.delete();
|
ctx.msg.delete();
|
||||||
|
|
||||||
return await urql
|
return await urql
|
||||||
.mutation(increment, { link: true })
|
.mutation(increment, { link: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg) {
|
||||||
@@ -42,10 +44,19 @@ feature.hears(
|
|||||||
const groupUsername = ctx.chat?.username;
|
const groupUsername = ctx.chat?.username;
|
||||||
|
|
||||||
return await urql
|
return await urql
|
||||||
.mutation(addGroup, { groupID, groupName, groupUsername })
|
.mutation(addGroup, {
|
||||||
|
groupID,
|
||||||
|
groupName,
|
||||||
|
groupUsername,
|
||||||
|
mutationKey
|
||||||
|
})
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(() =>
|
.then(() =>
|
||||||
urql.mutation(incrementGroup, { groupID, linksDeleted: 1 })
|
urql.mutation(incrementGroup, {
|
||||||
|
groupID,
|
||||||
|
linksDeleted: 1,
|
||||||
|
mutationKey
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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 { twitterRegex } from "#root/lib/twitterLinkCheck.js";
|
import { twitterRegex } from "#root/lib/twitterLinkCheck.js";
|
||||||
import urql from "#root/lib/urql.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrimentMutation.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";
|
||||||
@@ -11,6 +11,8 @@ const composer = new Composer<Context>();
|
|||||||
|
|
||||||
const feature = composer.chatType(["group", "supergroup"]);
|
const feature = composer.chatType(["group", "supergroup"]);
|
||||||
|
|
||||||
|
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What triggers this feature and adds to the log when it has been triggered.
|
* What triggers this feature and adds to the log when it has been triggered.
|
||||||
* The trigger uses the global Twitter regex to detect Twitter and X links within messages.
|
* The trigger uses the global Twitter regex to detect Twitter and X links within messages.
|
||||||
@@ -19,7 +21,7 @@ feature.hears(
|
|||||||
twitterRegex,
|
twitterRegex,
|
||||||
logHandle("blacklist-detection-twitter"),
|
logHandle("blacklist-detection-twitter"),
|
||||||
async (ctx: Context) => {
|
async (ctx: Context) => {
|
||||||
await urql.mutation(increment, { trigger: true });
|
await urql.mutation(increment, { trigger: true, mutationKey });
|
||||||
|
|
||||||
if (ctx.chat && ctx.msg) {
|
if (ctx.chat && ctx.msg) {
|
||||||
const username = ctx.msg.from?.username;
|
const username = ctx.msg.from?.username;
|
||||||
@@ -27,7 +29,7 @@ feature.hears(
|
|||||||
ctx.msg.delete();
|
ctx.msg.delete();
|
||||||
|
|
||||||
return await urql
|
return await urql
|
||||||
.mutation(increment, { link: true })
|
.mutation(increment, { link: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg) {
|
||||||
@@ -42,10 +44,19 @@ feature.hears(
|
|||||||
const groupUsername = ctx.chat?.username;
|
const groupUsername = ctx.chat?.username;
|
||||||
|
|
||||||
return await urql
|
return await urql
|
||||||
.mutation(addGroup, { groupID, groupName, groupUsername })
|
.mutation(addGroup, {
|
||||||
|
groupID,
|
||||||
|
groupName,
|
||||||
|
groupUsername,
|
||||||
|
mutationKey
|
||||||
|
})
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(() =>
|
.then(() =>
|
||||||
urql.mutation(incrementGroup, { groupID, linksDeleted: 1 })
|
urql.mutation(incrementGroup, {
|
||||||
|
groupID,
|
||||||
|
linksDeleted: 1,
|
||||||
|
mutationKey
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,21 +1,24 @@
|
|||||||
import { Composer } from "grammy";
|
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/lib/urql.js";
|
import { urql } from "#root/main.js";
|
||||||
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
import increment from "#root/lib/graphql/mutations/incrimentMutation.js";
|
||||||
|
|
||||||
const composer = new Composer<Context>();
|
const composer = new Composer<Context>();
|
||||||
|
|
||||||
const feature = composer.chatType("private");
|
const feature = composer.chatType("private");
|
||||||
|
|
||||||
|
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What triggers this feature and adds to the log when it has been triggered.
|
* What triggers this feature and adds to the log when it has been triggered.
|
||||||
* The trigger is the command "/start" or "start"
|
* The trigger is the command "/start" or "start"
|
||||||
*/
|
*/
|
||||||
feature.command("start", logHandle("command-start"), async ctx => {
|
feature.command("start", logHandle("command-start"), async ctx => {
|
||||||
await urql.mutation(increment, { trigger: true });
|
await urql.mutation(increment, { trigger: true, mutationKey });
|
||||||
|
|
||||||
await urql
|
await urql
|
||||||
.mutation(increment, { command: true })
|
.mutation(increment, { command: true, mutationKey })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (ctx.msg) {
|
if (ctx.msg) {
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ const addGroup = gql`
|
|||||||
$groupID: BigInt
|
$groupID: BigInt
|
||||||
$groupName: String
|
$groupName: String
|
||||||
$groupUsername: String
|
$groupUsername: String
|
||||||
|
$mutationKey: String
|
||||||
) {
|
) {
|
||||||
addGroup(
|
addGroup(
|
||||||
groupID: $groupID
|
groupID: $groupID
|
||||||
groupName: $groupName
|
groupName: $groupName
|
||||||
groupUsername: $groupUsername
|
groupUsername: $groupUsername
|
||||||
|
mutationKey: $mutationKey
|
||||||
) {
|
) {
|
||||||
telegramID
|
telegramID
|
||||||
name
|
name
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
import { gql } from "@urql/core";
|
import { gql } from "@urql/core";
|
||||||
|
|
||||||
const incrementGroup = gql`
|
const incrementGroup = gql`
|
||||||
mutation incrementGroup($groupID: BigInt, $linksDeleted: Int) {
|
mutation incrementGroup(
|
||||||
incrementGroup(groupID: $groupID, linksDeleted: $linksDeleted) {
|
$groupID: BigInt
|
||||||
|
$linksDeleted: Int
|
||||||
|
$mutationKey: String
|
||||||
|
) {
|
||||||
|
incrementGroup(
|
||||||
|
groupID: $groupID
|
||||||
|
linksDeleted: $linksDeleted
|
||||||
|
mutationKey: $mutationKey
|
||||||
|
) {
|
||||||
telegramID
|
telegramID
|
||||||
name
|
name
|
||||||
username
|
username
|
||||||
|
|||||||
@@ -1,8 +1,18 @@
|
|||||||
import { gql } from "@urql/core";
|
import { gql } from "@urql/core";
|
||||||
|
|
||||||
const increment = gql`
|
const increment = gql`
|
||||||
mutation increment($command: Boolean, $link: Boolean, $trigger: Boolean) {
|
mutation increment(
|
||||||
increment(command: $command, link: $link, trigger: $trigger) {
|
$command: Boolean
|
||||||
|
$link: Boolean
|
||||||
|
$trigger: Boolean
|
||||||
|
$mutationKey: String
|
||||||
|
) {
|
||||||
|
increment(
|
||||||
|
command: $command
|
||||||
|
link: $link
|
||||||
|
trigger: $trigger
|
||||||
|
mutationKey: $mutationKey
|
||||||
|
) {
|
||||||
createdAt
|
createdAt
|
||||||
updatedAt
|
updatedAt
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
import { Client, cacheExchange, fetchExchange } from "@urql/core";
|
|
||||||
|
|
||||||
const urql = new Client({
|
|
||||||
url: process.env.GRAPHQL_URL || "",
|
|
||||||
exchanges: [cacheExchange, fetchExchange],
|
|
||||||
fetchOptions: {
|
|
||||||
headers: {
|
|
||||||
"x-api-key": process.env?.GRAPHQL_API_TOKEN || ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export default urql;
|
|
||||||
11
src/main.ts
11
src/main.ts
@@ -8,6 +8,7 @@ import { config } from "#root/config.js";
|
|||||||
import { logger } from "#root/logger.js";
|
import { logger } from "#root/logger.js";
|
||||||
import { createServer, createServerManager } from "#root/server/index.js";
|
import { createServer, createServerManager } from "#root/server/index.js";
|
||||||
import { run } from "@grammyjs/runner";
|
import { run } from "@grammyjs/runner";
|
||||||
|
import { Client, cacheExchange, fetchExchange } from "@urql/core";
|
||||||
|
|
||||||
async function startPolling(config: PollingConfig) {
|
async function startPolling(config: PollingConfig) {
|
||||||
const bot = createBot(config.botToken, {
|
const bot = createBot(config.botToken, {
|
||||||
@@ -112,3 +113,13 @@ function onShutdown(cleanUp: () => Promise<void>) {
|
|||||||
process.on("SIGINT", handleShutdown);
|
process.on("SIGINT", handleShutdown);
|
||||||
process.on("SIGTERM", handleShutdown);
|
process.on("SIGTERM", handleShutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const urql = new Client({
|
||||||
|
url: process.env.GRAPHQL_URL || "",
|
||||||
|
exchanges: [cacheExchange, fetchExchange],
|
||||||
|
fetchOptions: {
|
||||||
|
headers: {
|
||||||
|
"x-api-key": process.env?.GRAPHQL_API_TOKEN || ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user