ziv-conntour commited on
Commit
20fce65
·
verified ·
1 Parent(s): 0e01501

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -11
app.py CHANGED
@@ -21,20 +21,24 @@ from slack_sdk.errors import SlackApiError
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 file sent successfully!")
36
- else:
37
- print("Failed to send message with file:", response)
 
 
38
 
39
  except SlackApiError as e:
40
  # Handle Slack-specific errors
@@ -73,6 +77,8 @@ alerts_mode = True
73
 
74
  base_start_time = time.time()
75
 
 
 
76
  print("base_start_time", base_start_time)
77
 
78
  def clip_video_segment_2(input_video_path, start_time, duration):
@@ -397,7 +403,10 @@ def analyze_video_file(prompt, chatbot):
397
  # Function to stop video capture
398
  def stop_capture_func():
399
  global stop_capture
 
 
400
  stop_capture = True
 
401
 
402
  def get_time():
403
  global base_start_time
 
21
  def send_message_with_file(
22
  title: str, filename: str, message: str, file_path: str
23
  ):
24
+ global SLACK_MESSAGES_SENT
25
  client = WebClient(token=SLACK_BOT_TOKEN)
26
 
27
+
28
  try:
29
+ if SLACK_MESSAGES_SENT < 2:
30
+ response = client.files_upload_v2(
31
+ channel=SLACK_BOT_CHANNEL_ID,
32
+ initial_comment=message,
33
+ file=file_path,
34
+ title=title,
35
+ filename=filename,
36
+ )
37
+ if response.get("ok"):
38
+ print("Message with file sent successfully!")
39
+ SLACK_MESSAGES_SENT += 1
40
+ else:
41
+ print("Failed to send message with file:", response)
42
 
43
  except SlackApiError as e:
44
  # Handle Slack-specific errors
 
77
 
78
  base_start_time = time.time()
79
 
80
+ SLACK_MESSAGES_SENT = 0
81
+
82
  print("base_start_time", base_start_time)
83
 
84
  def clip_video_segment_2(input_video_path, start_time, duration):
 
403
  # Function to stop video capture
404
  def stop_capture_func():
405
  global stop_capture
406
+ global SLACK_MESSAGES_SENT
407
+
408
  stop_capture = True
409
+ SLACK_MESSAGES_SENT = 0
410
 
411
  def get_time():
412
  global base_start_time