-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
27 lines (19 loc) · 686 Bytes
/
Copy pathmain.py
File metadata and controls
27 lines (19 loc) · 686 Bytes
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
import os
import telebot
import requests
API_KEY = os.getenv('API_KEY')
LOG_URL = os.getenv('LOG_URL')
bot = telebot.TeleBot(API_KEY)
def hello_request(message):
return message.text.lower() == "show last test"
@bot.message_handler(func=hello_request)
def show_last_test(message):
r = requests.get(LOG_URL, allow_redirects=True)
lastSpeedTest = r.text.splitlines()[-4:]
bot.send_message(message.chat.id, "\n".join(lastSpeedTest))
@bot.message_handler(commands=['last_test'])
def last_test(message):
r = requests.get(LOG_URL, allow_redirects=True)
lastSpeedTest = r.text.splitlines()[-4:]
bot.send_message(message.chat.id, "\n".join(lastSpeedTest))
bot.polling()