File size: 729 Bytes
b37ebd1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Hugging Face Space entrypoint (Gradio SDK).

Gradio only serves a tiny status page (also used for uptime pings).
The Telegram bot runs in a background thread.
"""
import asyncio
import threading

import gradio as gr

try:  # ZeroGPU Spaces expect at least one @spaces.GPU function
    import spaces

    @spaces.GPU
    def _noop():
        return "ok"
except ImportError:  # running locally
    pass

from app.main import run_bot_forever


def _runner() -> None:
    asyncio.run(run_bot_forever())


threading.Thread(target=_runner, daemon=True, name="telegram-bot").start()

with gr.Blocks(title="DBU Central Bot") as demo:
    gr.Markdown("### DBU Central Bot is running ✅")

if __name__ == "__main__":
    demo.launch()