feat(telegram): add /blu and /oficial commands and main menu

This commit is contained in:
Jose Selesan
2026-08-20 14:22:56 -03:00
parent 96f6b26a76
commit 31dae446af
2 changed files with 103 additions and 37 deletions

View File

@@ -1,4 +1,5 @@
import crypto from "crypto";
import type { QuoteType } from "../../generated/prisma/client";
import { logger } from "../../lib/logger";
import { prisma } from "../../lib/prisma";
import { getBot, getBotUsername } from "../../lib/telegram";
@@ -209,7 +210,7 @@ export async function checkAndNotifyBelo(): Promise<void> {
});
}
export interface BeloQuoteStatus {
export interface QuoteStatus {
buy: number;
sell: number;
timeStamp: Date;
@@ -220,9 +221,11 @@ export interface BeloQuoteStatus {
progressPercentage: number | null;
}
export async function getBeloQuoteStatus(): Promise<BeloQuoteStatus | null> {
export async function getQuoteStatus(
type: QuoteType,
): Promise<QuoteStatus | null> {
const currentQuote = await prisma.quote.findFirst({
where: { type: "BELO" },
where: { type },
orderBy: { timeStamp: "desc" },
});
if (!currentQuote) return null;
@@ -241,7 +244,7 @@ export async function getBeloQuoteStatus(): Promise<BeloQuoteStatus | null> {
const agg = await prisma.quoteHistory.aggregate({
where: {
type: "BELO",
type,
timeStamp: { gte: todayStart },
},
_min: { buy: true, sell: true },