Skip to content

Commit b8505a9

Browse files
committedOct 16, 2020
add filtering regex
1 parent 9d1116b commit b8505a9

File tree

4 files changed

+448
-424
lines changed

4 files changed

+448
-424
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules/
2+
temp/
23
.env
34
.env.local
45
/*.env

‎package-lock.json

+418-400
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
{
2-
"name": "hack-club-tele-discord",
3-
"version": "1.0.0",
4-
"description": "A discord-telegram bridge which forwards announcements to a telegram channel",
5-
"main": "src/index.js",
6-
"scripts": {
7-
"start": "node src/index.js",
8-
"dev": "nodemon src/index.js"
9-
},
10-
"author": "Kaushal",
11-
"license": "ISC",
12-
"dependencies": {
13-
"discord.js": "^12.3.1",
14-
"dotenv": "^8.2.0",
15-
"express": "^4.17.1",
16-
"node-telegram-bot-api": "^0.50.0"
17-
},
18-
"devDependencies": {
19-
"eslint": "^7.8.1",
20-
"nodemon": "^2.0.4",
21-
"prettier": "^2.1.1"
22-
}
2+
"name": "hack-club-tele-discord",
3+
"version": "1.0.0",
4+
"description": "A discord-telegram bridge which forwards announcements to a telegram channel",
5+
"main": "src/index.js",
6+
"scripts": {
7+
"start": "node src/index.js",
8+
"dev": "nodemon src/index.js",
9+
"devStart": "nodemon temp/index-test.js"
10+
},
11+
"author": "Kaushal",
12+
"license": "ISC",
13+
"dependencies": {
14+
"discord.js": "^12.3.1",
15+
"dotenv": "^8.2.0",
16+
"express": "^4.17.1",
17+
"node-telegram-bot-api": "^0.50.0"
18+
},
19+
"devDependencies": {
20+
"eslint": "^7.11.0",
21+
"nodemon": "^2.0.4",
22+
"prettier": "^2.1.2"
23+
}
2324
}

‎src/index.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ client.on('ready', () => {
2323
});
2424

2525
client.on('message', (msg) => {
26-
const regExAnnounce = /@everyone/g;
26+
const regExAnnounce = /\s@everyone/g;
2727
// regExAnnounce.test(msg.content) // also works in the if condition
2828

2929
console.log(`msg.attachments:`);
@@ -45,14 +45,18 @@ client.on('message', (msg) => {
4545

4646
// msg.channel.send("Sent in announcements channel telegram");
4747

48-
const msgToSend = msg.content.replace(regExAnnounce, '');
48+
const msgToSend = msg.content
49+
.replace(regExAnnounce, '')
50+
.replace(/\*\*/g, '');
4951

5052
bot.sendMessage(channel_id, msgToSend).catch((error) => {
5153
console.log(error.code); // => 'ETELEGRAM'
5254
console.log(error.response.body); // => { ok: false, error_code: 400, description: 'Bad Request: chat not found' }
5355
});
5456
} else {
55-
const msgToSend = msg.content.replace(regExAnnounce, '');
57+
const msgToSend = msg.content
58+
.replace(regExAnnounce, '')
59+
.replace(/\*\*/g, '');
5660

5761
// bot.sendMessage(channel_id, msgToSend).catch((error) => {
5862
// console.log(error.code); // => 'ETELEGRAM'

0 commit comments

Comments
 (0)
Please sign in to comment.