Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
daily ping changes -> live
Browse files
app.py
CHANGED
@@ -30,7 +30,36 @@ DATA_DISCUSSIONS_CHANNEL_ID = 1217179426002047076
|
|
30 |
|
31 |
TRIGGERS = {
|
32 |
("discord bot",): "<@U051DB2754M>", # adam
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
|
36 |
daily_pings = []
|
@@ -59,28 +88,25 @@ async def on_message(message):
|
|
59 |
|
60 |
huggingfolks_role = discord.utils.get(message.guild.roles, id=897376942817419265)
|
61 |
bots_role = discord.utils.get(message.guild.roles, id=1258328471609016341)
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
# Check if the message is in a thread
|
85 |
if isinstance(message.channel, discord.Thread):
|
86 |
discord_thread_id = message.channel.id
|
@@ -98,7 +124,6 @@ def extract_adjacent_words(content, trigger):
|
|
98 |
words = content.split()
|
99 |
pattern = r'\s*\b'.join(map(re.escape, trigger))
|
100 |
regex = re.compile(pattern, re.IGNORECASE)
|
101 |
-
|
102 |
match = regex.search(content)
|
103 |
if match:
|
104 |
start, end = match.span()
|
@@ -218,7 +243,7 @@ def send_daily_pings():
|
|
218 |
print(f"sending daily pings...{daily_pings}")
|
219 |
# combine into one message
|
220 |
main_message = slack_client.chat_postMessage(
|
221 |
-
channel=
|
222 |
text=f"DAILY PINGS FOR {datetime.now().strftime('%d/%m/%Y')}",
|
223 |
unfurl_links=False,
|
224 |
unfurl_media=False
|
@@ -226,7 +251,7 @@ def send_daily_pings():
|
|
226 |
main_ts = main_message['ts']
|
227 |
for ping in daily_pings:
|
228 |
slack_client.chat_postMessage(
|
229 |
-
channel=
|
230 |
text=f"{ping['mention']} (for the keyword -> '{ping['trigger']}')\nFrom {ping['author']} in channel #{ping['channel']}: {ping['content']}\n{ping['url']}",
|
231 |
thread_ts=main_ts,
|
232 |
unfurl_links=False,
|
@@ -238,7 +263,7 @@ def send_daily_pings():
|
|
238 |
# pings -------------------------------------------------------------------------------------------
|
239 |
executor = ThreadPoolExecutor(max_workers=1)
|
240 |
scheduler = BackgroundScheduler(executors={'default': executor})
|
241 |
-
scheduler.add_job(send_daily_pings, trigger='interval',
|
242 |
scheduler.start()
|
243 |
|
244 |
|
|
|
30 |
|
31 |
TRIGGERS = {
|
32 |
("discord bot",): "<@U051DB2754M>", # adam
|
33 |
+
("autotrain",): "<@U01E3LEC2N7>", # abhishek
|
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 = []
|
|
|
88 |
|
89 |
huggingfolks_role = discord.utils.get(message.guild.roles, id=897376942817419265)
|
90 |
bots_role = discord.utils.get(message.guild.roles, id=1258328471609016341)
|
91 |
+
if huggingfolks_role not in message.author.roles: # no need for ping if we're already discussing
|
92 |
+
if bots_role not in message.author.roles: # bots shouldn't trigger pings for this
|
93 |
+
print(" not bot ")
|
94 |
+
content = message.content.lower()
|
95 |
+
|
96 |
+
for trigger, slack_mention in TRIGGERS.items():
|
97 |
+
if all(word in content for word in trigger):
|
98 |
+
adjacent_words = extract_adjacent_words(message.content, trigger)
|
99 |
+
daily_pings.append({
|
100 |
+
'author': str(message.author),
|
101 |
+
'content': adjacent_words,
|
102 |
+
'channel': message.channel.name,
|
103 |
+
'url': message.jump_url,
|
104 |
+
'mention': slack_mention,
|
105 |
+
'trigger': trigger
|
106 |
+
})
|
107 |
+
print(f"daily pings:{daily_pings}")
|
108 |
+
break
|
109 |
|
|
|
|
|
|
|
110 |
# Check if the message is in a thread
|
111 |
if isinstance(message.channel, discord.Thread):
|
112 |
discord_thread_id = message.channel.id
|
|
|
124 |
words = content.split()
|
125 |
pattern = r'\s*\b'.join(map(re.escape, trigger))
|
126 |
regex = re.compile(pattern, re.IGNORECASE)
|
|
|
127 |
match = regex.search(content)
|
128 |
if match:
|
129 |
start, end = match.span()
|
|
|
243 |
print(f"sending daily pings...{daily_pings}")
|
244 |
# combine into one message
|
245 |
main_message = slack_client.chat_postMessage(
|
246 |
+
channel=SLACK_CHANNEL_ID,
|
247 |
text=f"DAILY PINGS FOR {datetime.now().strftime('%d/%m/%Y')}",
|
248 |
unfurl_links=False,
|
249 |
unfurl_media=False
|
|
|
251 |
main_ts = main_message['ts']
|
252 |
for ping in daily_pings:
|
253 |
slack_client.chat_postMessage(
|
254 |
+
channel=SLACK_CHANNEL_ID,
|
255 |
text=f"{ping['mention']} (for the keyword -> '{ping['trigger']}')\nFrom {ping['author']} in channel #{ping['channel']}: {ping['content']}\n{ping['url']}",
|
256 |
thread_ts=main_ts,
|
257 |
unfurl_links=False,
|
|
|
263 |
# pings -------------------------------------------------------------------------------------------
|
264 |
executor = ThreadPoolExecutor(max_workers=1)
|
265 |
scheduler = BackgroundScheduler(executors={'default': executor})
|
266 |
+
scheduler.add_job(send_daily_pings, trigger='interval', days=1)
|
267 |
scheduler.start()
|
268 |
|
269 |
|