Follow these steps to set up and run your Telegram bot:
- Open BotFather on Telegram.
- Use
/newbotto create a new bot and get your bot's API token.
Clone the repository to your local machine:
git clone <repository-url>
cd <repository-directory>In the project directory, create a .env file with the following content:
TOKEN=your-bot-token-hereReplace your-bot-token-here with the API token you received from BotFather.
To start the bot, run the following Go command:
go run main.go- Open Telegram and search for your bot.
- Start a chat with your bot by typing
/start.
- Type
/connectand input your database connection string when prompted.
- To query your database, use the
/querycommand followed by your SQL query. For example:
/query select * from users where username like 'thinhphoenix'You're all set! Enjoy using the bot and querying your database.
