feat: ✨ add random anon credits on post
parent
f90e54bd75
commit
dc8e113efa
|
@ -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<BotContext>(BOT_TOKEN);
|
||||
|
@ -16,4 +17,4 @@ setupSession(bot);
|
|||
setupConversations(bot);
|
||||
setupCommands(bot);
|
||||
setupCallbackQueries(bot);
|
||||
|
||||
setupMessages(bot);
|
||||
|
|
|
@ -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
|
|
@ -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") })();
|
||||
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");
|
|
@ -0,0 +1,2 @@
|
|||
export { setupMessages } from './setupMessages.ts';
|
||||
export { postCredits } from './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,
|
||||
}
|
||||
});
|
||||
}
|
|
@ -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<BotContext>) => {
|
||||
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");
|
||||
}
|
Loading…
Reference in New Issue