diff --git a/buttons/hardware.js b/buttons/hardware.js index 097cf00..6d76e47 100644 --- a/buttons/hardware.js +++ b/buttons/hardware.js @@ -1,6 +1,6 @@ const figlet = require("figlet"); module.exports = { - title: "Hardware", + title: "🔨 Hardware", /** * @param {{app: import('@slack/bolt').App}} param1 */ diff --git a/buttons/local.js b/buttons/local.js index 227d271..3afd1e4 100644 --- a/buttons/local.js +++ b/buttons/local.js @@ -23,7 +23,7 @@ async function lookupCity(lat, lon) { } module.exports = { - title: "Find Local Hack Clubbers", + title: "🧭 Local Channels", /** * @param {{app: import('@slack/bolt').App}} param1 */ diff --git a/buttons/recommended.js b/buttons/recommended.js new file mode 100644 index 0000000..7628589 --- /dev/null +++ b/buttons/recommended.js @@ -0,0 +1,18 @@ +const { Gorse } = require("gorsejs") +const client = new Gorse({ endpoint: process.env.GORSE_ENDPOINT, secret: process.env.GORSE_SECRET }); +module.exports = { + title: "🎯 Recommended for me", + /** + * @param {{app: import('@slack/bolt').App}} param1 + */ + render: async function ({ app }) { + var recommends = await client.getRecommend({ userId: body.user_id, cursorOptions: { n: 10 } }) + + recommends = recommends.map(rec => `- <#${rec}>`).join("\n") + return `Recyard in *beta*. Based on your recent history in the Slack, here are some channels recommended for you: + +${recommends} + +There are more features in Recyard like finding popular channels and those similar to the one you're in. Check it out in <#C07SREWJ4DA>`; + }, +}; diff --git a/package.json b/package.json index 1548ba0..ec08dc9 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,12 @@ "figlet": "^1.8.0", "geoip-lite2": "^2.1.43", "geolib": "^3.3.4", + "gorsejs": "^0.4.8", "node-cron": "^3.0.3", "pretty-ms": "7.0.1", "prisma": "^5.21.1", "redis": "4.7.0", + "tslib": "^2.8.0", "ws": "^8.18.0" } } diff --git a/yarn.lock b/yarn.lock index 0a257a2..35916dc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -336,7 +336,7 @@ ansi-regex@^6.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.1.0.tgz#95ec409c69619d6cb1b8b34f14b660ef28ebd654" integrity sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA== -ansi-styles@^4.0.0: +ansi-styles@^4.0.0, ansi-styles@^4.1.0: version "4.3.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== @@ -404,6 +404,22 @@ available-typed-arrays@^1.0.7: dependencies: possible-typed-array-names "^1.0.0" +axios-logger@^2.6.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/axios-logger/-/axios-logger-2.8.1.tgz#42bb8a64ab5c51841a10339388ca823145477dba" + integrity sha512-Bbl7XRR/Rkxg2Owv/kRgAZ/0qf8kMPLc08LtiUcGCWV5RmoI7vHr+eee6SUc8jRi2nE5KWShziCVh35C1SBEaw== + dependencies: + chalk "^4.1.0" + dateformat "^3.0.3" + +axios@^0.27.0: + version "0.27.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972" + integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ== + dependencies: + follow-redirects "^1.14.9" + form-data "^4.0.0" + axios@^1.7.4: version "1.7.7" resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.7.tgz#2f554296f9892a72ac8d8e4c5b79c14a91d0a47f" @@ -464,6 +480,14 @@ call-bind@^1.0.2, call-bind@^1.0.5, call-bind@^1.0.6, call-bind@^1.0.7: get-intrinsic "^1.2.4" set-function-length "^1.2.1" +chalk@^4.1.0: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + cluster-key-slot@1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz#88ddaa46906e303b5de30d3153b7d9fe0a0c19ac" @@ -546,6 +570,11 @@ data-view-byte-offset@^1.0.0: es-errors "^1.3.0" is-data-view "^1.0.1" +dateformat@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" + integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== + debug@2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -586,7 +615,7 @@ destroy@1.2.0: resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== -dotenv@^16.4.5: +dotenv@^16.0.0, dotenv@^16.4.5: version "16.4.5" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== @@ -827,7 +856,7 @@ finity@^0.5.4: resolved "https://registry.yarnpkg.com/finity/-/finity-0.5.4.tgz#f2a8a9198e8286467328ec32c8bfcc19a2229c11" integrity sha512-3l+5/1tuw616Lgb0QBimxfdd2TqaDGpfCBpfX6EqtFmqUV3FtQnVEX4Aa62DagYEqnsTIjZcTfbq9msDbXYgyA== -follow-redirects@^1.15.6: +follow-redirects@^1.14.9, follow-redirects@^1.15.6: version "1.15.9" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== @@ -969,11 +998,25 @@ gopd@^1.0.1: dependencies: get-intrinsic "^1.1.3" +gorsejs@^0.4.8: + version "0.4.8" + resolved "https://registry.yarnpkg.com/gorsejs/-/gorsejs-0.4.8.tgz#9e90f89d45e65805a15f1eaa64e693b0ac12894a" + integrity sha512-e4zZ5Onq65iHnN53QaLUMGZAhaFGp95ENswsvrCd0OK1uAi5PxwHs6R9A/rL0wyX0+6M6Um+5h7h9PkHNnPfzQ== + dependencies: + axios "^0.27.0" + axios-logger "^2.6.1" + dotenv "^16.0.0" + has-bigints@^1.0.1, has-bigints@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.2.tgz#0871bd3e3d51626f6ca0966668ba35d5602d6eaa" integrity sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ== +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + has-property-descriptors@^1.0.0, has-property-descriptors@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" @@ -1779,6 +1822,13 @@ strip-ansi@^7.0.1: dependencies: ansi-regex "^6.0.1" +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + toidentifier@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" @@ -1789,6 +1839,11 @@ tr46@~0.0.3: resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== +tslib@^2.8.0: + version "2.8.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.0.tgz#d124c86c3c05a40a91e6fdea4021bd31d377971b" + integrity sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA== + tsscmp@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/tsscmp/-/tsscmp-1.0.6.tgz#85b99583ac3589ec4bfef825b5000aa911d605eb"