This repository contains code for a chatbot implemented in Python using the Telegram Bot API. The chatbot is designed to respond to user messages and provide assistance based on the input.
To run the chatbot, ensure you have the following:
- Python 3.7 or above installed on your machine.
python-telegram-bot
library. Install it usingpip install python-telegram-bot
.- A Telegram bot token. You can obtain one by creating a new bot through the BotFather on Telegram. Note down the bot token for later use.
- Clone the repository to your local machine or download the source code.
- Install the required dependencies by running
pip install -r requirements.txt
in the project directory. - Set up environment variables:
-
Create a
.env
file in the project directory. -
Add the following variables to the
.env
file:# Your Telegram bot token obtained using @BotFather TELEGRAM_BOT_TOKEN="<your_telegram_bot_token>" #telegram bot token # bard token Secure_1PSID="<__secure_1PSID>" Secure_1PSIDTS="<__secure_1PSIDTS>" # telegram user id obtained using @userinfobot USER_ID='*' # comma for separation, '*' to enable all user
Replace
<your_bard_token>
with the token for your Bard chatbot and<your_telegram_bot_token>
with the token for your Telegram bot.<your_user_id>
should be replaced with your Telegram user ID.
-
- Run the chatbot by executing
python main.py
.
The repository has the following structure:
main.py
.env
README.md
requirements.txt
main.py
: The main file that contains the implementation of the chatbot, sets up the Telegram bot, handles incoming messages, and triggers the chatbot for generating responses.
- Start the bot by running
python main.py
. - Open the Telegram app and search for your bot using the username you assigned to it during creation.
- Start a chat with the bot and interact with it by sending messages.
- The bot will process your input and provide a response based on the implemented logic.
- You can use the
/start
command to initiate a conversation with the bot. - If you need to reset the chat history, you can use the
/reset
command.
Note: The bot will only respond to authorized users whose Telegram user ID matches the one specified in the .env
file.
You can customize the behavior and responses of the chatbot by modifying the code in main.py
. You can add new functionalities or change the logic to suit your requirements.
Contributions to the project are welcome. If you encounter any issues or have suggestions for improvement, please submit an issue or a pull request to the repository.
The code in this repository was developed based on the Python-Telegram-Bot library and follows best practices for Telegram bot development.
If you have any questions or need further assistance, please don't hesitate to reach out. Enjoy using the chatbot!.