Muttered3 commited on
Commit
bbae4ad
Β·
verified Β·
1 Parent(s): 063739f

Delete main.py

Browse files
Files changed (1) hide show
  1. main.py +0 -80
main.py DELETED
@@ -1,80 +0,0 @@
1
- # ════════════════════════════════════════
2
- # FILE: main.py
3
- # ════════════════════════════════════════
4
-
5
- """
6
- ╔══════════════════════════════════════════════════════════════════════╗
7
- β•‘ DEPLOYMENT GUIDE β•‘
8
- ╠══════════════════════════════════════════════════════════════════════╣
9
- β•‘ STEP 1 Get API credentials β•‘
10
- β•‘ my.telegram.org β†’ API development tools β•‘
11
- β•‘ Copy API_ID (int) and API_HASH (str) β•‘
12
- β•‘ β•‘
13
- β•‘ STEP 2 Create bot β•‘
14
- β•‘ @BotFather β†’ /newbot β†’ copy BOT_TOKEN β•‘
15
- β•‘ β•‘
16
- β•‘ STEP 3 Get your user ID β•‘
17
- β•‘ @userinfobot β†’ copy integer ID β†’ ADMIN_USER_IDS β•‘
18
- β•‘ β•‘
19
- β•‘ STEP 4 Create HF Space β•‘
20
- β•‘ huggingface.co/new-space β†’ SDK: Docker β†’ Visibility: Private β•‘
21
- β•‘ β•‘
22
- β•‘ STEP 5 Add Repository Secrets β•‘
23
- β•‘ Space β†’ Settings β†’ Repository Secrets β•‘
24
- β•‘ BOT_TOKEN BotFather token β•‘
25
- β•‘ API_ID integer β•‘
26
- β•‘ API_HASH string β•‘
27
- β•‘ REDIS_URL full redis:// URL β•‘
28
- β•‘ ADMIN_USER_IDS comma-separated IDs β•‘
29
- β•‘ β•‘
30
- β•‘ STEP 6 Push code β•‘
31
- β•‘ git clone https://huggingface.co/spaces/YOU/SPACE β•‘
32
- β•‘ cp *.py Dockerfile requirements.txt SPACE/ β•‘
33
- β•‘ cd SPACE && git add . && git commit -m deploy && git push β•‘
34
- β•‘ Watch build in Space β†’ Logs tab β•‘
35
- β•‘ β•‘
36
- β•‘ STEP 7 Verify health endpoint β•‘
37
- β•‘ https://YOU-SPACE.hf.space/health β•‘
38
- β•‘ Expected: {"status":"ok","redis":"connected"} β•‘
39
- β•‘ β•‘
40
- β•‘ STEP 8 UptimeRobot β€” prevent HF Space from sleeping β•‘
41
- β•‘ uptimerobot.com β†’ New Monitor β†’ HTTP(s) β•‘
42
- β•‘ URL: https://YOU-SPACE.hf.space/ping β•‘
43
- β•‘ Interval: 5 minutes β•‘
44
- β•‘ β•‘
45
- β•‘ COMMON ERRORS β•‘
46
- β•‘ Crashes on start β†’ Logs tab, usually missing env var β•‘
47
- β•‘ Bot not responding β†’ ADMIN_USER_IDS wrong, verify @userinfobot β•‘
48
- β•‘ AUTH_KEY error β†’ API_ID or API_HASH wrong β•‘
49
- β•‘ Redis unreachable β†’ use /ping, check REDIS_URL secret β•‘
50
- β•‘ Port 7080 dead β†’ keep_alive must use AppRunner+TCPSite β•‘
51
- β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
52
- """
53
-
54
- import asyncio
55
- import nest_asyncio
56
- nest_asyncio.apply()
57
-
58
- from pyrogram import Client
59
- import config
60
- import bot
61
- from keep_alive import start_server
62
-
63
- def make_client() -> Client:
64
- return Client(
65
- name="scanner_bot",
66
- api_id=config.API_ID,
67
- api_hash=config.API_HASH,
68
- bot_token=config.BOT_TOKEN,
69
- in_memory=True,
70
- )
71
-
72
- async def main():
73
- client = make_client()
74
- await asyncio.gather(
75
- start_server(),
76
- bot.run_bot(client),
77
- )
78
-
79
- if __name__ == "__main__":
80
- asyncio.run(main())