Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change parse mode #16

Merged
merged 9 commits into from Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Expand Up @@ -13,7 +13,7 @@ COLUMN_NODE_ID_PR=
NOTIFIER_URL=

# List of people to tag in the «Pull Requests» message
MENTION = "ilyamore88 fabled228 Xemka kebyo GeekaN2 ranemihir Robonetphy neSpecc nikmel2803 talyguryn gohabereg khaydarov f0m41h4u7 SunnyCapt dependabot"
MENTION = "ilyamore88 fabled228 Xemka kebyo GeekaN2 ranemihir Robonetphy neSpecc nikmel2803 n0str talyguryn gohabereg khaydarov f0m41h4u7 SunnyCapt dependabot"

# List of people to tag in the «Meeting Message» message
MEETING_MENTION = "specc guryn khaydarovm nikmel2803 xemk4 gohabereg ilyamore88 GeekaN augustovich n0str f0m41h4u7 polina_shneider oybekmuslimov"
Expand Down
20 changes: 11 additions & 9 deletions src/index.js
Expand Up @@ -37,7 +37,7 @@ const PR_QUERY = require('./queries/pr');
/**
* Sends POST request to telegram bot
*
* @param {string} message - telegram message.
* @param {string} message - telegram message
* @returns {Promise} - returns a promise to catch error.
*/
async function notify(message) {
Expand Down Expand Up @@ -95,9 +95,9 @@ function replaceGithubLink(message, markdownLink) {
* @returns {string}
*/
function escapeChars(message) {
message = message.replaceAll('<', '&lt;');
message = message.replaceAll('>', '&gt;');
message = message.replaceAll('&', '&amp;');
message = message.replace(/</g, '&lt;');
message = message.replace(/>/g, '&gt;');
message = message.replace(/&/g, '&amp;');
Comment on lines +98 to +100
Copy link
Member

@robonetphy robonetphy Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@talyguryn I change this because replaceAll throwing me an error

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it work correctly for multiple entities?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup


return message;
}
Expand Down Expand Up @@ -214,7 +214,7 @@ async function parseQuery(members, response) {
await response.map(async (items) => {
if (items.state === 'NOTE_ONLY') {
for (let i = 0; i < members.length; i++) {
if (items.note.includes(`@${members[i].name}`)) {
if (items.note.includes(`@${members[i].name}`) || items.note.includes(`@${members[i].name.toLowerCase()}`)) {
const parsable = checkForParsableGithubLink(items.note);

return parsable[0]
Expand Down Expand Up @@ -243,15 +243,17 @@ async function parseQuery(members, response) {
let cardDataWithoutMembers = [ ...parsedCardData ];

for (let i = 0; i < members.length; i++) {
cardDataWithoutMembers = cardDataWithoutMembers.map((x) =>
x.replace(new RegExp(`@${members[i].name}`, 'g'), '')
);
cardDataWithoutMembers = cardDataWithoutMembers.map((x) => {
const data = x.replace(new RegExp(`@${members[i].name}`, 'g'), '');

return data.replace(new RegExp(`@${members[i].name.toLowerCase()}`, 'g'), '');
});
}
cardDataWithoutMembers = cardDataWithoutMembers.map((x) => x.replace(/^\s+|\s+$/g, ''));

parsedCardData.forEach((items, index) => {
for (let i = 0; i < members.length; i++) {
if (items.includes(`@${members[i].name}`)) {
if (items.includes(`@${members[i].name}`) || items.includes(`@${members[i].name.toLowerCase()}`)) {
members[i].tasks.push(cardDataWithoutMembers[index]);
}
}
Expand Down