@@ -351,6 +351,27 @@ def build_conversation_content(payload, token):
351
351
}
352
352
)
353
353
354
+ # Support plaintext snippets
355
+ elif file ["mimetype" ] in ["text/plain" ]:
356
+ # File is a supported type
357
+ snippet_file_url = file ["url_private_download" ]
358
+
359
+ # Fetch the file and continue
360
+ snippet_file_object = requests .get (
361
+ snippet_file_url , headers = {"Authorization" : "Bearer " + token }
362
+ )
363
+
364
+ # Decode the file into plaintext
365
+ snippet_text = snippet_file_object .content .decode ("utf-8" )
366
+
367
+ # Append the file to the content array
368
+ content .append (
369
+ {
370
+ "type" : "text" ,
371
+ "text" : f"{ speaker_name } ({ pronouns } ) attached a snippet of text:\n \n { snippet_text } " ,
372
+ }
373
+ )
374
+
354
375
# If the mime type is not supported, set unsupported_file_type_found to True
355
376
else :
356
377
print (f"Unsupported file type found: { file ['mimetype' ]} " )
@@ -546,19 +567,19 @@ def lambda_handler(event, context):
546
567
# Isolate body
547
568
event_body = isolate_event_body (event )
548
569
549
- # Check for duplicate event or trash messages, return 200 and exit if detected
550
- if check_for_duplicate_event (event ["headers" ], event_body ["event" ]):
551
- return generate_response (
552
- 200 , "❌ Detected a re-send or edited message, exiting"
553
- )
554
-
555
570
# Special challenge event for Slack. If receive a challenge request, immediately return the challenge
556
571
if "challenge" in event_body :
557
572
return {
558
573
"statusCode" : 200 ,
559
574
"body" : json .dumps ({"challenge" : event_body ["challenge" ]}),
560
575
}
561
576
577
+ # Check for duplicate event or trash messages, return 200 and exit if detected
578
+ if check_for_duplicate_event (event ["headers" ], event_body ["event" ]):
579
+ return generate_response (
580
+ 200 , "❌ Detected a re-send or edited message, exiting"
581
+ )
582
+
562
583
# Print the event
563
584
print ("🚀 Event:" , event )
564
585
@@ -596,7 +617,7 @@ def handle_message_events(client, body, say, req):
596
617
return slack_handler .handle (event , context )
597
618
598
619
599
- # Main function
620
+ # Main function, primarily for local development
600
621
if __name__ == "__main__" :
601
622
602
623
# Run in local development mode
0 commit comments