feat: add Telegram album purchase bot
This commit is contained in:
@@ -45,8 +45,7 @@ A modern, interactive website showcasing a progressive rock composer and produce
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Node.js 18+
|
||||
- npm or yarn
|
||||
- Bun 1.3+
|
||||
|
||||
### Installation
|
||||
|
||||
@@ -54,13 +53,13 @@ A modern, interactive website showcasing a progressive rock composer and produce
|
||||
2. Install dependencies:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
bun install
|
||||
```
|
||||
|
||||
3. Run the development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
bun run dev
|
||||
```
|
||||
|
||||
4. Open [http://localhost:3000](http://localhost:3000) in your browser
|
||||
@@ -197,13 +196,33 @@ export const albums: Album[] = [
|
||||
## Build for Production
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
npm start
|
||||
bun run build
|
||||
bun run start
|
||||
```
|
||||
|
||||
## Telegram Purchase Approval Bot
|
||||
|
||||
The Telegram bot works as both a customer storefront and an approval channel. Customers can browse albums, add several albums to a cart, receive the configured card details, and submit either a text transaction ID or a receipt screenshot. After approval, the bot uploads every purchased track directly into the customer's Telegram chat.
|
||||
|
||||
Authorized reviewers receive pending purchases with **Approve** and **Reject** buttons. They can also send `/pending` to list outstanding purchases or `/id` to see their Telegram user ID.
|
||||
|
||||
1. Create a bot with BotFather and copy `.env.example` to `.env`.
|
||||
2. Set a long random `TELEGRAM_WEBHOOK_SECRET`. `NEXT_PUBLIC_APP_URL` defaults to `https://podzahr.com` and can be overridden if needed.
|
||||
3. Deploy the application.
|
||||
4. In **Admin → Purchases**, set the Telegram API base URL, paste the BotFather token, customize the greeting, and enter the payment card number and cardholder name. The saved token is never returned to the browser again.
|
||||
5. Click **Register webhook**.
|
||||
6. Each reviewer must start a private chat with the bot and send `/id`.
|
||||
7. Enter the reviewers' comma-separated Telegram user IDs in the same admin settings panel and save.
|
||||
|
||||
Telegram calls `/api/telegram/webhook` with the configured secret. Every approval callback also verifies that the sender is still present in the SQLite-backed approver list.
|
||||
|
||||
Album delivery uses the full track files configured for each album in the admin panel. The application downloads each file and uploads it to Telegram as a document after the purchase is approved.
|
||||
|
||||
## Technologies Used
|
||||
|
||||
- **Next.js 15**: React framework with App Router
|
||||
- **Bun**: JavaScript runtime, package manager, and native SQLite driver
|
||||
- **SQLite**: Persistent album, purchase, and payment data via `bun:sqlite`
|
||||
- **TypeScript**: Type-safe development
|
||||
- **Tailwind CSS**: Utility-first CSS framework
|
||||
- **Framer Motion**: Animation library
|
||||
|
||||
Reference in New Issue
Block a user