mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 17:41:26 +02:00
Add three new Telegram bot services: - telegram-nutriphi-bot: Nutrition tracking bot with Gemini AI analysis - Photo meal analysis - Daily nutrition goals and tracking - Statistics and reports - telegram-todo-bot: Todo list management bot - Integration with Todo backend API - Reminder scheduling - User preferences per chat - telegram-zitare-bot: Daily inspiration quotes bot - Scheduled daily quotes - Quote database with authors - User subscription management All bots use NestJS with nestjs-telegraf for Telegram integration. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
import { pgTable, uuid, text, timestamp, bigint, boolean, unique } from 'drizzle-orm/pg-core';
|
|
import { relations } from 'drizzle-orm';
|
|
|
|
// Telegram users
|
|
export const telegramUsers = pgTable('telegram_users', {
|
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
telegramUserId: bigint('telegram_user_id', { mode: 'number' }).notNull().unique(),
|
|
telegramUsername: text('telegram_username'),
|
|
dailyEnabled: boolean('daily_enabled').default(false).notNull(),
|
|
dailyTime: text('daily_time').default('08:00').notNull(),
|
|
timezone: text('timezone').default('Europe/Berlin').notNull(),
|
|
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
});
|
|
|
|
// User favorites
|
|
export const userFavorites = pgTable(
|
|
'user_favorites',
|
|
{
|
|
id: uuid('id').primaryKey().defaultRandom(),
|
|
telegramUserId: bigint('telegram_user_id', { mode: 'number' }).notNull(),
|
|
quoteId: text('quote_id').notNull(),
|
|
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
},
|
|
(table) => [unique().on(table.telegramUserId, table.quoteId)]
|
|
);
|
|
|
|
// Relations
|
|
export const telegramUsersRelations = relations(telegramUsers, ({ many }) => ({
|
|
favorites: many(userFavorites),
|
|
}));
|
|
|
|
export const userFavoritesRelations = relations(userFavorites, ({ one }) => ({
|
|
user: one(telegramUsers, {
|
|
fields: [userFavorites.telegramUserId],
|
|
references: [telegramUsers.telegramUserId],
|
|
}),
|
|
}));
|
|
|
|
// Types
|
|
export type TelegramUser = typeof telegramUsers.$inferSelect;
|
|
export type NewTelegramUser = typeof telegramUsers.$inferInsert;
|
|
export type UserFavorite = typeof userFavorites.$inferSelect;
|
|
export type NewUserFavorite = typeof userFavorites.$inferInsert;
|