Setup mode added

This commit is contained in:
Dmitry Anderson 2024-10-19 12:47:33 +02:00
parent 2e051088b3
commit 13de32ae00
5 changed files with 26 additions and 8 deletions

View File

@ -7,7 +7,7 @@ const pack: LangPack = {
captcha: { captcha: {
already_in_chat: "You are already in chat", already_in_chat: "You are already in chat",
passed: (invite_link: string) => `Captcha passed! Now u can join to the community: ${invite_link}`, passed: (invite_link: string) => `Captcha passed! Now u can join to the community: ${invite_link}`,
failed: (timeout_mins: number) => `Капча не пройдена. Вы сможете попробовать снова через ${timeout_mins} минут.`, failed: (timeout_mins: number) => `U didn't pass the captcha. U can try again after ${timeout_mins} minutes.`,
} }
}, },
} }

View File

@ -1,7 +1,7 @@
import { Bot } from "https://deno.land/x/grammy@v1.30.0/mod.ts"; import { Bot } from "https://deno.land/x/grammy/mod.ts";
import { Kysely } from "npm:kysely"; import { Kysely } from "npm:kysely";
import { Ctx } from "../ctx.ts"; import { Ctx } from "../ctx.ts";
import { CompiledConfig } from "../../cfg/exports.ts"; import { CompiledConfig } from "../../cfg/config.ts";
import { Database } from "../../repo/exports.ts"; import { Database } from "../../repo/exports.ts";

View File

@ -0,0 +1,18 @@
import { Bot } from "https://deno.land/x/grammy/mod.ts";
import { CompiledConfig } from "../../cfg/config.ts";
import { Ctx } from "../ctx.ts";
export const init = (bot: Bot<Ctx>, _: CompiledConfig) => {
bot.command("getchat", ctx => {
if (!ctx.from || !ctx.message) return
if (ctx.message.chat.type != "group"
&& ctx.message.chat.type != "supergroup") return
ctx.deleteMessage()
console.log(`Chat ${ctx.message.chat.title} ID: ${ctx.message.chat.id}`)
})
bot.command("getme", ctx => {
if (!ctx.from) return
console.log(`User ${ctx.from.first_name} ${ctx.from.last_name} ID: ${ctx.from.id}`)
})
}

View File

@ -13,7 +13,7 @@ export const DEFAULT_DB_NAME = "mic"
export const DEFAULT_DB_PORT = 5432 export const DEFAULT_DB_PORT = 5432
export const DEFAULT_DB_TLS = false export const DEFAULT_DB_TLS = false
export const reloadConfig = (): CompiledConfig => { export const loadConfig = (): CompiledConfig => {
const cfg = getConfig() const cfg = getConfig()
const pgPoolCfg: PoolConfig = { const pgPoolCfg: PoolConfig = {
host: cfg.db_name || DEFAULT_DB_HOST, host: cfg.db_name || DEFAULT_DB_HOST,

View File

@ -1,20 +1,20 @@
import { runBot } from "./bot/bot.ts"; import { runBot } from "./bot/bot.ts";
import { init as initNormalMode } from "./bot/normal_mode/init.ts" import { init as initNormalMode } from "./bot/normal_mode/init.ts"
import { setupDB } from "./repo/exports.ts"; import { setupDB } from "./repo/exports.ts";
import { reloadConfig } from "./config.ts"; import { loadConfig } from "./config.ts";
import { BotMode } from "./cfg/bot.ts"; import { BotMode } from "./cfg/bot.ts";
const main = async () => { const main = async () => {
const cfg = reloadConfig() const cfg = loadConfig()
const { botCfg } = cfg const { botCfg } = cfg
const { db } = await setupDB(cfg) const { db } = await setupDB(cfg)
runBot(botCfg, (bot) => { runBot(botCfg, (bot) => {
switch (botCfg.mode) { switch (botCfg.mode) {
case BotMode.setup: case BotMode.normal:
initNormalMode(bot, db, cfg) initNormalMode(bot, db, cfg)
break; break;
case BotMode.normal: case BotMode.setup:
break; break;
} }
}) })