this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

repl repl repl

alice 493ea8b0 3c9a5035

+115 -30
+71 -29
index.ts
··· 1 + /* eslint-disable @typescript-eslint/no-explicit-any */ 1 2 /// <reference types="./custom-typings.d.ts" /> 2 3 import bsky from '@atproto/api'; 3 4 const { BskyAgent } = bsky; 4 5 import * as dotenv from 'dotenv'; 5 6 import process from 'node:process'; 6 - // import { search } from 'fast-fuzzy'; 7 - import Fuse from 'fuse.js'; 7 + import { search } from 'fast-fuzzy'; 8 + // import Fuse from 'fuse.js'; 8 9 dotenv.config(); 9 10 10 11 if (typeof process.argv[2] === 'undefined') { ··· 56 57 ...res.feed.map((e) => ({ 57 58 text: (e.post.record as any).text, 58 59 uri: e.post.uri.replace('app.bsky.feed.', '').replace('at://', 'https://staging.bsky.app/profile/'), 60 + likeCount: e.post.likeCount, 61 + did: e.post.author.did, 62 + isOwn: e.post.author.did === agent.session!.did, 63 + repostCount: e.post.repostCount, 64 + isRepost: e.post.repostCount === 0 ? false : true, 59 65 })), 60 66 ); 61 67 } 62 68 }); 63 69 64 - // const results = search(process.argv[2], posts, { keySelector: (o) => (o as any).text, returnMatchData: true }); 70 + const pattern = process.argv[2]; 65 71 66 - const options = { 67 - // isCaseSensitive: false, 68 - includeScore: true, 69 - // shouldSort: true, 70 - includeMatches: true, 71 - findAllMatches: true, 72 - // minMatchCharLength: 1, 73 - // location: 0, 74 - threshold: 0.3, 75 - // distance: 100, 76 - // useExtendedSearch: false, 77 - // ignoreLocation: false, 78 - // ignoreFieldNorm: false, 79 - // fieldNormWeight: 1, 80 - keys: ['text'], 81 - }; 72 + if (pattern === 'topLikes') { 73 + posts.sort((a: any, b: any) => { 74 + return b.likeCount - a.likeCount; 75 + }); 76 + const ownBestPosts = posts.filter((post: any) => { 77 + return post.isOwn === true && post.isRepost === false; 78 + }); 79 + console.log(ownBestPosts.slice(0, 20)); 80 + process.exit(0); 81 + } 82 82 83 - const fuse = new Fuse(posts, options); 83 + if (pattern === 'topRTs') { 84 + posts.sort((a: any, b: any) => { 85 + return b.repostCount - a.repostCount; 86 + }); 87 + const ownBestPosts = posts.filter((post: any) => { 88 + return post.isOwn === true; 89 + }); 90 + console.log(ownBestPosts.slice(0, 20)); 91 + process.exit(0); 92 + } 93 + 94 + if (pattern === 'noText') { 95 + posts.sort((a: any, b: any) => { 96 + return b.likeCount - a.likeCount; 97 + }); 98 + const ownBestImages = posts.filter((post: any) => { 99 + return post.text === '' && post.isOwn === true; 100 + }); 101 + console.log(ownBestImages.slice(0, 20)); 102 + process.exit(0); 103 + } 104 + 105 + // const options = { 106 + // // isCaseSensitive: false, 107 + // includeScore: true, 108 + // // shouldSort: true, 109 + // includeMatches: true, 110 + // findAllMatches: true, 111 + // // minMatchCharLength: 1, 112 + // // location: 0, 113 + // threshold: 0.3, 114 + // // distance: 100, 115 + // // useExtendedSearch: false, 116 + // // ignoreLocation: false, 117 + // // ignoreFieldNorm: false, 118 + // // fieldNormWeight: 1, 119 + // keys: ['text'], 120 + // }; 121 + 122 + // const fuse = new Fuse(posts, options); 84 123 85 124 // Change the pattern 86 - const pattern = process.argv[2]; 125 + 126 + // console.log( 127 + // fuse.search(pattern).map((e) => { 128 + // return { 129 + // text: e.item.text, 130 + // uri: e.item.uri, 131 + // likeCount: e.item.likeCount, 132 + // }; 133 + // }), 134 + // ); 87 135 88 - console.log( 89 - fuse.search(pattern).map((e) => { 90 - return { 91 - text: e.item.text, 92 - uri: e.item.uri, 93 - }; 94 - }), 95 - ); 136 + const results = search(process.argv[2], posts, { keySelector: (o) => (o as any).text, returnMatchData: true }); 137 + console.log(results);
+42
package-lock.json
··· 11 11 "dependencies": { 12 12 "@atproto/api": "^0.2.5", 13 13 "dotenv": "^16.0.3", 14 + "fast-fuzzy": "^1.12.0", 14 15 "fuse.js": "^6.6.2" 15 16 }, 16 17 "devDependencies": { ··· 822 823 "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", 823 824 "dev": true 824 825 }, 826 + "node_modules/fast-fuzzy": { 827 + "version": "1.12.0", 828 + "resolved": "https://registry.npmjs.org/fast-fuzzy/-/fast-fuzzy-1.12.0.tgz", 829 + "integrity": "sha512-sXxGgHS+ubYpsdLnvOvJ9w5GYYZrtL9mkosG3nfuD446ahvoWEsSKBP7ieGmWIKVLnaxRDgUJkZMdxRgA2Ni+Q==", 830 + "dependencies": { 831 + "graphemesplit": "^2.4.1" 832 + } 833 + }, 825 834 "node_modules/fast-glob": { 826 835 "version": "3.2.12", 827 836 "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", ··· 1017 1026 "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", 1018 1027 "dev": true 1019 1028 }, 1029 + "node_modules/graphemesplit": { 1030 + "version": "2.4.4", 1031 + "resolved": "https://registry.npmjs.org/graphemesplit/-/graphemesplit-2.4.4.tgz", 1032 + "integrity": "sha512-lKrpp1mk1NH26USxC/Asw4OHbhSQf5XfrWZ+CDv/dFVvd1j17kFgMotdJvOesmHkbFX9P9sBfpH8VogxOWLg8w==", 1033 + "dependencies": { 1034 + "js-base64": "^3.6.0", 1035 + "unicode-trie": "^2.0.0" 1036 + } 1037 + }, 1020 1038 "node_modules/has-flag": { 1021 1039 "version": "4.0.0", 1022 1040 "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", ··· 1126 1144 "resolved": "https://registry.npmjs.org/iso-datestring-validator/-/iso-datestring-validator-2.2.2.tgz", 1127 1145 "integrity": "sha512-yLEMkBbLZTlVQqOnQ4FiMujR6T4DEcCb1xizmvXS+OxuhwcbtynoosRzdMA69zZCShCNAbi+gJ71FxZBBXx1SA==" 1128 1146 }, 1147 + "node_modules/js-base64": { 1148 + "version": "3.7.5", 1149 + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.5.tgz", 1150 + "integrity": "sha512-3MEt5DTINKqfScXKfJFrRbxkrnk2AxPWGBL/ycjz4dK8iqiSJ06UxD8jh8xuh6p10TX4t2+7FsBYVxxQbMg+qA==" 1151 + }, 1129 1152 "node_modules/js-sdsl": { 1130 1153 "version": "4.4.0", 1131 1154 "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", ··· 1318 1341 "funding": { 1319 1342 "url": "https://github.com/sponsors/sindresorhus" 1320 1343 } 1344 + }, 1345 + "node_modules/pako": { 1346 + "version": "0.2.9", 1347 + "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", 1348 + "integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==" 1321 1349 }, 1322 1350 "node_modules/parent-module": { 1323 1351 "version": "1.0.1", ··· 1585 1613 "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", 1586 1614 "dev": true 1587 1615 }, 1616 + "node_modules/tiny-inflate": { 1617 + "version": "1.0.3", 1618 + "resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.3.tgz", 1619 + "integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==" 1620 + }, 1588 1621 "node_modules/tlds": { 1589 1622 "version": "1.238.0", 1590 1623 "resolved": "https://registry.npmjs.org/tlds/-/tlds-1.238.0.tgz", ··· 1683 1716 "integrity": "sha512-HRCx0q6O9Bfbp+HHSfQQKD7wU70+lydKVt4EghkdOvlK/NlrF90z+eXV34mUd48rNvVJXwkrMSPpCATkct8fJA==", 1684 1717 "dependencies": { 1685 1718 "multiformats": "^9.4.2" 1719 + } 1720 + }, 1721 + "node_modules/unicode-trie": { 1722 + "version": "2.0.0", 1723 + "resolved": "https://registry.npmjs.org/unicode-trie/-/unicode-trie-2.0.0.tgz", 1724 + "integrity": "sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ==", 1725 + "dependencies": { 1726 + "pako": "^0.2.5", 1727 + "tiny-inflate": "^1.0.0" 1686 1728 } 1687 1729 }, 1688 1730 "node_modules/uri-js": {
+1
package.json
··· 13 13 "dependencies": { 14 14 "@atproto/api": "^0.2.5", 15 15 "dotenv": "^16.0.3", 16 + "fast-fuzzy": "^1.12.0", 16 17 "fuse.js": "^6.6.2" 17 18 }, 18 19 "devDependencies": {
+1 -1
tsconfig.json
··· 83 83 84 84 /* Type Checking */ 85 85 "strict": true /* Enable all strict type-checking options. */, 86 - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 86 + "noImplicitAny": false /* Enable error reporting for expressions and declarations with an implied 'any' type. */, 87 87 // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 88 // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 89 // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */