vmzhivetyev / tg-vnstat-monitor-bot

Report VPS traffic usage using telegram bot and vnstat
2 stars 1 forks source link

Problem to execute sh file #1

Open mohamadsohani opened 4 months ago

mohamadsohani commented 4 months ago

Hello i faced with this error , could you please help me

python3 main.py Traceback (most recent call last): File "main.py", line 65, in application = Application.builder().token(TOKEN).build() File "/usr/local/lib/python3.8/dist-packages/telegram/ext/_applicationbuilder.py", line 275, in build bot: Bot = self._build_ext_bot() # build a bot File "/usr/local/lib/python3.8/dist-packages/telegram/ext/_applicationbuilder.py", line 237, in _build_ext_bot return ExtBot( File "/usr/local/lib/python3.8/dist-packages/telegram/ext/_extbot.py", line 203, in init super().init( File "/usr/local/lib/python3.8/dist-packages/telegram/_bot.py", line 231, in init raise InvalidToken("You must pass the token you received from https://t.me/Botfather!") telegram.error.InvalidToken: You must pass the token you received from https://t.me/Botfather!

i modified report.sh file to :

!/bin/bash

set -euo pipefail

export LIMIT_GIB=20480 # 1TB is default non-billed limit on DigitalOcean export INTERFACE=eth0 export TOKEN=< i jast paste my token id like this : 6865154758:BBFoUN-vzYYulRLdlKSGef0bE938PvFGgiw > export TG_CHAT_ID=< like this : 79584882>

set -x

cd tg-vnstat-monitor-bot

git pull # auto-update repo

python3 main.py

and i save this lines to my report.sh

vmzhivetyev commented 4 months ago

Hi!

Those lines should look like this:

export TOKEN=6865154758:BBFoUN-vzYYulRLdlKSGef0bE938PvFGgiw
export TG_CHAT_ID=79584882

Double check that the token in the script is exactly the same as the one BotFather gave you.

mohamadsohani commented 4 months ago

Hi!

Those lines should look like this:

export TOKEN=6865154758:BBFoUN-vzYYulRLdlKSGef0bE938PvFGgiw
export TG_CHAT_ID=79584882

Double check that the token in the script is exactly the same as the one BotFather gave you.

Thanks, problem solved, how can i changed report from monthly report to hourly report? i mean bot send a hourly traffic

vmzhivetyev commented 4 months ago

Great!

I bet you need something like 0 9-17 * * *

Also check out this amazing website, it has a lot of examples of cron job schedule syntax: https://crontab.guru/examples.html

If you need it to provide per hour traffic numbers instead of per month then you need to modify vnstat.py to run vstat with --json h instead of --json m and then modify how the output of vnstat is parsed and formatted.

mohamadsohani commented 4 months ago

Great!

I bet you need something like 0 9-17 * * *

Also check out this amazing website, it has a lot of examples of cron job schedule syntax: https://crontab.guru/examples.html

If you need it to provide per hour traffic numbers instead of per month then you need to modify vnstat.py to run vstat with --json h instead of --json m and then modify how the output of vnstat is parsed and formatted.

thanks , telegram is filtered in my country and no one can access , how can i change api telegram link in you code to another telegram link ? i create worker in cloudflare and linked to telegram api site