asyncio aver
Browse files- envia_mensaje.py +2 -13
envia_mensaje.py
CHANGED
|
@@ -2,9 +2,6 @@ import httpx
|
|
| 2 |
import asyncio
|
| 3 |
import os
|
| 4 |
import sys
|
| 5 |
-
from fastapi import FastAPI
|
| 6 |
-
|
| 7 |
-
app = FastAPI()
|
| 8 |
|
| 9 |
async def send_telegram_message(message):
|
| 10 |
TELEGRAM_BOT_TOKEN = os.environ.get("T_bot")
|
|
@@ -21,15 +18,7 @@ async def send_telegram_message(message):
|
|
| 21 |
if response.status_code != 200:
|
| 22 |
raise Exception(f"Error sending message: {response.text}")
|
| 23 |
|
| 24 |
-
|
| 25 |
-
async def startup_event():
|
| 26 |
if len(sys.argv) > 1:
|
| 27 |
message = sys.argv[1]
|
| 28 |
-
|
| 29 |
-
else:
|
| 30 |
-
print("Please provide a message as an argument.")
|
| 31 |
-
raise SystemExit
|
| 32 |
-
|
| 33 |
-
if __name__ == '__main__':
|
| 34 |
-
import uvicorn
|
| 35 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
| 2 |
import asyncio
|
| 3 |
import os
|
| 4 |
import sys
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
async def send_telegram_message(message):
|
| 7 |
TELEGRAM_BOT_TOKEN = os.environ.get("T_bot")
|
|
|
|
| 18 |
if response.status_code != 200:
|
| 19 |
raise Exception(f"Error sending message: {response.text}")
|
| 20 |
|
| 21 |
+
if __name__ == '__main__':
|
|
|
|
| 22 |
if len(sys.argv) > 1:
|
| 23 |
message = sys.argv[1]
|
| 24 |
+
asyncio.run(send_telegram_message(message))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|