This is a simple Telegram bot that allows you to search, add, and edit contacts using a JSON file.
You can install Python on your VPS using this command:
sudo apt install python3
You can install the python-telegram-bot library using pip:
pip install python-telegram-bot==13.7
1.Clone this repository to your local machine or server.
2.Create a new bot on Telegram and obtain your bot token from BotFather.
- Insert your token in line 83:
updater = Updater('YOUR_BOT_TOKEN_HERE', use_context=True)
- Create a data.JSON file to store your contacts, and populate it with some sample data. An example file is included in the project directory.
[
{
"full_name": "Linus Torvalds",
"post": "Developer",
"phones": [
"123-456-7890",
"555-555-5555"
],
"comment": "Likes bananas."
},
{
"full_name": "Jony Ive",
"post": "Designer",
"phones": [
"987-654-3210"
],
"comment": "Also likes bananas."
}
]
- Run the bot using the following command:
python3 main.py
2023-02-13.11.02.28.mov
The bot should now be running and listening for incoming messages.
To search for a contact, type /search [query]
or simply [query]
in the chat. The bot will search for contacts whose full_name, post, phones, or comment fields contain the given query. For example:
/search Linus
or
Linus
To add a new contact, type /add [full name];[post];[phone numbers];[comment]
in the chat. The phone numbers should be separated by commas.
For example:
/add Michelangelo di Lodovico Buonarroti Simoni;Designer;123-456-7890,555-555-5555;Allergic to bananas.
add.mov
To edit a contact, simply reply to the search result message with the new contact information in the same format as when adding a contact.
For example:
Michelangelo di Lodovico Buonarroti Simoni;Product Manager;123-456-7890,555-555-5555;Likes apples.
This project is licensed under the MIT License. See the LICENSE file for details.