Spaces:
Running
Running
Download app.py from DROPZONEBASTS/dropzone-bot: direct link, hf CLI and curl.
- Browser
- Download file 933 Bytes
-
https://huggingface.co/spaces/DROPZONEBASTS/dropzone-bot/resolve/main/app.py
- Command line
-
hf download hf://spaces/DROPZONEBASTS/dropzone-bot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/DROPZONEBASTS/dropzone-bot/resolve/main/app.py
933 Bytes
| import os | |
| import threading | |
| import telebot | |
| from flask import Flask | |
| # Ambil token dari secret Hugging Face | |
| TOKEN = os.environ.get("8978329744:AAF9yD8-KuEuj3Y2Tc31rIB78RJ0zFDAyMo") | |
| bot = telebot.TeleBot(TOKEN) | |
| app = Flask(__name__) | |
| # Server web mini agar Hugging Face tahu aplikasi menyala | |
| def home(): | |
| return "Bot Dropzone sedang berjalan!" | |
| # Logika Bot Telegram saat ada yang mengirim perintah /start | |
| def send_welcome(message): | |
| bot.reply_to(message, "Halo! Saya Bot Dropzone. Sistem siap digunakan.") | |
| # Fungsi untuk menjalankan bot secara terus-menerus | |
| def run_bot(): | |
| print("Bot mulai mendengarkan pesan...") | |
| bot.polling(non_stop=True) | |
| if __name__ == "__main__": | |
| # Jalankan bot di latar belakang | |
| threading.Thread(target=run_bot).start() | |
| # Jalankan web server di port 7860 sesuai aturan Hugging Face | |
| app.run(host="0.0.0.0", port=7860) |