diff --git a/src/bot.ts b/src/bot.ts index 410074d..6c73faa 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -9,6 +9,7 @@ import { setupCallbackQueries } from "./callbackQueries/mod.ts"; import { setupCommands } from "./commands/mod.ts"; import { setupConversations } from "./conversations/mod.ts"; import { setupSession } from "./session/mod.ts"; +import { setupMessages } from "./messages/mod.ts"; export const bot = new Bot(BOT_TOKEN); @@ -16,4 +17,4 @@ setupSession(bot); setupConversations(bot); setupCommands(bot); setupCallbackQueries(bot); - +setupMessages(bot); diff --git a/src/config/anon_credits.txt b/src/config/anon_credits.txt new file mode 100644 index 0000000..5e20099 --- /dev/null +++ b/src/config/anon_credits.txt @@ -0,0 +1,22 @@ +Heisenberg +Programming Socks +Furry +Rick Astley +Boykisser +Rewrite it in Rust +Rust Evangelist +Boomer +Lain +Shinji +dQw4w9WgXcQ +I have an idea +var pippo +uwu +nyaa +Normie +Instagram user +TikTok user +Redditor +4chan user +Obstructionist +soy programador diff --git a/src/config/mod.ts b/src/config/mod.ts index 1263a7c..3b49ead 100644 --- a/src/config/mod.ts +++ b/src/config/mod.ts @@ -8,4 +8,7 @@ await load({ export: true }); export const BOT_TOKEN = Deno.env.get("BOT_TOKEN") ?? (() => { throw new Error("BOT_TOKEN is unset") })(); export const CHANNEL_ID = Deno.env.get("CHANNEL_ID") ?? (() => { throw new Error("CHANNEL_ID is unset") })(); -export const GROUP_ID = Deno.env.get("GROUP_ID") ?? (() => { throw new Error("GROUP_ID is unset") })(); \ No newline at end of file +export const GROUP_ID = Deno.env.get("GROUP_ID") ?? (() => { throw new Error("GROUP_ID is unset") })(); +export const COMMUNITY_GROUP_ID = Deno.env.get("COMMUNITY_GROUP_ID") ?? (() => { throw new Error("COMMUNITY_GROUP_ID is unset") })(); + +export const ANON_CREDITS = Deno.readTextFileSync("./src/config/anon_credits.txt").split("\n"); \ No newline at end of file diff --git a/src/messages/mod.ts b/src/messages/mod.ts new file mode 100644 index 0000000..601136b --- /dev/null +++ b/src/messages/mod.ts @@ -0,0 +1,2 @@ +export { setupMessages } from './setupMessages.ts'; +export { postCredits } from './postCredits.ts'; \ No newline at end of file diff --git a/src/messages/postCredits.ts b/src/messages/postCredits.ts new file mode 100644 index 0000000..2963c4c --- /dev/null +++ b/src/messages/postCredits.ts @@ -0,0 +1,12 @@ +import { ANON_CREDITS } from "../config/mod.ts"; +import { BotContext } from "../mod.ts"; + +const getCreditsText = () => `Credits: ${ANON_CREDITS[Math.floor(Math.random() * ANON_CREDITS.length)]}`; + +export const postCredits = async (ctx: BotContext, messageId: number) => { + await ctx.reply(getCreditsText(), { + reply_parameters: { + message_id: messageId, + } + }); +} \ No newline at end of file diff --git a/src/messages/setupMessages.ts b/src/messages/setupMessages.ts new file mode 100644 index 0000000..4f7799b --- /dev/null +++ b/src/messages/setupMessages.ts @@ -0,0 +1,14 @@ +import { Bot } from "grammy"; +import { BotContext } from "../mod.ts"; +import { COMMUNITY_GROUP_ID } from "../config/mod.ts"; +import { postCredits } from "./postCredits.ts"; + +export const setupMessages = (bot: Bot) => { + bot.on("message:is_automatic_forward", (ctx) => { + if (ctx.chat.id === Number(COMMUNITY_GROUP_ID)) { + postCredits(ctx, ctx.message.message_id); + } + }); + + console.log("Messages setup complete"); +} \ No newline at end of file