randydev commited on
Commit
8bef42a
·
verified ·
1 Parent(s): 5edf6d2

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +26 -0
main.py CHANGED
@@ -1,4 +1,30 @@
 
 
1
  from akenoai.runner import run_fast
 
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  run_fast(port=7860)
 
1
+ import logging
2
+ from akenoai import AkenoXToJs as js
3
  from akenoai.runner import run_fast
4
+ from config import API_ID, API_HASH, BOT_TOKEN
5
 
6
+ logger = logging.getLogger(__name__)
7
+ LOGS = logging.getLogger("[akenox]")
8
+ logger.setLevel(logging.DEBUG)
9
+
10
+ app = js.get_app()
11
+ js.add_cors_middleware()
12
+
13
+ client = js.create_pyrogram(
14
+ "fastapi-bot",
15
+ api_id=API_ID,
16
+ api_hash=API_HASH,
17
+ bot_token=BOT_TOKEN
18
+ )
19
+
20
+ @app.on_event("startup")
21
+ async def startup_event():
22
+ user = await client.start()
23
+ LOGS.info(f"Started Bot: {user.me.first_name}")
24
+
25
+ @app.get("/api/send")
26
+ async def send_message():
27
+ response_json = await client.send_message("@xpushz", "hello world!")
28
+ return {"success": response_json}
29
 
30
  run_fast(port=7860)