This is a backend application for a Telegram bot built with Spring Boot. The bot helps manage daily tasks and notifications for groups, allowing users to add, delete, and edit users, notifications, and chats. It also features interaction with ChatGPT3 for quick Q&A sessions.
- User Management:
- Add, delete, and edit users
- Notification Management:
- Add, delete, and edit notifications
- Send time-based notifications
- Show list of notifications
- Chat Management:
- Add, delete, and edit chats
- Show list of users
- Assign winners for daily tasks
- Reset winners
- ChatGPT3 Interaction:
- Interact with ChatGPT3
- Java 17
- Spring Boot 3.0.5
- Maven 3.x
- PostgreSQL 13.x
Follow these steps to set up and run the Telegram Daily Bot:
Clone this repository to your local machine:
git clone https://github.com/yourusername/telegramdailybot.git
Create a PostgreSQL database using src/main/resources/db/schema.sql
.
Set your:
- Telegram bot usename and token
- Connection to the database
- (optionally) GPT-3 API key
Rename src/main/resources/application.properties.example
into application.properties
and adjust the following properties:
telegrambot.botUsername=YOUR_TELEGRAM_BOT_USERNAME
telegrambot.botToken:=YOUR_TELEGRAM_BOT_TOKEN
telegrambot.timezone=YOUR_TIMEZONE
spring.datasource.url=jdbc:postgresql://localhost:5432/YOUR_DATABASE_NAME
spring.datasource.username=YOUR_DATABASE_USERNAME
spring.datasource.password=YOUR_DATABASE_PASSWORD
openai.token=YOUR_GPT3_API_KEY
When setting your timezone, use the IANA timezone format, for example Europe/Berlin
.
application.properties should be kept in the same folder as the jar file.
Change your current working directory to the telegramdailybot
folder:
cd telegramdailybot
Use Maven to build the project:
mvn clean install
After the build is successful, run the Spring Boot application:
mvn spring-boot:run
Now the Telegram Daily Bot is up and running. You can start interacting with the bot by sending commands and messages.
Get you Telegram user ID by sending /getchatid
command to the bot.
Add first admin user manually in the database. You can do this by running the following SQL query:
INSERT INTO public.chats(name, telegramchatid, role)
VALUES ('<YourName>', <your telegram user id>, 'admin');
- /start: Initialize the bot
- /getchatid: Get the chat ID
- /next: Select the next winner
- /resetwinners: Reset the winners list
- /showusers: Show the list of users
- /shownotifications: Show the list of notifications
- /editusers: Edit users
- /editnotifications: Edit notifications
- /editchats: Edit group chats - this command is only available to admin users
- /askchatgpt3: Ask a question to ChatGPT3
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.