feat(nitter): add bluechecks to config. chore(config): move to config.example.js
This commit is contained in:
parent
beb8a4520c
commit
4a4cd304df
4 changed files with 38 additions and 6 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -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
|
||||
|
|
|
@ -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) =>
|
||||
`<a href="${base}/${tweet.handle.replace(/^@/, '')}"><b>${tweet.name}</b></a> ` +
|
||||
(tweet.check ? check : '') +
|
||||
`<a href="${base}${path}"><b>${tweet.date}</b></a> ` +
|
||||
`<span>🗨️ ${tweet.stats.replies}</span> ` +
|
||||
`<span>🔁 ${tweet.stats.retweets}</span> ` +
|
||||
|
@ -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) => {
|
||||
|
|
29
config.example.js
Normal file
29
config.example.js
Normal file
|
@ -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' ]
|
||||
}
|
||||
};
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue