Spaces:
Paused
Paused
test separate thread daily pings
Browse files
app.py
CHANGED
|
@@ -28,40 +28,15 @@ ARGILLA_HELP_CHANNEL_ID = 1253640751481356330
|
|
| 28 |
DATA_DISCUSSIONS_CHANNEL_ID = 1217179426002047076
|
| 29 |
|
| 30 |
|
|
|
|
|
|
|
|
|
|
| 31 |
TRIGGERS = {
|
| 32 |
("discord bot",): "<@U051DB2754M>", # adam
|
| 33 |
-
|
| 34 |
-
("auto train",): "<@U01E3LEC2N7>", # abhishek
|
| 35 |
-
("competition",): "<@U01E3LEC2N7>", # abhishek
|
| 36 |
-
("competitions",): "<@U01E3LEC2N7>", # abhishek
|
| 37 |
-
("text to speech",): "<@U039C2GANMV>", # VB
|
| 38 |
-
("tts",): "<@U039C2GANMV>", # VB
|
| 39 |
-
("asr",): "<@U039C2GANMV>", # VB
|
| 40 |
-
("musicgen",): "<@U039C2GANMV>", # VB
|
| 41 |
-
("whisper",): "<@U039C2GANMV>", # VB
|
| 42 |
-
("speech recognition",): "<@U039C2GANMV>", # VB
|
| 43 |
-
("bark",): "<@U039C2GANMV>", # VB
|
| 44 |
-
("sentence-transformers",): "<@U04E4DNPWG7>", # tom aarsen
|
| 45 |
-
("sentence_transformers",): "<@U04E4DNPWG7>", # tom aarsen
|
| 46 |
-
("setfit",): "<@U04E4DNPWG7>", # tom aarsen
|
| 47 |
-
("sentence transformers",): "<@U04E4DNPWG7>", # tom aarsen
|
| 48 |
-
("argilla",): "<@U076B8C7G3E>", # david berenstein
|
| 49 |
-
("distilabel",): "<@U076B8C7G3E>", # david berenstein
|
| 50 |
-
("argilla",): "<@U0766H30T7F>", # natalia elvira
|
| 51 |
-
("dataset",): "<@U0766H30T7F>", # natalia elvira
|
| 52 |
-
("docs",): "<@U02DATT4C5B>", # steven liu
|
| 53 |
-
("documentation",): "<@U02DATT4C5B>", # steven liu
|
| 54 |
-
("gradio",): "<@U02NMK75F1V>", # abubakar abid
|
| 55 |
-
("gradio",): "<@U04FLGQ26PQ>", # yuvraj sharma
|
| 56 |
-
("argilla",): "<@U076MF65WEM>", # sara han diaz lorenzo
|
| 57 |
-
("distilabel",): "<@U076MF65WEM>", # sara han diaz lorenzo
|
| 58 |
-
("argilla",): "<@U0765RENPNZ>", # sara han diaz lorenzo
|
| 59 |
-
("distilabel",): "<@U0765RENPNZ>", # sara han diaz lorenzo
|
| 60 |
-
("dataset", "feedback"): "<@U0768RCHCRY>", # ben burtenshaw
|
| 61 |
-
("distilabel",): "<@U0768QEN0LA>", # Gabriel Martín Blázquez
|
| 62 |
-
("distilabel",): "<@U076271MBUN>", # Agustín Piqueres
|
| 63 |
}
|
| 64 |
|
|
|
|
| 65 |
daily_pings = []
|
| 66 |
|
| 67 |
intents = discord.Intents.all()
|
|
@@ -241,29 +216,39 @@ def send_daily_pings():
|
|
| 241 |
global daily_pings
|
| 242 |
if daily_pings:
|
| 243 |
print(f"sending daily pings...{daily_pings}")
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
text=f"DAILY PINGS FOR {datetime.now().strftime('%d/%m/%Y')}",
|
| 248 |
-
unfurl_links=False,
|
| 249 |
-
unfurl_media=False
|
| 250 |
-
)
|
| 251 |
-
main_ts = main_message['ts']
|
| 252 |
for ping in daily_pings:
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
unfurl_links=False,
|
| 258 |
unfurl_media=False
|
| 259 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
|
| 261 |
daily_pings = [] # reset after posting
|
| 262 |
|
| 263 |
# pings -------------------------------------------------------------------------------------------
|
| 264 |
executor = ThreadPoolExecutor(max_workers=1)
|
| 265 |
scheduler = BackgroundScheduler(executors={'default': executor})
|
| 266 |
-
scheduler.add_job(send_daily_pings, trigger='interval',
|
| 267 |
scheduler.start()
|
| 268 |
|
| 269 |
|
|
|
|
| 28 |
DATA_DISCUSSIONS_CHANNEL_ID = 1217179426002047076
|
| 29 |
|
| 30 |
|
| 31 |
+
# U051DB2754M == adam hf real slack
|
| 32 |
+
# U061W3NRFFA == lunarflu test slack
|
| 33 |
+
|
| 34 |
TRIGGERS = {
|
| 35 |
("discord bot",): "<@U051DB2754M>", # adam
|
| 36 |
+
("lunarflu",): "<@U061W3NRFFA>" # lunarflu test slack
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
}
|
| 38 |
|
| 39 |
+
|
| 40 |
daily_pings = []
|
| 41 |
|
| 42 |
intents = discord.Intents.all()
|
|
|
|
| 216 |
global daily_pings
|
| 217 |
if daily_pings:
|
| 218 |
print(f"sending daily pings...{daily_pings}")
|
| 219 |
+
pings_by_mention = {}
|
| 220 |
+
|
| 221 |
+
# group pings by mention
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
for ping in daily_pings:
|
| 223 |
+
mention = ping['mention']
|
| 224 |
+
if mention not in pings_by_mention:
|
| 225 |
+
pings_by_mention[mention] = []
|
| 226 |
+
pings_by_mention[mention].append(ping)
|
| 227 |
+
|
| 228 |
+
# send each group of pings in a separate thread
|
| 229 |
+
for mention, pings in pings_by_mention.items():
|
| 230 |
+
main_message = slack_client.chat_postMessage(
|
| 231 |
+
channel=TEST_SLACK_CHANNEL_ID_TEST,
|
| 232 |
+
text=f"DAILY PINGS FOR {mention} ON {datetime.now().strftime('%d/%m/%Y')}",
|
| 233 |
unfurl_links=False,
|
| 234 |
unfurl_media=False
|
| 235 |
+
)
|
| 236 |
+
main_ts = main_message['ts']
|
| 237 |
+
for ping in pings:
|
| 238 |
+
slack_client.chat_postMessage(
|
| 239 |
+
channel=TEST_SLACK_CHANNEL_ID_TEST,
|
| 240 |
+
text=f"{ping['mention']} (for the keyword -> '{ping['trigger']}')\nFrom {ping['author']} in channel #{ping['channel']}: {ping['content']}\n{ping['url']}",
|
| 241 |
+
thread_ts=main_ts,
|
| 242 |
+
unfurl_links=False,
|
| 243 |
+
unfurl_media=False
|
| 244 |
+
)
|
| 245 |
|
| 246 |
daily_pings = [] # reset after posting
|
| 247 |
|
| 248 |
# pings -------------------------------------------------------------------------------------------
|
| 249 |
executor = ThreadPoolExecutor(max_workers=1)
|
| 250 |
scheduler = BackgroundScheduler(executors={'default': executor})
|
| 251 |
+
scheduler.add_job(send_daily_pings, trigger='interval', seconds=30)
|
| 252 |
scheduler.start()
|
| 253 |
|
| 254 |
|