This is a quick and dirty telegram sample bot in python based on StarChat.ai. The program uses an in memory datastore for sessions data. If you want to contribute with a proper database, eg SQLite, you are wellcome!
- Fork the repository on your account. You could clone this rep directly, but then you won't be able to push your changes on github. Click on top left button "Fork" :)
- Clone:
git clone [email protected]:MY_ACCOUNT/starchat_telegram_bot.git
- Set this repository as "upstream", so you can rebase your repository everytime we make a change:
git remote add upstream [email protected]:GetJenny/starchat_telegram_bot.git
In the future, when you want to update your repository with GetJenny's one, just type:
git fetch upstream
git rebase upstream/master
- python3
- docker
Start the service following the instructions on StarChat Documentation (5-10 minutes)
Create a new index. On a terminal (Unix) type:
curl -v -H "Content-Type: application/json" -X POST "http://localhost:8888/index_management/create"
Optional, but recommended!
virtualenv -p python3 env3_telegram
source env3_telegram/bin/activate
pip install python-telegram-bot --upgrade
pip install urllib3
Load a configuration file into StarChat and apply the changes:
curl -v --form "csv=@starchat_configuration_sample.csv" http://localhost:8888/decisiontable_upload_csv
# Apply:
curl -v -H "Content-Type: application/json" -X POST "http://localhost:8888/decisiontable_analyzer"
If you want to delete the old configuration:
curl -v -H "Content-Type: application/json" -X DELETE http://localhost:8888/decisiontable
You need a telegram account of course!
- Go on [https://web.telegram.org/#/im?p=@BotFather]
- Type the command "/newbot" to create a new bot, follow the instructions
- Collect the unique token access which is something like this:
Use this token to access the HTTP API: XXXXXXX:YYYYYYYYYYYYYYYYYYYYYYYYYYYY
- Edit the file telegram_starchat.py and replace the token access into the main function
python3 telegram_starchat.py