lunarflu HF Staff commited on
Commit
48e5a20
·
verified ·
1 Parent(s): b71c258

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -1,5 +1,13 @@
1
  import os
2
  import praw
 
 
 
 
 
 
 
 
3
 
4
  # working
5
 
@@ -53,6 +61,14 @@ def monitor_new_posts():
53
  print(f"Author: {submission.author}")
54
  print(f"URL: {submission.url}")
55
  print(f"Content: {submission.selftext}\n")
 
 
 
 
 
 
 
 
56
  except Exception as e:
57
  print(f"Error during streaming submissions: {e}")
58
 
 
1
  import os
2
  import praw
3
+ from slack_sdk import WebClient
4
+ from slack_sdk.errors import SlackApiError
5
+
6
+ SLACK_BOT_TOKEN = os.getenv('BOT_USER_OAUTH_TOKEN_HF')
7
+ SLACK_CHANNEL_ID = os.getenv('SLACK_CHANNEL_ID_HF')
8
+ SLACK_CHANNEL_ID_TEST = 'C07B4KNU5BQ'
9
+
10
+ slack_client = WebClient(token=SLACK_BOT_TOKEN)
11
 
12
  # working
13
 
 
61
  print(f"Author: {submission.author}")
62
  print(f"URL: {submission.url}")
63
  print(f"Content: {submission.selftext}\n")
64
+
65
+ response = slack_client.chat_postMessage(
66
+ channel=SLACK_CHANNEL_ID_TEST,
67
+ text=submission.selftext,
68
+ thread_ts=thread_ts,
69
+ unfurl_links=False,
70
+ unfurl_media=False
71
+ )
72
  except Exception as e:
73
  print(f"Error during streaming submissions: {e}")
74