Spaces:
Paused
Paused
pink-mothra
commited on
Commit
•
0c706d1
1
Parent(s):
a59c0ef
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,12 @@
|
|
1 |
-
from telegram import Update
|
2 |
-
from telegram.ext import Updater, CommandHandler, MessageHandler
|
3 |
-
import requests
|
4 |
import os
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
|
9 |
@bot.message_handler(commands=['start', 'hello'])
|
@@ -16,43 +19,41 @@ def sign_handler(message):
|
|
16 |
text = "Por favor escolha um tipo de dado:\nuint8 (Inteiros 0–255), uint16 (Inteiros 0–65535)"
|
17 |
bot.reply_to(message, text)
|
18 |
|
19 |
-
# Agora, vamos esperar a resposta do usuário
|
20 |
bot.register_next_step_handler(message, process_data_type_choice)
|
21 |
|
22 |
def process_data_type_choice(message):
|
23 |
-
|
24 |
data_type = message.text
|
25 |
|
26 |
-
|
27 |
bot.reply_to(message, "Por favor, escolha o comprimento da matriz. O valor deve variar de 1 a 1024.")
|
28 |
|
29 |
-
# Agora, vamos esperar a resposta do usuário sobre o comprimento da matriz
|
30 |
bot.register_next_step_handler(message, lambda msg: process_array_length_choice(msg, data_type))
|
31 |
|
32 |
def process_array_length_choice(message, data_type):
|
33 |
-
|
34 |
array_length = message.text
|
35 |
|
36 |
-
|
37 |
api_url = f"https://qrng.anu.edu.au/API/jsonI.php?length={array_length}&type={data_type}"
|
38 |
|
39 |
-
|
40 |
try:
|
41 |
response = requests.get(api_url)
|
42 |
-
response.raise_for_status()
|
43 |
|
44 |
-
|
45 |
result = response.json()
|
46 |
|
47 |
-
|
48 |
random_data = result.get('data', [])
|
49 |
|
50 |
-
|
51 |
bot.reply_to(message, f"Números aleatórios verdadeiros: {random_data}")
|
52 |
|
53 |
except requests.exceptions.RequestException as e:
|
54 |
-
|
55 |
bot.reply_to(message, f"Aguarde 1 min depois da ultima solicitação")
|
56 |
|
57 |
-
|
58 |
bot.infinity_polling()
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
|
3 |
+
import telebot
|
4 |
+
|
5 |
+
import requests
|
6 |
+
|
7 |
+
BOT_TOKEN = os.environ.get('BOT_TOKEN')
|
8 |
+
|
9 |
+
bot = telebot.TeleBot(BOT_TOKEN)
|
10 |
|
11 |
|
12 |
@bot.message_handler(commands=['start', 'hello'])
|
|
|
19 |
text = "Por favor escolha um tipo de dado:\nuint8 (Inteiros 0–255), uint16 (Inteiros 0–65535)"
|
20 |
bot.reply_to(message, text)
|
21 |
|
|
|
22 |
bot.register_next_step_handler(message, process_data_type_choice)
|
23 |
|
24 |
def process_data_type_choice(message):
|
25 |
+
|
26 |
data_type = message.text
|
27 |
|
28 |
+
|
29 |
bot.reply_to(message, "Por favor, escolha o comprimento da matriz. O valor deve variar de 1 a 1024.")
|
30 |
|
|
|
31 |
bot.register_next_step_handler(message, lambda msg: process_array_length_choice(msg, data_type))
|
32 |
|
33 |
def process_array_length_choice(message, data_type):
|
34 |
+
|
35 |
array_length = message.text
|
36 |
|
37 |
+
|
38 |
api_url = f"https://qrng.anu.edu.au/API/jsonI.php?length={array_length}&type={data_type}"
|
39 |
|
40 |
+
|
41 |
try:
|
42 |
response = requests.get(api_url)
|
43 |
+
response.raise_for_status()
|
44 |
|
45 |
+
|
46 |
result = response.json()
|
47 |
|
48 |
+
|
49 |
random_data = result.get('data', [])
|
50 |
|
51 |
+
|
52 |
bot.reply_to(message, f"Números aleatórios verdadeiros: {random_data}")
|
53 |
|
54 |
except requests.exceptions.RequestException as e:
|
55 |
+
|
56 |
bot.reply_to(message, f"Aguarde 1 min depois da ultima solicitação")
|
57 |
|
58 |
+
|
59 |
bot.infinity_polling()
|