From 4a4cd304dfc62036ea13d6bb8b91dd28385f67e3 Mon Sep 17 00:00:00 2001 From: vulet Date: Mon, 2 Nov 2020 23:22:27 +0800 Subject: [PATCH] feat(nitter): add bluechecks to config. chore(config): move to config.example.js --- .gitignore | 6 +++--- commands/nitter.js | 6 ++++-- config.example.js | 29 +++++++++++++++++++++++++++++ config.js | 3 ++- 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 config.example.js diff --git a/.gitignore b/.gitignore index 0cc8fb8..5d7a8f7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,11 +9,11 @@ yarn-debug.log* yarn-error.log* # Ignore config -/config.js +config.js # Ignore JSON -/timeline.json -/notification.json +timeline.json +notification.json # Runtime data pids diff --git a/commands/nitter.js b/commands/nitter.js index 2ba95dc..f07b6e7 100644 --- a/commands/nitter.js +++ b/commands/nitter.js @@ -20,6 +20,7 @@ const nitter = async (instance, url) => { text: tweet.querySelector('.tweet-body > .tweet-content').innerHTML, date: tweet.querySelector('.tweet-body > .tweet-published').textContent, name: tweet.querySelector('.tweet-body > div .fullname').textContent, + check: !!tweet.querySelector('.tweet-body > div .fullname .icon-ok'), handle: tweet.querySelector('.tweet-body > div .username').textContent, hasAttachments: !!tweet.querySelector('.tweet-body > .attachments'), quote: quote ? { @@ -38,8 +39,9 @@ const nitter = async (instance, url) => { }; }; -const card = (tweet, base, path) => +const card = (tweet, base, check, path) => `${tweet.name} ` + +(tweet.check ? check : '') + `${tweet.date} ` + `๐Ÿ—จ๏ธ ${tweet.stats.replies} ` + `๐Ÿ” ${tweet.stats.retweets} ` + @@ -57,7 +59,7 @@ const run = async (matrixClient, { roomId }, userInput, registrar) => { timeout: 10 * 1000 }); const tweet = await nitter(instance, userInput); - return await matrixClient.sendHtmlNotice(roomId, '', card(tweet, `https://${config.domain}`, userInput)); + return await matrixClient.sendHtmlNotice(roomId, '', card(tweet, `https://${config.domain}`, config.check, userInput)); } exports.runQuery = async (client, room, userInput, registrar) => { diff --git a/config.example.js b/config.example.js new file mode 100644 index 0000000..6a4769e --- /dev/null +++ b/config.example.js @@ -0,0 +1,29 @@ +module.exports = { + matrix: { + domain: 'https://your_homeserver.com', + user: 'your_user', + password: 'your_password', + domains: [ 'your_homeserver.com' ], + mimetypes: [ 'image/png', 'image/jpeg', 'video/webm', 'image/jpg', 'video/mp4', 'audio/mp3' ], + subject: '' + }, + fediverse: { + domain: 'https://your_federation.com', + token: 'your_federation_token', + }, + archive: { + domain: 'archive.is', + userAgent: 'Mozilla/4.0 (compatible; Beep Boop)' + }, + nitter: { + domain: 'nitter.net', + userAgent: 'Mozilla/4.0 (compatible; Beep Boop)', + domains: [ 'nitter.net', 'www.nitter.net', 'twitter.com', 'wwww.twitter.com' ], + check: '(รขล“โ€œ)' + }, + invidious: { + domain: 'invidious.fdn.fr', + userAgent: 'Mozilla/4.0 (compatible; Beep Boop)', + domains: [ 'invidious.snopyta.org', 'invidious.xyz', 'youtube.com', 'www.youtube.com' ] + } +}; diff --git a/config.js b/config.js index b1ef675..6a4769e 100644 --- a/config.js +++ b/config.js @@ -18,7 +18,8 @@ module.exports = { nitter: { domain: 'nitter.net', userAgent: 'Mozilla/4.0 (compatible; Beep Boop)', - domains: [ 'nitter.net', 'www.nitter.net', 'twitter.com', 'wwww.twitter.com' ] + domains: [ 'nitter.net', 'www.nitter.net', 'twitter.com', 'wwww.twitter.com' ], + check: '(รขล“โ€œ)' }, invidious: { domain: 'invidious.fdn.fr',