1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
Создаем бота в BotFather:
==/newbot = Work_Server==
t.me/vlapa_bot
7286073488:AAGzCTkYPI8rleSXpZxRm5isckgN09YVhiM
'id': 949969015
==/newbot = Home_server==
t.me/vlapaHome_bot
7423942020:AAGw0w75nFIkMGLDRSk2Spx1wq_-dlJOPeM
'id': 949969015
==/newbot = mqtt==
t.me/vlapa_mqtt_log_Bot
7238364847:AAGbx7RwzPaTpirzttnLQT9FPWL7DmvyWDs
'id': 949969015
Запускаем боты:
- /start
```python
# python -m pip install requests
import requests
TOKEN = "Сюда вставьте свой токен"
url = f"https://api.telegram.org/bot{TOKEN}/getUpdates"
print(requests.get(url).json())
```
{'ok': True, 'result': [{'update_id': 552144411, 'message': {'message_id': 1, 'from': {'id': 949969015, 'is_bot': False, 'first_name': 'Vlapa', 'language_code': 'ru'}, 'chat': {'id': 949969015, 'first_name': 'Vlapa', 'type': 'private'}, 'date': 1725095952, 'text': '/start', 'entities': [{'offset': 0, 'length': 6, 'type': 'bot_command'}]}}]}
```python
import requests
TOKEN = "Сюда вставьте свой токен"
chat_id = "Сюда вставьте ID чата"
message = "Здесь напишите свое сообщение"
url = f"https://api.telegram.org/bot{TOKEN}/sendMessage?chat_id={chat_id}&text={message}"
print(requests.get(url).json()) # Эта строка отсылает сообщение
```
```python
disk_list = '/dev/sdd5 /dev/md127p1 /dev/md126p1 /dev/sdc'
disk_name = '300Gb 1Tb-a 1Tb-b 1Tb-c'
for disk in disk_list
command = f"df {disk} | grep / | awk 'print $5' | sed 's/%//g' >> size.txt"
current = os.system(command)
threshold = 5
if current > threshold
f = open('size.txt', w+)
f.close()
```
|