| import telebot |
| from telebot import types |
| import requests |
| import time |
| import os |
|
|
| |
| TOKEN = '8559275008:AAGTiuuiGWPykrOEe14Dple_GAlHWssP5Aw' |
| MY_CHAT_ID = 582934051 |
|
|
| |
| bot = telebot.TeleBot(TOKEN) |
| CHECK_OBJECT = "P22lbY0" |
|
|
| def get_current_status(): |
| results = [] |
| |
| try: |
| url = f"https://ssd-api.jpl.nasa.gov/sbdb.api?sstr={CHECK_OBJECT}" |
| r = requests.get(url, timeout=15) |
| if r.status_code == 200: |
| data = r.json() |
| name = data.get("object", {}).get("full_name", "Имя не определено") |
| results.append(f"🛰 NASA JPL: {name}") |
| else: |
| results.append("❌ NASA: Объект не найден") |
| except Exception as e: |
| results.append(f"⚠️ NASA: Ошибка связи") |
|
|
| |
| try: |
| url = "https://www.minorplanetcenter.net/iau/NEO/pccp_last.html" |
| r = requests.get(url, timeout=15) |
| if CHECK_OBJECT in r.text: |
| results.append("🔭 MPC PCCP: Объект в списке (ждем)") |
| else: |
| results.append("🔔 MPC: ИНДЕКС ИСЧЕЗ! Срочно проверь имя!") |
| except Exception as e: |
| results.append("⚠️ MPC: Ошибка связи") |
| |
| return "\n".join(results) |
|
|
| def main_keyboard(): |
| markup = types.InlineKeyboardMarkup() |
| markup.add(types.InlineKeyboardButton("🔄 Проверить статус", callback_data="check_status")) |
| markup.add(types.InlineKeyboardButton("🌐 Проверить домены", callback_data="check_domain")) |
| return markup |
|
|
| @bot.message_handler(commands=['start']) |
| def start(message): |
| bot.send_message( |
| message.chat.id, |
| f"🤖 Мониторинг {CHECK_OBJECT} запущен.", |
| reply_markup=main_keyboard() |
| ) |
|
|
| @bot.callback_query_handler(func=lambda call: True) |
| def callback_inline(call): |
| if call.data == "check_status": |
| status = get_current_status() |
| bot.edit_message_text( |
| chat_id=call.message.chat.id, |
| message_id=call.message.message_id, |
| text=f"📊 **Данные:**\n\n{status}", |
| reply_markup=main_keyboard(), |
| parse_mode="Markdown" |
| ) |
| elif call.data == "check_domain": |
| bot.send_message( |
| call.message.chat.id, |
| f"🔎 Ссылка:\nhttps://www.reg.ru/whois/?dname={CHECK_OBJECT.lower()}.com" |
| ) |
|
|
| |
| if __name__ == "__main__": |
| print("⏳ Ожидание стабилизации сети (20 секунд)...") |
| time.sleep(20) |
| |
| print("🚀 Попытка подключения к Telegram API...") |
| try: |
| |
| me = bot.get_me() |
| print(f"✅ Успешно! Бот @{me.username} онлайн.") |
| bot.polling(none_stop=True, timeout=90) |
| except Exception as e: |
| print(f"❌ Ошибка подключения: {e}") |
| print("💡 Если ошибка DNS, попробуй Settings -> Factory Rebuild в Hugging Face.") |