Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,12 +13,43 @@ import os
|
|
13 |
from gradio_client import Client, file
|
14 |
import subprocess
|
15 |
import ffmpeg
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
api_key = os.getenv("OPEN_AI_KEY")
|
19 |
user_name = os.getenv("USER_NAME")
|
20 |
password = os.getenv("PASSWORD")
|
21 |
|
|
|
|
|
22 |
LENGTH = 3
|
23 |
WEBCAM = 0
|
24 |
|
|
|
13 |
from gradio_client import Client, file
|
14 |
import subprocess
|
15 |
import ffmpeg
|
16 |
+
|
17 |
+
# Slack integration start
|
18 |
+
from slack_sdk import WebClient
|
19 |
+
from slack_sdk.errors import SlackApiError
|
20 |
+
|
21 |
+
def send_message_with_file(
|
22 |
+
title: str, filename: str, message: str, file_path: str
|
23 |
+
):
|
24 |
+
client = WebClient(token=SLACK_BOT_TOKEN)
|
25 |
+
|
26 |
+
try:
|
27 |
+
response = client.files_upload_v2(
|
28 |
+
channel=SLACK_BOT_CHANNEL_ID,
|
29 |
+
initial_comment=message,
|
30 |
+
file=file_path,
|
31 |
+
title=title,
|
32 |
+
filename=filename,
|
33 |
+
)
|
34 |
+
if response.get("ok"):
|
35 |
+
print("Message with image sent successfully!")
|
36 |
+
else:
|
37 |
+
print("Failed to send message with image:", response)
|
38 |
+
|
39 |
+
except SlackApiError as e:
|
40 |
+
# Handle Slack-specific errors
|
41 |
+
print(f"Slack API Error: {e.response.get('error')}")
|
42 |
+
|
43 |
+
SLACK_BOT_TOKEN = os.getenv("SLACK_BOT_TOKEN")
|
44 |
+
SLACK_BOT_CHANNEL_ID = os.getenv("SLACK_BOT_CHANNEL_ID")
|
45 |
+
# Slack integration end
|
46 |
|
47 |
api_key = os.getenv("OPEN_AI_KEY")
|
48 |
user_name = os.getenv("USER_NAME")
|
49 |
password = os.getenv("PASSWORD")
|
50 |
|
51 |
+
|
52 |
+
|
53 |
LENGTH = 3
|
54 |
WEBCAM = 0
|
55 |
|