supernova-go-bot is a Telegram bot based on Go Telegram API framework. It integrates with various services like OpenAI and AccuWeather with authorization middleware so that only promoted users can have an access to the fetching commands. The database is managed by PostgreSQL and is used to store promoted users and to record the users' activity. The user can be promoted by the admin, which id among other settings like API keys for the services and db connection string is stored in the .env
file.
-
Install Go and set up your workspace. Install make if on Windows via chocolatey:
choco install make
-
Create the bot on Telegram with BotFather and save its API key.
-
Clone this repository
-
Install dependencies:
make dep
-
Create and fill the env file (as in example file) with the required parameters. If you do not fill some external tokens, the commands that require their APIs won't be available.
-
Install PostgreSQL and create a database. Fill the env file with the database connection string parameters.
-
Execute the up migration to create the tables in the database:
make migrate-up
-
Run the bot:
make run
-
Type /help in the bot chat to see the available commands
The bot has the following commands:
/help
- shows the available commands/getid
- shows the user's Telegram ID, useful for the admin to promote users
/weather <city> <N> days|hours
- fetches the weather forecast for the city for the next N days or hours from AccuWeather/chat <prompt>
- sends the prompt to OpenAI and returns the response
/allow <user_id>
- promotes the user with the given ID to have access to the promoted commands
The project is licensed under the MIT License. See the LICENSE file for more information.
The project was created by Nikita Smirnov. You can contact me via email or by opening an issue in this repository.