CaesarCloudSync commited on
Commit
8951a9e
1 Parent(s): 115c701

CaesarAI Telegram Message

Browse files
CaesarAIMusicLoad/caesaraimusicload.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+ class CaesarAITelegramBOT:
4
+ def __init__(self) -> None:
5
+ self.TOKEN = "6186492282:AAEOrXHlfhKZDnOo8ekQqu2glfmF9v4UEWE"
6
+ def get_chatids(self):
7
+ url = f"https://api.telegram.org/bot{self.TOKEN}/getUpdates"
8
+ response = requests.get(url).json()
9
+ return response
10
+ def send_message(self,chat_id,message):
11
+ url = f"https://api.telegram.org/bot{self.TOKEN}/sendMessage?chat_id={chat_id}&text={message}"
12
+ response = requests.get(url).json()
13
+ return response
RequestModels.py CHANGED
@@ -30,7 +30,9 @@ class CaesarStockInfoModel(BaseModel):
30
  stock: str
31
  start_date: str
32
  end_date: str
33
-
 
 
34
 
35
  class CaesarVoiceModel(BaseModel):
36
  filename: Union[str,None]
 
30
  stock: str
31
  start_date: str
32
  end_date: str
33
+ class CaesarTelegramMessageModel(BaseModel):
34
+ chat_id: str
35
+ message: str
36
 
37
  class CaesarVoiceModel(BaseModel):
38
  filename: Union[str,None]
main.py CHANGED
@@ -28,10 +28,11 @@ from CaesarVoice import CaesarVoice
28
  from csv_to_db import ImportCSV
29
  from RequestModels import *
30
  from CaesarFaceRecognition.caesardeepface import CaesarDeepFace
31
-
32
  importcsv = ImportCSV("CaesarAI")
33
  caesaryolo = CaesarYolo()
34
  caesarfacedetectmodel = CaesarFaceDetection()
 
35
  app = FastAPI()
36
 
37
  CURRENT_DIR = os.path.realpath(__file__).replace(f"/main.py","")
@@ -88,6 +89,23 @@ async def caesarfacedetect(websocket: WebSocket):
88
 
89
  except WebSocketDisconnect:
90
  print("Client disconnected")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
  @app.post("/caesarfacesnap")
93
  def caesarfacesnap(frames: CaesarOCRHTTPModel):
 
28
  from csv_to_db import ImportCSV
29
  from RequestModels import *
30
  from CaesarFaceRecognition.caesardeepface import CaesarDeepFace
31
+ from CaesarAIMusicLoad.caesaraimusicload import CaesarAITelegramBOT
32
  importcsv = ImportCSV("CaesarAI")
33
  caesaryolo = CaesarYolo()
34
  caesarfacedetectmodel = CaesarFaceDetection()
35
+ caesartelgegrambot = CaesarAITelegramBOT()
36
  app = FastAPI()
37
 
38
  CURRENT_DIR = os.path.realpath(__file__).replace(f"/main.py","")
 
89
 
90
  except WebSocketDisconnect:
91
  print("Client disconnected")
92
+ @app.get("/getcaesartelegramchatids")
93
+ def getcaesartelegramchatid():
94
+ try:
95
+ chatids = caesartelgegrambot.get_chatids()
96
+ return chatids
97
+ except Exception as ex:
98
+ return {"error":f"{type(ex)},{ex}"}
99
+ @app.get("/caesartelegramsendmessage")
100
+ def caesartelegramsendmessage(messageinfo: CaesarAITelegramBOT):
101
+ try:
102
+ messageinfo = dict(messageinfo)
103
+ chat_id = messageinfo["chat_id"]
104
+ message = messageinfo["message"]
105
+ chatids = caesartelgegrambot.send_message(chat_id,message)
106
+ return chatids
107
+ except Exception as ex:
108
+ return {"error":f"{type(ex)},{ex}"}
109
 
110
  @app.post("/caesarfacesnap")
111
  def caesarfacesnap(frames: CaesarOCRHTTPModel):