- You need
Python 3installed on your computer
Install the following Python dependencies:
pip install requests python-dotenvRename the .env.sample file to .env file:
mv .env.sample .env- Open Botfather https://t.me/botfather and follow the instructions to create your bot (e.g, Desco Balance Bot). You will get a telegram bot token.
- Copy and add it to
TELEGRAM_BOT_TOKENin the.envfile. - Send a
hi/hellochat to your new bot. - Open this URL in your browser
https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/getUpdates - Copy the chat
idvalue and add it to theTELEGRAM_CHAT_IDin the.envfile.
python check_balance.pyOutput:
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'prepaid.desco.org.bd'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
warnings.warn(
(True, 'Telegram sent')Ignore the SSL warning for now (I will update it later); you should see (True, 'Telegram sent`)
And receive a message in your Telegram app.
It is possible that behind the scenes, DESCO is using multiple endpoints for quering various Meter types.
The endpoint this script is using is:
https://prepaid.desco.org.bd/api/unified/customer/getBalance?accountNo=
So please test this endpoint with your DESCO account and first verify that this is working for your meter.