From 8c0bc95245250e2f03e1ed396265124cffcb214b Mon Sep 17 00:00:00 2001 From: eriemer1 <77909520+eriemer1@users.noreply.github.com> Date: Wed, 4 Oct 2023 21:41:54 -0600 Subject: [PATCH 1/3] Create Welcome react.js New parser to respond in a thread when the :welcome: react is used to greet new users and give some general tips on being a good member of the SNDevs slack --- Parsers/Welcome react.js | 98 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 Parsers/Welcome react.js diff --git a/Parsers/Welcome react.js b/Parsers/Welcome react.js new file mode 100644 index 0000000..43ea042 --- /dev/null +++ b/Parsers/Welcome react.js @@ -0,0 +1,98 @@ +/* +emoji:welcome +*/ + +var message = { + "type": "home", + "blocks": [{ + "type": "header", + "text": { + "type": "plain_text", + "text": "Hello and welcome to SNDevs slack!" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Here are some tips to get you started*" + } + }, + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Asking Good questions" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "- Use Threads! #general gets busy so make sure to keep conversation about your question in the original thread. \n- Write a title that summarizes the specific problem. \n- Pretend you're talking to a busy colleague.\n -Spelling, grammar, and punctuation are important! \n- Bad: GlideRecord isn't working \n- Good: Why does str == 'value' evaluate to false when str is set to 'value' in my script? \n- Proof-read before posting! \n- Post the question and respond to feedback" + } + }, + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Posting Code" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "- Introduce the problem before you post any code. \n- Help others reproduce the problem. Don't just copy in your entire script. \n- Do not post images of code, data, error messages (just copy the text).\n -When posting code wrap it in 1x and 3x back-tick [`] syntax, or use the code editor \n- `your text` = Red highlighted single-line \n ```your text``` = Grey highlighted multi-line \n- Or use the code button on the text editor in slack." + } + }, + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Give Points to say thank you!" + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "If someone successfully helped you (or ever just help you get closer to the answer) tag them with a ++ in the thread. eg. <@' + current.user.user_id + '> ++ will grant that user some community points to show how helpful they were." + } + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "Looking for more helpful tips? These tips are mostly from https://stackoverflow.com/help/how-to-ask" + } + } + ] +}; + +//This should find any other payloads where there is already a :welcome: reaction in the thread to prevent the message from firing more than once +var previousMessage = new global.GlideQuery('x_snc_slackerbot_payload') + .where('payload', 'CONTAINS', '"type": "reaction_added"') + .where('payload', 'CONTAINS', '"reaction": "welcome"') + .where('payload', 'CONTAINS', '"is_bot": true') + .where('payload', 'CONTAINS', '"thread_ts": ' + current.thread_ts) + .selectOne() + .isPresent(); + +if (!previousMessage) + new x_snc_slackerbot.Slacker().send_chat(current, message, true); From 6d2718067fce9bd15dad1f70da795572b75dc9ea Mon Sep 17 00:00:00 2001 From: eriemer1 <77909520+eriemer1@users.noreply.github.com> Date: Thu, 5 Oct 2023 08:55:24 -0600 Subject: [PATCH 2/3] Update Welcome react.js fixes to add actual bullets instead of letting markdown do it and "" where they were needed --- Parsers/Welcome react.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Parsers/Welcome react.js b/Parsers/Welcome react.js index 43ea042..213ffac 100644 --- a/Parsers/Welcome react.js +++ b/Parsers/Welcome react.js @@ -4,7 +4,8 @@ emoji:welcome var message = { "type": "home", - "blocks": [{ + "blocks": [ + { "type": "header", "text": { "type": "plain_text", @@ -35,7 +36,7 @@ var message = { "type": "section", "text": { "type": "mrkdwn", - "text": "- Use Threads! #general gets busy so make sure to keep conversation about your question in the original thread. \n- Write a title that summarizes the specific problem. \n- Pretend you're talking to a busy colleague.\n -Spelling, grammar, and punctuation are important! \n- Bad: GlideRecord isn't working \n- Good: Why does str == 'value' evaluate to false when str is set to 'value' in my script? \n- Proof-read before posting! \n- Post the question and respond to feedback" + "text": " • Use Threads! #general gets busy so make sure to keep conversation about your question in the original thread. \n • Write a title that summarizes the specific problem. \n • Pretend you're talking to a busy colleague.\n • Spelling, grammar, and punctuation are important! \n • Bad: GlideRecord isn't working \n • Good: Why does str == 'value' evaluate to false when str is set to 'value' in my script? \n • Proof-read before posting! \n • Post the question and respond to feedback" } }, { @@ -52,7 +53,7 @@ var message = { "type": "section", "text": { "type": "mrkdwn", - "text": "- Introduce the problem before you post any code. \n- Help others reproduce the problem. Don't just copy in your entire script. \n- Do not post images of code, data, error messages (just copy the text).\n -When posting code wrap it in 1x and 3x back-tick [`] syntax, or use the code editor \n- `your text` = Red highlighted single-line \n ```your text``` = Grey highlighted multi-line \n- Or use the code button on the text editor in slack." + "text": " • Introduce the problem before you post any code. \n • Help others reproduce the problem. Don't just copy in your entire script. \n- Do not post images of code, data, error messages (just copy the text).\n • When posting code wrap it in 1x and 3x back-tick [`] syntax, or use the code editor \n ````your text` = Red highlighted single-line``` \n ``````your text`````` ```= Grey highlighted multi-line``` \n • Or use the code button on the text editor in slack." } }, { @@ -69,7 +70,7 @@ var message = { "type": "section", "text": { "type": "mrkdwn", - "text": "If someone successfully helped you (or ever just help you get closer to the answer) tag them with a ++ in the thread. eg. <@' + current.user.user_id + '> ++ will grant that user some community points to show how helpful they were." + "text": "If someone successfully helped you (or ever just help you get closer to the answer) tag them with a ++ in the thread. eg. <@" + current.user.user_id + "> ++ will grant that user some community points to show how helpful they were." } }, { From 528d8a9f9e5b52d341606e8b8c188a27a322d18a Mon Sep 17 00:00:00 2001 From: eriemer1 <77909520+eriemer1@users.noreply.github.com> Date: Thu, 5 Oct 2023 08:56:16 -0600 Subject: [PATCH 3/3] Update Welcome react.js Removed the '"is_bot": true' condition --- Parsers/Welcome react.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Parsers/Welcome react.js b/Parsers/Welcome react.js index 213ffac..83794b8 100644 --- a/Parsers/Welcome react.js +++ b/Parsers/Welcome react.js @@ -90,7 +90,6 @@ var message = { var previousMessage = new global.GlideQuery('x_snc_slackerbot_payload') .where('payload', 'CONTAINS', '"type": "reaction_added"') .where('payload', 'CONTAINS', '"reaction": "welcome"') - .where('payload', 'CONTAINS', '"is_bot": true') .where('payload', 'CONTAINS', '"thread_ts": ' + current.thread_ts) .selectOne() .isPresent();