diff options
author | RaindropsSys <contact@minteck.org> | 2023-04-05 15:55:48 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-04-05 15:55:48 +0200 |
commit | 47b8f2299a483024c4a6a8876af825a010954caa (patch) | |
tree | 8c8dc4e99e1e971eeda964a95942340f5a71f546 /includes | |
parent | 164d31aeb4d1e4d4b796fa4c5fbc356ab1a6ad67 (diff) | |
download | pluralconnect-47b8f2299a483024c4a6a8876af825a010954caa.tar.gz pluralconnect-47b8f2299a483024c4a6a8876af825a010954caa.tar.bz2 pluralconnect-47b8f2299a483024c4a6a8876af825a010954caa.zip |
Updated 2 files and added 3 files (automated)
Diffstat (limited to 'includes')
-rw-r--r-- | includes/external/addressbook/discord.js | 2 | ||||
-rw-r--r-- | includes/external/addressbook/mastodon.js | 59 | ||||
-rw-r--r-- | includes/external/addressbook/phone.js | 59 | ||||
-rw-r--r-- | includes/external/addressbook/reddit.js | 63 | ||||
-rw-r--r-- | includes/external/addressbook/twitter.js | 2 |
5 files changed, 185 insertions, 0 deletions
diff --git a/includes/external/addressbook/discord.js b/includes/external/addressbook/discord.js index 04ef2d6..068f6b0 100644 --- a/includes/external/addressbook/discord.js +++ b/includes/external/addressbook/discord.js @@ -23,6 +23,7 @@ function sleep(ms) { avatar: "https://img.icons8.com/fluency-systems-regular/64/ffffff/discord.png", name: user, description: "Discord", + link: null, copy: [ { title: "Copy full username", @@ -62,6 +63,7 @@ function sleep(ms) { avatar: "https://img.icons8.com/fluency-systems-regular/64/ffffff/discord.png", name: user, description: "Discord", + link: null, copy: [] }, null, 2)); } diff --git a/includes/external/addressbook/mastodon.js b/includes/external/addressbook/mastodon.js new file mode 100644 index 0000000..3209b7b --- /dev/null +++ b/includes/external/addressbook/mastodon.js @@ -0,0 +1,59 @@ +const axios = require('axios'); +const apiVersion = "v1" + +function sleep(ms) { + return new Promise((res) => { + setTimeout(res, ms); + }); +} + +(async () => { + let user = process.argv[2]; + + try { + let data = (await axios.get(`https://mastodon.social/api/${apiVersion}/accounts/lookup?acct=${user}`)).data; + + let obj = { + error: null, + avatar: "https://img.icons8.com/external-tal-revivo-regular-tal-revivo/64/ffffff/external-mastodon-is-an-online-self-hosted-social-media-and-social-networking-service-logo-regular-tal-revivo.png", + name: data['display_name'] ?? data['username'], + description: `@${data['acct']}`, + link: data['url'], + copy: [ + { + title: "Copy link to profile", + text: data['url'] + }, + { + title: "Copy local username", + text: data['username'] + }, + { + title: "Copy full username", + text: data['acct'] + }, + data['avatar_static'] ? { + title: "Copy avatar URL", + text: data['avatar_static'] + } : null + ] + } + + if (data['avatar_static']) { + obj.avatar = data['avatar_static']; + } + + console.log(JSON.stringify(obj, null, 2)); + } catch (e) { + console.log(JSON.stringify({ + error: e, + avatar: "https://img.icons8.com/external-tal-revivo-regular-tal-revivo/64/ffffff/external-mastodon-is-an-online-self-hosted-social-media-and-social-networking-service-logo-regular-tal-revivo.png", + name: user, + description: "Mastodon", + link: null, + copy: [] + }, null, 2)); + } + + +})();
\ No newline at end of file diff --git a/includes/external/addressbook/phone.js b/includes/external/addressbook/phone.js new file mode 100644 index 0000000..9f9236b --- /dev/null +++ b/includes/external/addressbook/phone.js @@ -0,0 +1,59 @@ +const axios = require('axios'); +const apiVersion = "v2"; +const app = require('../../app.json'); + +function sleep(ms) { + return new Promise((res) => { + setTimeout(res, ms); + }); +} + +(async () => { + let user = process.argv[2]; + + try { + let data = (await axios.get(`https://lookups.twilio.com/${apiVersion}/PhoneNumbers/${user}`, { + auth: { + username: app.twilio.sid, + password: app.twilio.secret + } + })).data; + + if (!data['valid']) throw new Error(JSON.stringify(data['validation_errors'])); + + let obj = { + error: null, + avatar: `https://flagcdn.com/w160/${data['country_code'].toLowerCase()}.png`, + name: data['national_format'], + description: data['phone_number'], + link: `tel:${data['phone_number']}`, + copy: [ + { + title: "Copy national phone number", + text: data['national_format'] + }, + { + title: "Copy international phone number", + text: data['phone_number'] + }, + { + title: "Copy tel: link", + text: `tel:${data['phone_number']}` + } + ] + } + + console.log(JSON.stringify(obj, null, 2)); + } catch (e) { + console.log(JSON.stringify({ + error: e, + avatar: "https://img.icons8.com/fluency-systems-regular/64/ffffff/phone.png", + name: user, + description: "Phone", + link: null, + copy: [] + }, null, 2)); + } + + +})();
\ No newline at end of file diff --git a/includes/external/addressbook/reddit.js b/includes/external/addressbook/reddit.js new file mode 100644 index 0000000..3e5dd15 --- /dev/null +++ b/includes/external/addressbook/reddit.js @@ -0,0 +1,63 @@ +const axios = require('axios'); + +function sleep(ms) { + return new Promise((res) => { + setTimeout(res, ms); + }); +} + +(async () => { + let user = process.argv[2]; + + if (user.startsWith("u/")) user = user.substring(2); + if (user.startsWith("user/")) user = user.substring(5); + + try { + let data = (await axios.get(`https://www.reddit.com/user/${user}/about.json`)).data.data; + + if (data['icon_img']) data['icon_img'] = data['icon_img'].replaceAll("&", "&"); + + let obj = { + error: null, + avatar: "https://img.icons8.com/fluency-systems-regular/64/ffffff/reddit.png", + name: data['subreddit']['title'] ?? data['name'], + description: data['subreddit']['display_name_prefixed'], + link: `https://www.reddit.com${data['subreddit']['url']}`, + copy: [ + { + title: "Copy link to profile", + text: `https://www.reddit.com${data['subreddit']['url']}` + }, + { + title: "Copy username", + text: data['username'] + }, + { + title: "Copy ID", + text: data['id'] + }, + data['icon_img'] ? { + title: "Copy avatar URL", + text: data['icon_img'] + } : null + ] + } + + if (data['icon_img']) { + obj.avatar = data['icon_img']; + } + + console.log(JSON.stringify(obj, null, 2)); + } catch (e) { + console.log(JSON.stringify({ + error: e, + avatar: "https://img.icons8.com/fluency-systems-regular/64/ffffff/reddit.png", + name: user, + description: "Reddit", + link: null, + copy: [] + }, null, 2)); + } + + +})();
\ No newline at end of file diff --git a/includes/external/addressbook/twitter.js b/includes/external/addressbook/twitter.js index b22fca3..d8834ca 100644 --- a/includes/external/addressbook/twitter.js +++ b/includes/external/addressbook/twitter.js @@ -23,6 +23,7 @@ function sleep(ms) { avatar: "https://img.icons8.com/fluency-systems-regular/64/ffffff/twitter.png", name: data['name'], description: `@${data['username']}`, + link: `https://twitter.com/${data['username']}`, copy: [ { title: "Copy link to profile", @@ -54,6 +55,7 @@ function sleep(ms) { avatar: "https://img.icons8.com/fluency-systems-regular/64/ffffff/twitter.png", name: user, description: "Twitter", + link: null, copy: [] }, null, 2)); } |