From f20163767723cf87f2c58127d138bee63062bb20 Mon Sep 17 00:00:00 2001 From: vulet Date: Fri, 6 Nov 2020 19:21:01 +0800 Subject: [PATCH] refactor(invidious/nitter): combine commands. fix(config): spelling error --- config.example.js | 4 ++-- main.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config.example.js b/config.example.js index 6a4769e..8214794 100644 --- a/config.example.js +++ b/config.example.js @@ -18,8 +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' ], - check: '(✓)' + domains: [ 'nitter.net', 'www.nitter.net', 'twitter.com', 'www.twitter.com' ], + check: '(✅)' }, invidious: { domain: 'invidious.fdn.fr', diff --git a/main.js b/main.js index 60cc50e..f88a0ec 100644 --- a/main.js +++ b/main.js @@ -72,6 +72,16 @@ let CreateClient = (token, user_id) => { }); command = 'media'; break; + case 'proxy': + try { + const url = new URL(userInput); + command = registrar.config.invidious.domains.includes(url.hostname) + ? 'invidious' + : registrar.config.nitter.domains.includes(url.hostname) + ? 'nitter' + : 'proxy'; + } catch(e) {} + //fallthrough default: args.push(matrixClient, room, userInput, registrar); }