Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegram output #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,21 @@ sudo dpkg -i rkn-check.deb
* ``failure`` — Ресурс успешно блокируется, произошла ошибка TCP
* ``local-ip`` — Ресурс резолвится в локальный IP
* ``available`` — Ресурс **не блокируется**


## Telegram

* Adjust string 202 of ``/usr/bin/rkn-check.py`` with your bot-ID and chat_ID

```
202 cmdstring = "/usr/bin/curl -s -d \"chat_id=-10CHAT-ID57&disable_web_page_preview=1&text=Checked %d, errors: %d\"" % (total_count, available_count) + " https://api.telegram.org/bot36BOT-ID8:AAEBOT-ID9Ksl-6ABOT-IDY0/sendMessage"
203
204 print (cmdstring)
205
206 os.system( cmdstring )

```

* ``GET handy tg output as`` - **Checked 121040, errors: 0**


8 changes: 8 additions & 0 deletions rkn-check/usr/bin/rkn-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Сторонние пакеты
import requests
from lxml import etree
import os
from subprocess import call

# Наш конфигурационный файл
sys.path.append('/etc/roskom')
Expand Down Expand Up @@ -190,3 +192,9 @@ def parse_registry(filename):
f.write("%s <%d>\n" % (link['url'], link['checked']))

print("---\nCheck finished in %dm:%.2fs using %d kb RES\nAvailable: %d, not available: %d" % (execution_minutes, execution_seconds, stat.ru_maxrss, available_count, total_count - available_count))

cmdstring = "/usr/bin/curl -s -d \"chat_id=-100YOUR-CHAT-ID357&disable_web_page_preview=1&text=Checked %d, errors: %d\"" % (total_count, available_count) + " https://api.telegram.org/bot36YOUR-BOT-ID18:YOUR-BOT-IDsl-6BOT-IDY0/sendMessage"

print (cmdstring)

os.system( cmdstring )