├── .env-typings.d.ts ├── .env.example ├── .github └── workflows │ └── ban.yml ├── .gitignore ├── .vscode └── settings.json ├── .xata ├── migrations │ ├── .ledger │ ├── mig_cfi2p615ciif77dddk6g_54226118.json │ ├── mig_cfi2sgt1glmqsj88bu20_459aebb1.json │ ├── mig_cfi2sot1glmqsj88bu30_65800213.json │ ├── mig_cfi51uvjl0nis1fg0dl0_09f50d1b.json │ ├── mig_cfi5aj7jl0nis1fg0e10_f3eddced.json │ ├── mig_cfi5br4a71mbp97brl80_fd433875.json │ ├── mig_cfi5c07jl0nis1fg0e1g_91f0a768.json │ ├── mig_cfi5c8njl0nis1fg0e20_d5ea14ed.json │ ├── mig_cfi5iet1glmqsj8a6flg_1a2e2e36.json │ ├── mig_cfina8fjl0nis1fn9hs0_896867a7.json │ ├── mig_cfirk8vjl0nis1fnbgmg_795eaf79.json │ ├── mig_cfirkenjl0nis1fnbgn0_a82c4469.json │ ├── mig_cfrrdhukrlkpj2ia7n4g_e2ccbf7e.json │ ├── mig_cfrrdm6krlkpj2ia7n50_ffa2aca5.json │ └── mig_cg58uvfod75b3er6f9sg_8d8f1e41.json └── version │ └── compatibility.json ├── .xatarc ├── FUNDING.json ├── LICENSE ├── README.md ├── actions ├── ask-to-expand.ts ├── delete-message.ts ├── expand-link.ts ├── get-member-count.ts ├── missing-permissions.ts └── show-bot-activity.ts ├── callbacks ├── destruct-expanded-link.ts ├── index.ts ├── manual-expand.ts ├── settings-autoexpand.ts ├── settings-changelog.ts ├── settings-lock.ts ├── settings-permissions.ts └── undo.ts ├── commands ├── autoexpand.ts ├── changelog.ts ├── index.ts ├── lock.ts ├── permissions.ts ├── source.ts └── start.ts ├── helpers ├── admin.ts ├── analytics.ts ├── api.ts ├── banned.ts ├── button-states.ts ├── cache.ts ├── hacker-news-metadata.ts ├── instagram-share.ts ├── link-regex.ts ├── notifier.ts ├── og-metadata.ts ├── platforms.ts ├── templates.ts └── xata.ts ├── index.ts ├── link-listener-channel.ts ├── link-listener.ts ├── middleware └── error-handler.ts ├── package.json └── yarn.lock /.env-typings.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace NodeJS { 2 | interface ProcessEnv { 3 | ADMIN_TELEGRAM_ID: string; 4 | ANALYTICS_ENDPOINT?: string; 5 | ANALYTICS_KEY?: string; 6 | DEV?: boolean; 7 | TELEGRAM_BOT_TOKEN: string; 8 | XATA_API_KEY: string; 9 | XATA_BRANCH: string; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | ## Telegram 2 | TELEGRAM_BOT_TOKEN=42069:ABCDEF42069 3 | ADMIN_TELEGRAM_ID=42069 4 | DEV=true 5 | 6 | ## Analytics 7 | ANALYTICS_ENDPOINT=https://analytics.example.com 8 | ANALYTICS_KEY=42069 9 | 10 | ## Xata backend 11 | XATA_API_KEY=42069 12 | XATA_BRANCH=whatever -------------------------------------------------------------------------------- /.github/workflows/ban.yml: -------------------------------------------------------------------------------- 1 | name: Append Chat ID to Ban List 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | chatId: 7 | description: "Chat ID to ban" 8 | required: true 9 | 10 | jobs: 11 | update-array: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Check out repository 16 | uses: actions/checkout@v2 17 | 18 | - name: Append to array 19 | run: | 20 | echo "Appending chat ID to the ban list..." 21 | sed -i "/];/i \ ${{ github.event.inputs.chatId }}," helpers/banned.ts 22 | cat helpers/banned.ts 23 | 24 | - name: Commit and push if changed 25 | run: | 26 | git config --global user.email "hi@wojtek.im" 27 | git config --global user.name "pugson" 28 | git add helpers/banned.ts 29 | git commit -m "Appending Chat ID ${{ github.event.inputs.chatId }} to Ban List" || exit 0 30 | git push 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "dotenv.enableAutocloaking": false 3 | } 4 | -------------------------------------------------------------------------------- /.xata/migrations/.ledger: -------------------------------------------------------------------------------- 1 | mig_cfi2p615ciif77dddk6g_54226118 2 | mig_cfi2sgt1glmqsj88bu20_459aebb1 3 | mig_cfi2sot1glmqsj88bu30_65800213 4 | mig_cfi51uvjl0nis1fg0dl0_09f50d1b 5 | mig_cfi5aj7jl0nis1fg0e10_f3eddced 6 | mig_cfi5br4a71mbp97brl80_fd433875 7 | mig_cfi5c07jl0nis1fg0e1g_91f0a768 8 | mig_cfi5c8njl0nis1fg0e20_d5ea14ed 9 | mig_cfi5iet1glmqsj8a6flg_1a2e2e36 10 | mig_cfina8fjl0nis1fn9hs0_896867a7 11 | mig_cfirk8vjl0nis1fnbgmg_795eaf79 12 | mig_cfirkenjl0nis1fnbgn0_a82c4469 13 | mig_cfrrdhukrlkpj2ia7n4g_e2ccbf7e 14 | mig_cfrrdm6krlkpj2ia7n50_ffa2aca5 15 | mig_cg58uvfod75b3er6f9sg_8d8f1e41 16 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfi2p615ciif77dddk6g_54226118.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfi2p615ciif77dddk6g", 3 | "checksum": "1:542261182c6169d8a4675dfeacf61a919b2798a2c12b7f53c9879b019f656145", 4 | "operations": [] 5 | } 6 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfi2sgt1glmqsj88bu20_459aebb1.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfi2sgt1glmqsj88bu20", 3 | "parentID": "mig_cfi2p615ciif77dddk6g", 4 | "checksum": "1:459aebb1304a0431d3e90362c1eec377cc92e15949b14d1588e66d5a3674b049", 5 | "operations": [ 6 | { 7 | "addTable": { 8 | "table": "chats" 9 | } 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfi2sot1glmqsj88bu30_65800213.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfi2sot1glmqsj88bu30", 3 | "parentID": "mig_cfi2sgt1glmqsj88bu20", 4 | "checksum": "1:65800213d1717920d3a656e836b74abef03d307f60134359a7bdbeaf480b67a0", 5 | "operations": [ 6 | { 7 | "addColumn": { 8 | "column": { 9 | "name": "chat_id", 10 | "type": "string", 11 | "unique": true 12 | }, 13 | "table": "chats" 14 | } 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfi51uvjl0nis1fg0dl0_09f50d1b.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfi51uvjl0nis1fg0dl0", 3 | "parentID": "mig_cfi2sot1glmqsj88bu30", 4 | "checksum": "1:09f50d1b2cd5b4e333e4146f2e2da7d988a64d0e01f74978d7ed7d6f9ed8d9b3", 5 | "operations": [ 6 | { 7 | "addColumn": { 8 | "column": { 9 | "name": "autoexpand", 10 | "type": "bool", 11 | "notNull": true, 12 | "defaultValue": "false" 13 | }, 14 | "table": "chats" 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfi5aj7jl0nis1fg0e10_f3eddced.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfi5aj7jl0nis1fg0e10", 3 | "parentID": "mig_cfi51uvjl0nis1fg0dl0", 4 | "checksum": "1:f3eddcedb6c8b92b89af7111278a2d72233884b474817044819de6a0e61cacc7", 5 | "operations": [ 6 | { 7 | "addColumn": { 8 | "column": { 9 | "name": "release_notes_notification", 10 | "type": "bool", 11 | "notNull": true, 12 | "defaultValue": "false" 13 | }, 14 | "table": "chats" 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfi5br4a71mbp97brl80_fd433875.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfi5br4a71mbp97brl80", 3 | "parentID": "mig_cfi5aj7jl0nis1fg0e10", 4 | "checksum": "1:fd433875f67c307529c7d8c2af38aa34250cc6ffd51df542626e314665d6fd00", 5 | "operations": [ 6 | { 7 | "addTable": { 8 | "table": "events" 9 | } 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfi5c07jl0nis1fg0e1g_91f0a768.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfi5c07jl0nis1fg0e1g", 3 | "parentID": "mig_cfi5br4a71mbp97brl80", 4 | "checksum": "1:91f0a76850efc140ca99a9ab31a16c7fec36098fba3375a287aa63aa1adabc13", 5 | "operations": [ 6 | { 7 | "addColumn": { 8 | "column": { 9 | "name": "name", 10 | "type": "string", 11 | "unique": true 12 | }, 13 | "table": "events" 14 | } 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfi5c8njl0nis1fg0e20_d5ea14ed.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfi5c8njl0nis1fg0e20", 3 | "parentID": "mig_cfi5c07jl0nis1fg0e1g", 4 | "checksum": "1:d5ea14edb193657f2794cd6d670440537499ff916731a2565a4f6f7f7fd61826", 5 | "operations": [ 6 | { 7 | "addColumn": { 8 | "column": { 9 | "name": "timestamp", 10 | "type": "datetime" 11 | }, 12 | "table": "events" 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfi5iet1glmqsj8a6flg_1a2e2e36.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfi5iet1glmqsj8a6flg", 3 | "parentID": "mig_cfi5c8njl0nis1fg0e20", 4 | "checksum": "1:1a2e2e3636b85a54f6f2c7a36f4cf476691d104db6f00dcb269989b220d1969e", 5 | "operations": [ 6 | { 7 | "addColumn": { 8 | "column": { 9 | "name": "note", 10 | "type": "string" 11 | }, 12 | "table": "events" 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfina8fjl0nis1fn9hs0_896867a7.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfina8fjl0nis1fn9hs0", 3 | "parentID": "mig_cfi5iet1glmqsj8a6flg", 4 | "checksum": "1:896867a7027842c5ca7c5545a97631b039de1777b138495a922430ddbc1071b6", 5 | "operations": [ 6 | { 7 | "addColumn": { 8 | "column": { 9 | "name": "chat_size", 10 | "type": "int" 11 | }, 12 | "table": "chats" 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfirk8vjl0nis1fnbgmg_795eaf79.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfirk8vjl0nis1fnbgmg", 3 | "parentID": "mig_cfina8fjl0nis1fn9hs0", 4 | "checksum": "1:795eaf79a5fb78437d0d163b8033078140b4bcbe977291bb22b8a6a7bee62a57", 5 | "operations": [ 6 | { 7 | "removeColumn": { 8 | "column": "name", 9 | "table": "events" 10 | } 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfirkenjl0nis1fnbgn0_a82c4469.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfirkenjl0nis1fnbgn0", 3 | "parentID": "mig_cfirk8vjl0nis1fnbgmg", 4 | "checksum": "1:a82c4469d27d0d316aa8520b616288b84e32ea9a17c28f11105a24695875f896", 5 | "operations": [ 6 | { 7 | "addColumn": { 8 | "column": { 9 | "name": "name", 10 | "type": "string", 11 | "notNull": true, 12 | "defaultValue": "" 13 | }, 14 | "table": "events" 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfrrdhukrlkpj2ia7n4g_e2ccbf7e.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfrrdhukrlkpj2ia7n4g", 3 | "parentID": "mig_cfirkenjl0nis1fnbgn0", 4 | "checksum": "1:e2ccbf7e2b102bd0f55ad1b28c7e01622962dfdfc6614bea395aa4ef684434ec", 5 | "operations": [ 6 | { 7 | "removeColumn": { 8 | "column": "release_notes_notification", 9 | "table": "chats" 10 | } 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cfrrdm6krlkpj2ia7n50_ffa2aca5.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cfrrdm6krlkpj2ia7n50", 3 | "parentID": "mig_cfrrdhukrlkpj2ia7n4g", 4 | "checksum": "1:ffa2aca56928952b09718de2372bf5fc90b05373b85ef013b0376897907a81ba", 5 | "operations": [ 6 | { 7 | "addColumn": { 8 | "column": { 9 | "name": "changelog", 10 | "type": "bool", 11 | "notNull": true, 12 | "defaultValue": "true" 13 | }, 14 | "table": "chats" 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.xata/migrations/mig_cg58uvfod75b3er6f9sg_8d8f1e41.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "mig_cg58uvfod75b3er6f9sg", 3 | "parentID": "mig_cfrrdm6krlkpj2ia7n50", 4 | "checksum": "1:8d8f1e418563dcc3b59b06de55e6cc902c6a1b75116767bdb8ce3395f42e1ecf", 5 | "operations": [ 6 | { 7 | "addColumn": { 8 | "column": { 9 | "name": "ignore_permissions_warning", 10 | "type": "bool", 11 | "notNull": true, 12 | "defaultValue": "false" 13 | }, 14 | "table": "chats" 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.xata/version/compatibility.json: -------------------------------------------------------------------------------- 1 | {"@xata.io/cli":{"latest":"0.16.12","compatibility":[{"range":">=0.0.0"}]},"@xata.io/client":{"latest":"0.30.1","compatibility":[{"range":">=0.0.0"}]}} -------------------------------------------------------------------------------- /.xatarc: -------------------------------------------------------------------------------- 1 | { 2 | "databaseURL": "https://pugson-3k9p63.us-east-1.xata.sh/db/linkbot", 3 | "codegen": { 4 | "output": "helpers/xata.ts" 5 | } 6 | } -------------------------------------------------------------------------------- /FUNDING.json: -------------------------------------------------------------------------------- 1 | { 2 | "drips": { 3 | "ethereum": { 4 | "ownedBy": "0x96a77560146501eAEB5e6D5B7d8DD1eD23DEfa23" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Link Expander — Telegram Bot for expanding Twitter, Instagram, TikTok, Spotify, Reddit, Bluesky, Hacker News, and Dribbble links. 2 | 3 | ![banner-4 1@1x](https://user-images.githubusercontent.com/6843656/214646426-db3bf292-afc4-4729-8e16-64ed687127aa.png) 4 | 5 | Some Twitter links stopped expanding inside Telegram which made it extremely annoying when you wanted to send a banger tweet to your homies in the group chat. This bot replies with an alternative [fxtwitter.com](https://fxtwitter.com) URL which has a working embed for multiple photos and even includes inline video. 6 | 7 | ## Supported platforms 8 | 9 | - _Twitter / X_ using [fxtwitter.com](https://fxtwitter.com) 10 | - _Instagram_ using [ddinstagram.com](https://ddinstagram.com) (doesn’t work with Stories or Highlights yet.) 11 | - _TikTok_ using [tfxktok.com](https://tfxktok.com) 12 | - _Bluesky_ using [fxbsky.app](https://fxbsky.app) 13 | - _Reddit_ using [rxddit.com](https://rxddit.com) 14 | - _Hacker News_ using a custom API 15 | - _Dribbble_ using [dribbbletv.com](https://dribbbletv.com) 16 | - _Posts.cv_ using [postscv.com](https://postscv.com) 17 | - _Spotify_ using a custom API 18 | 19 | ## ✨🆕✨ Support for Spotify links! 20 | 21 | When you send a Spotify link, the bot will reply with a photo of the artwork and info about the track / album / playlist / artist / podcast / show. 22 | It will also send a sample audio clip in another message. 23 | 24 | ![Spotify preview](https://wsrv.nl/?url=https://github.com/user-attachments/assets/a63af8c5-c968-4b44-b5ba-ed64f1336462&w=300) 25 | 26 | ## Hacker News links! (not in channels yet) 27 | 28 | You can now expand Hacker News links. It will reply with the original YCombinator URL, the link shared in a HN post, and the title of the submission. 29 | 30 | CleanShot 2024-01-09 at 09 15 18 PM@2x 31 | 32 | ## ✨🆕✨ Bot now works in Telegram Channels! 33 | 34 | When you add this bot to your channel it will automatically edit any message that includes a supported platform and replace the link in that message with one of the working embeds for each platform. Your channel subscribers will finally be able to watch inline videos and photos without leaving Telegram. 35 | 36 | > [!NOTE] 37 | > 38 | > There is no message logging or personal tracking — your chats stay private. 39 | > 40 | > The exact source code that’s published on GitHub is automatically [deployed to Railway](https://railway.app?referralCode=dev) and logs will never include any user/chat/personal info or content. You can audit the code to see for yourself. 41 | 42 | ## Demo 43 | 44 | https://user-images.githubusercontent.com/6843656/182036672-5b566200-cba4-462d-ba5c-4c043e032b06.mp4 45 | 46 | ## How to use this bot? 47 | 48 | ### Channels 49 | 50 | 1. Find it on Telegram as `@TwitterLinkExpanderBot` or click here: https://t.me/twitterlinkexpanderbot?start=start 51 | 2. Add it to your channel as admin with the `Edit messages of others` permission. 52 | 3. Send a message that includes a tweet, TikTok, or Instagram URL. 53 | 54 | ### Groups or DMs 55 | 56 | 1. Find it on Telegram as `@TwitterLinkExpanderBot` or click here: https://t.me/twitterlinkexpanderbot?start=start 57 | 2. Add it to your group chat. 58 | 3. Send a message that includes a tweet, TikTok, or Instagram URL. 59 | 4. Click "Yes" or "No" when the bot replies to your message. 60 | 5. Configure automatically expanding links in your group chat by sending `/autoexpand` and changing your settings. 61 | 62 | image 63 | 64 | ## Do you read all messages inside the chat? 65 | 66 | 🙅‍♂️ **No, I will never do that.** 🙅‍♂️ 67 | 68 | While it is technically possible through the Bot API, I simply do not have the time or desire to snoop on your shit. The only thing I will keep track of is counting anonymous events when buttons are clicked, bot commands are used, a tweet has multiple images (etc.) to monitor stats to see if people are finding this bot useful. 69 | 70 | image 71 | 72 | # Thanks 73 | 74 | This bot wouldn't be possible without the following people and projects. Huge thanks to: 75 | 76 | - [@dylanpdx](https://github.com/dylanpdx) for creating [BetterTwitFix](https://github.com/dylanpdx/BetterTwitFix) / [vxtwitter.com](https://vxtwitter.com) 77 | - [@Wikidepia](https://github.com/Wikidepia) for creating [InstaFix](https://github.com/Wikidepia/InstaFix) / [ddinstagram.com](https://ddinstagram.com) 78 | - [fxtwitter.com](https://fxtwitter.com) / [FixTweet](https://github.com/FixTweet/FixTweet) 79 | - [@allanf181](https://github.com/allanf181) for creating [tfxktok.com](https://tfxktok.com) 80 | - [@fxbsky.app](https://bsky.app/profile/fxbsky.app) for creating [fxbsky.app](https://fxbsky.app) 81 | - [@MinnDevelopment](https://github.com/MinnDevelopment/fxreddit) for creating [rxddit.com](https://rxddit.com) 82 | -------------------------------------------------------------------------------- /actions/ask-to-expand.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { 3 | isInstagram, 4 | isTikTok, 5 | isPosts, 6 | isHackerNews, 7 | isDribbble, 8 | isBluesky, 9 | isReddit, 10 | isSpotify, 11 | } from "../helpers/platforms"; 12 | import { isBanned } from "../helpers/banned"; 13 | import { askToExpandTemplate } from "../helpers/templates"; 14 | 15 | /** 16 | * Sends a reply in chat asking the user if they want to expand 17 | * links in the message with 2 buttons: Yes and No 18 | * @param chatId Telegram Chat ID 19 | * @param msgId Telegram Message ID 20 | * @param identifier Unique identifier for this message 21 | * @param link Link to expand 22 | * @param isDeletable Whether the original message can be deleted 23 | */ 24 | export const askToExpand = async (ctx: Context, identifier: string, link: string, isDeletable: boolean) => { 25 | if (!ctx || !ctx.chat?.id) return; 26 | 27 | const chatId = ctx.chat?.id; 28 | if (isBanned(chatId)) return; 29 | 30 | const insta = isInstagram(link); 31 | const tiktok = isTikTok(link); 32 | const posts = isPosts(link); 33 | const hn = isHackerNews(link); 34 | const dribbble = isDribbble(link); 35 | const bluesky = isBluesky(link); 36 | const reddit = isReddit(link); 37 | const spotify = isSpotify(link); 38 | const platform = insta 39 | ? "instagram" 40 | : tiktok 41 | ? "tiktok" 42 | : posts 43 | ? "posts" 44 | : hn 45 | ? "hackernews" 46 | : dribbble 47 | ? "dribbble" 48 | : bluesky 49 | ? "bluesky" 50 | : reddit 51 | ? "reddit" 52 | : spotify 53 | ? "spotify" 54 | : "twitter"; 55 | 56 | try { 57 | const originalReplyId = ctx.update?.message?.reply_to_message?.message_id; 58 | 59 | await ctx 60 | .reply(askToExpandTemplate(link), { 61 | reply_to_message_id: ctx.msg?.message_id, 62 | reply_markup: { 63 | inline_keyboard: [ 64 | [ 65 | { 66 | text: "✅ Yes", 67 | callback_data: `expand:yes:${identifier}:${platform}:${originalReplyId}:${isDeletable}`, 68 | // callback_data has a 64 byte limit!!! 69 | }, 70 | { 71 | text: "❌ No", 72 | callback_data: `expand:no:${identifier}:${platform}`, 73 | }, 74 | ], 75 | ], 76 | }, 77 | }) 78 | .catch((error) => { 79 | console.error(`[Error] Could not send ask-to-expand message.`); 80 | console.error(error); 81 | return; 82 | }); 83 | } catch (error) { 84 | // @ts-ignore 85 | console.error({ 86 | message: "Error sending ask-to-expand message", 87 | // @ts-ignore 88 | error: error.message, 89 | }); 90 | return; 91 | } 92 | }; 93 | -------------------------------------------------------------------------------- /actions/delete-message.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { bot } from ".."; 3 | // import { handleMissingPermissions } from "./missing-permissions"; 4 | 5 | /** 6 | * Delete a Telegram message in chat. 7 | * @param chatId Telegram Chat ID 8 | * @param msgId Telegram Message ID 9 | * @param ctx Telegram Context 10 | */ 11 | export const deleteMessage = async (chatId: string | number, msgId: number, ctx?: Context) => { 12 | // Gotta await try/catch this because the original message might have been deleted already, or the bot might not have permission to delete it. 13 | // Bot will crash if it tries to delete a message that it cannot delete. 14 | try { 15 | await bot.api.deleteMessage(chatId, msgId).catch(() => { 16 | console.error(`[Error] Could not delete message.`); 17 | return; 18 | }); 19 | } catch (error) { 20 | // console.error({ 21 | // message: "Error deleting message", 22 | // error: error.message, 23 | // }); 24 | // if (ctx) await handleMissingPermissions(ctx); 25 | return; 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /actions/expand-link.ts: -------------------------------------------------------------------------------- 1 | import { Context, InputFile } from "grammy"; 2 | import { expandedMessageTemplate } from "../helpers/templates"; 3 | import { 4 | isInstagram, 5 | isPosts, 6 | isReddit, 7 | isTikTok, 8 | isTweet, 9 | isDribbble, 10 | isBluesky, 11 | isSpotify, 12 | isInstagramShare, 13 | } from "../helpers/platforms"; 14 | import { trackEvent } from "../helpers/analytics"; 15 | import { notifyAdmin } from "../helpers/notifier"; 16 | import { getOGMetadata } from "../helpers/og-metadata"; 17 | import { saveToCache, deleteFromCache } from "../helpers/cache"; 18 | import { getButtonState } from "../helpers/button-states"; 19 | import { resolveInstagramShare } from "../helpers/instagram-share"; 20 | 21 | type UserInfoType = { 22 | username: string | undefined; 23 | firstName: string | undefined; 24 | lastName: string | undefined; 25 | userId: number | undefined; 26 | }; 27 | 28 | /** 29 | * Handle expanding the link based on the platform. 30 | * @param link URL to expand 31 | * @returns Expanded URL with the right domain 32 | */ 33 | function handleExpandedLinkDomain(link: string): string { 34 | // If multiple URLs are accidentally concatenated, take only the first one 35 | if (link.includes("http", 1)) { 36 | link = link.split("http")[0]; 37 | } 38 | 39 | switch (true) { 40 | case isInstagram(link): 41 | if (link.includes("kkinstagram.com")) return link; 42 | return link.replace("instagram.com", "kkinstagram.com"); 43 | case isTikTok(link): 44 | return link.replace("lite.tiktok.com", "tfxktok.com").replace("tiktok.com", "tfxktok.com"); 45 | case isPosts(link): 46 | return link.replace("posts.cv", "postscv.com"); 47 | case isTweet(link): 48 | if (link.includes("fxtwitter.com")) return link; 49 | return link.replace("twitter.com", "fxtwitter.com").replace("x.com", "fxtwitter.com"); 50 | case isDribbble(link): 51 | return link.replace("dribbble.com", "dribbbletv.com"); 52 | case isBluesky(link): 53 | return link.replace("bsky.app", "fxbsky.app"); 54 | case isReddit(link): 55 | return link.replace("reddit.com", "rxddit.com"); 56 | default: 57 | return link; 58 | } 59 | } 60 | 61 | /** 62 | * Handles link expansion and sending the message with the correct template and destruct button. 63 | * @param ctx Telegram Context 64 | * @param link Link to expand 65 | * @param messageText Text of the message without URLs 66 | * @param userInfo Object with user details for creating the message template 67 | */ 68 | export async function expandLink( 69 | ctx: Context, 70 | link: string, 71 | messageText: string, 72 | userInfo: UserInfoType, 73 | expansionType: "auto" | "manual", 74 | replyId?: number 75 | ) { 76 | if (!ctx || !ctx.chat?.id) return; 77 | // Return correct link based on platform 78 | const expandedLink = handleExpandedLinkDomain(link); 79 | let linkWithNoTrackers = expandedLink; 80 | // Strip trackers from these platforms but not others. 81 | if (isTweet(link) || isInstagram(link) || isTikTok(link) || isSpotify(link)) { 82 | linkWithNoTrackers = expandedLink.split("?")[0]; 83 | } 84 | 85 | try { 86 | const chatId = ctx.chat?.id; 87 | const topicId = ctx.msg?.message_thread_id; 88 | const replyTo = replyId || ctx.update?.message?.reply_to_message?.message_id; 89 | // Very complicated bullshit to handle replying to a message inside a thread 90 | // and replying to a message outside a thread, because the way these topics are set up is annoying. 91 | const sameId = replyTo === topicId; 92 | const threadOptions = replyId ? { message_thread_id: topicId } : null; 93 | const threadId = sameId ? null : threadOptions; 94 | const replyOptions = { 95 | reply_to_message_id: replyTo, 96 | ...threadId, 97 | }; 98 | 99 | let botReply: any; 100 | 101 | if (isSpotify(link)) { 102 | try { 103 | const metadata = await getOGMetadata(link ?? ""); 104 | const { title, description, image, audio } = metadata; 105 | 106 | // Limit description to 500 chars because Telegram rejects messages with more than 4096 characters. 107 | // 4096 seems a bit excessive to see in the chat so we'll just cut it off at 500. 108 | const maxCaptionLength = 500; 109 | 110 | // Calculate template length first 111 | const template = await expandedMessageTemplate( 112 | ctx, 113 | userInfo.username, 114 | userInfo.userId, 115 | userInfo.firstName, 116 | userInfo.lastName, 117 | messageText, 118 | linkWithNoTrackers 119 | ); 120 | 121 | // Calculate remaining space for title and description (using 500 to be safe) 122 | const remainingSpace = Math.max(0, maxCaptionLength - template.length - 4); // 4 chars for "\n\n" 123 | const titleMaxLength = Math.min(50, Math.floor(remainingSpace * 0.3)); // Max 50 chars for title 124 | const descMaxLength = Math.floor(remainingSpace * 0.7); // Rest for description 125 | 126 | const truncatedTitle = title.length > titleMaxLength ? title.slice(0, titleMaxLength) + "..." : title; 127 | const truncatedDesc = 128 | description.length > descMaxLength ? description.slice(0, descMaxLength) + "..." : description; 129 | 130 | botReply = await ctx.api.sendPhoto(chatId, new InputFile(new URL(`https://wsrv.nl/?url=${image}&w=600`)), { 131 | ...replyOptions, 132 | caption: template + `\n\n${truncatedTitle}\n${truncatedDesc}`, 133 | parse_mode: "HTML", 134 | }); 135 | 136 | if (audio) { 137 | // Also limit the audio caption 138 | const audioDesc = description.length > 250 ? description.slice(0, 250) + "..." : description; 139 | await ctx.api.sendAudio(chatId, new InputFile(new URL(audio)), { 140 | ...replyOptions, 141 | title: truncatedTitle, 142 | caption: audioDesc, 143 | thumbnail: new InputFile(new URL(`https://wsrv.nl/?url=${image}&w=200&h=200`)), 144 | parse_mode: "HTML", 145 | reply_markup: { 146 | inline_keyboard: [ 147 | [ 148 | { 149 | text: "❌ Delete", 150 | callback_data: `destruct:${userInfo.userId}:${expansionType}`, 151 | }, 152 | ], 153 | ], 154 | }, 155 | }); 156 | } 157 | } catch (error) { 158 | console.error(error); 159 | notifyAdmin(error); 160 | 161 | botReply = await ctx.api.sendMessage( 162 | chatId, 163 | await expandedMessageTemplate( 164 | ctx, 165 | userInfo.username, 166 | userInfo.userId, 167 | userInfo.firstName, 168 | userInfo.lastName, 169 | messageText, 170 | linkWithNoTrackers 171 | ), 172 | { 173 | ...replyOptions, 174 | // Use HTML parse mode if the user does not have a username, 175 | // otherwise the bot will not be able to mention the user. 176 | parse_mode: "HTML", 177 | reply_markup: { 178 | inline_keyboard: [ 179 | [ 180 | { 181 | text: "❌ Delete — 15s", 182 | callback_data: `destruct:${userInfo.userId}:${expansionType}`, 183 | }, 184 | ], 185 | ], 186 | }, 187 | } 188 | ); 189 | } 190 | } else { 191 | // Handle Instagram share links 192 | if (link.includes("instagram.com/share/")) { 193 | try { 194 | const resolvedUrl = await resolveInstagramShare(link); 195 | if (resolvedUrl) { 196 | // Replace the share URL with the resolved URL and convert to kkinstagram.com 197 | const finalUrl = resolvedUrl.replace(/instagram\.com/g, "kkinstagram.com"); 198 | linkWithNoTrackers = finalUrl; // Update the link used in the template 199 | link = finalUrl; 200 | let platform: "twitter" | "instagram" | "tiktok" | "instagram-share" | null = null; 201 | platform = "instagram-share"; // Track as Instagram share 202 | } 203 | } catch (error) { 204 | console.error("[Error] Failed to resolve Instagram share link:", error); 205 | } 206 | } 207 | // Handle regular Instagram links (replace domain with kkinstagram.com) 208 | else if (isInstagram(link)) { 209 | link = link.replace(/instagram\.com/g, "kkinstagram.com"); 210 | } 211 | 212 | // Handle Spotify links 213 | if (link.includes("open.spotify.com")) { 214 | try { 215 | const metadata = await getOGMetadata(link ?? ""); 216 | const { title, description, image, audio } = metadata; 217 | 218 | // Limit description to 500 chars because Telegram rejects messages with more than 4096 characters. 219 | // 4096 seems a bit excessive to see in the chat so we'll just cut it off at 500. 220 | const maxCaptionLength = 500; 221 | 222 | // Calculate template length first 223 | const template = await expandedMessageTemplate( 224 | ctx, 225 | userInfo.username, 226 | userInfo.userId, 227 | userInfo.firstName, 228 | userInfo.lastName, 229 | messageText, 230 | linkWithNoTrackers 231 | ); 232 | 233 | // Calculate remaining space for title and description (using 500 to be safe) 234 | const remainingSpace = Math.max(0, maxCaptionLength - template.length - 4); // 4 chars for "\n\n" 235 | const titleMaxLength = Math.min(50, Math.floor(remainingSpace * 0.3)); // Max 50 chars for title 236 | const descMaxLength = Math.floor(remainingSpace * 0.7); // Rest for description 237 | 238 | const truncatedTitle = title.length > titleMaxLength ? title.slice(0, titleMaxLength) + "..." : title; 239 | const truncatedDesc = 240 | description.length > descMaxLength ? description.slice(0, descMaxLength) + "..." : description; 241 | 242 | botReply = await ctx.api.sendPhoto(chatId, new InputFile(new URL(`https://wsrv.nl/?url=${image}&w=600`)), { 243 | ...replyOptions, 244 | caption: template + `\n\n${truncatedTitle}\n${truncatedDesc}`, 245 | parse_mode: "HTML", 246 | }); 247 | 248 | if (audio) { 249 | // Also limit the audio caption 250 | const audioDesc = description.length > 250 ? description.slice(0, 250) + "..." : description; 251 | await ctx.api.sendAudio(chatId, new InputFile(new URL(audio)), { 252 | ...replyOptions, 253 | title: truncatedTitle, 254 | caption: audioDesc, 255 | thumbnail: new InputFile(new URL(`https://wsrv.nl/?url=${image}&w=200&h=200`)), 256 | parse_mode: "HTML", 257 | reply_markup: { 258 | inline_keyboard: [ 259 | [ 260 | { 261 | text: "❌ Delete", 262 | callback_data: `destruct:${userInfo.userId}:${expansionType}`, 263 | }, 264 | ], 265 | ], 266 | }, 267 | }); 268 | } 269 | } catch (error) { 270 | console.error(error); 271 | notifyAdmin(error); 272 | 273 | botReply = await ctx.api.sendMessage( 274 | chatId, 275 | await expandedMessageTemplate( 276 | ctx, 277 | userInfo.username, 278 | userInfo.userId, 279 | userInfo.firstName, 280 | userInfo.lastName, 281 | messageText, 282 | linkWithNoTrackers 283 | ), 284 | { 285 | ...replyOptions, 286 | // Use HTML parse mode if the user does not have a username, 287 | // otherwise the bot will not be able to mention the user. 288 | parse_mode: "HTML", 289 | reply_markup: { 290 | inline_keyboard: [ 291 | [ 292 | { 293 | text: "❌ Delete — 15s", 294 | callback_data: `destruct:${userInfo.userId}:${expansionType}`, 295 | }, 296 | ], 297 | ], 298 | }, 299 | } 300 | ); 301 | } 302 | } else { 303 | // For all other platforms 304 | let platform: any = null; 305 | if (isInstagram(link)) platform = "instagram"; 306 | else if (isTikTok(link)) platform = "tiktok"; 307 | else if (isTweet(link)) platform = "twitter"; 308 | else if (isInstagramShare(link)) platform = "instagram-share"; 309 | else if (isReddit(link)) platform = "reddit"; 310 | 311 | const replyMarkup = platform 312 | ? { 313 | inline_keyboard: getButtonState(platform, 15, userInfo.userId || ctx.from?.id || 0, link).buttons, 314 | } 315 | : undefined; 316 | 317 | try { 318 | botReply = await ctx.api.sendMessage( 319 | chatId, 320 | await expandedMessageTemplate( 321 | ctx, 322 | userInfo.username, 323 | userInfo.userId, 324 | userInfo.firstName, 325 | userInfo.lastName, 326 | messageText, 327 | linkWithNoTrackers 328 | ), 329 | { 330 | parse_mode: "HTML", 331 | ...replyOptions, 332 | ...(replyMarkup ? { reply_markup: replyMarkup } : {}), 333 | } 334 | ); 335 | 336 | // For supported platforms, start the button progression 337 | if (platform && botReply) { 338 | const identifier = `${chatId}:${botReply.message_id}`; 339 | await saveToCache(identifier, ctx); 340 | 341 | // Keep track of timeouts so we can clear them if needed 342 | const timeouts: NodeJS.Timeout[] = []; 343 | 344 | // Start the button progression 345 | const updateButtons = async (timeRemaining: number) => { 346 | try { 347 | const state = getButtonState(platform!, timeRemaining, userInfo.userId || ctx.from?.id || 0, link); 348 | await ctx.api.editMessageReplyMarkup(chatId, botReply!.message_id, { 349 | reply_markup: { inline_keyboard: state.buttons }, 350 | }); 351 | 352 | // Schedule next update if there is one 353 | if (state.nextTimeout !== null) { 354 | const timeout = setTimeout(() => { 355 | try { 356 | updateButtons(state.nextTimeout!).catch(() => { 357 | // Clear all timeouts if we can't update buttons 358 | timeouts.forEach((t) => clearTimeout(t)); 359 | }); 360 | } catch (error) { 361 | // Clear all timeouts if we can't update buttons 362 | timeouts.forEach((t) => clearTimeout(t)); 363 | } 364 | }, 5000); 365 | timeouts.push(timeout); 366 | } 367 | } catch (error) { 368 | // Message not found errors are expected if message was deleted 369 | if (error instanceof Error && error.message.includes("message to edit not found")) { 370 | console.warn("[Warning] Message has probably been already deleted."); 371 | // Clear all timeouts since we can't update this message anymore 372 | timeouts.forEach((t) => clearTimeout(t)); 373 | } else { 374 | console.error("[Error] Failed to update buttons:", error); 375 | } 376 | } 377 | }; 378 | 379 | // Start the progression 380 | try { 381 | const initialTimeout = setTimeout(() => { 382 | updateButtons(10).catch(() => { 383 | // Clear all timeouts if initial update fails 384 | timeouts.forEach((t) => clearTimeout(t)); 385 | }); 386 | }, 5000); 387 | timeouts.push(initialTimeout); 388 | 389 | // Remove from cache and set final state after 35 seconds 390 | const finalTimeout = setTimeout(() => { 391 | try { 392 | deleteFromCache(identifier); 393 | // Set final state with just the open button 394 | const finalState = getButtonState(platform!, null, userInfo.userId || ctx.from?.id || 0, link); 395 | ctx.api 396 | .editMessageReplyMarkup(chatId, botReply!.message_id, { 397 | reply_markup: { inline_keyboard: finalState.buttons }, 398 | }) 399 | .catch((error) => { 400 | if (error.message.includes("message to edit not found")) { 401 | console.warn("[Warning] Message has probably been already deleted."); 402 | } else { 403 | console.error("[Error] Failed to set final button state:", error); 404 | } 405 | }); 406 | } catch (error) { 407 | // Message not found errors are expected if message was deleted 408 | if (error instanceof Error && error.message.includes("message to edit not found")) { 409 | console.warn("[Warning] Message has probably been already deleted."); 410 | } else { 411 | console.error("[Error] Failed to set final button state:", error); 412 | } 413 | } 414 | }, 35000); 415 | timeouts.push(finalTimeout); 416 | } catch (error) { 417 | console.error("[Error] Failed to start button progression:", error); 418 | // Clear any timeouts that might have been set 419 | timeouts.forEach((t) => clearTimeout(t)); 420 | } 421 | } 422 | } catch (error) { 423 | console.error("[Error] Could not reply with an expanded link.", error); 424 | throw error; 425 | } 426 | } 427 | } 428 | 429 | try { 430 | // Delete the original message only after we've successfully sent our reply 431 | if (ctx.msg?.message_id && botReply) { 432 | await ctx.api.deleteMessage(chatId, ctx.msg.message_id); 433 | } 434 | 435 | // Add message to cache for undo functionality 436 | if (botReply) { 437 | const identifier = `${chatId}:${botReply.message_id}`; 438 | await saveToCache(identifier, ctx); 439 | } 440 | } catch (error) { 441 | console.error("[Error] Could not delete original message or add to cache.", error); 442 | } 443 | 444 | if (topicId) { 445 | trackEvent(`expand.${expansionType}.inside-topic`); 446 | } 447 | } catch (error) { 448 | console.error("[Error: expand-link.ts] Could not reply with an expanded link."); 449 | // @ts-ignore 450 | // console.error(error); 451 | return; 452 | } 453 | } 454 | -------------------------------------------------------------------------------- /actions/get-member-count.ts: -------------------------------------------------------------------------------- 1 | import { bot } from ".."; 2 | import { updateSettings } from "../helpers/api"; 3 | 4 | /** 5 | * Save group chat size to database for anonymous analytics. 6 | * @param chatId Telegram Chat ID 7 | */ 8 | export const getMemberCount = async (chatId: number) => { 9 | try { 10 | await bot.api 11 | .getChatMemberCount(chatId) 12 | .then((count: number) => { 13 | // Set count as 0 if there are 2 or less members in the chat 14 | // because this would mean it’s a private chat with the bot. 15 | // Otherwise subtract 1 from the count to account for the bot itself. 16 | const memberCount = count <= 2 ? 0 : count - 1; 17 | 18 | updateSettings(chatId, "chat_size", memberCount); 19 | }) 20 | .catch(() => { 21 | console.error(`[Error] Could not get member count.`); 22 | }); 23 | } catch (error) { 24 | console.error(`[Error] Could not get member count.`); 25 | // @ts-ignore 26 | console.error(error.message); 27 | return; 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /actions/missing-permissions.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { notifyAdmin } from "../helpers/notifier"; 3 | import { hasPermissionToDeleteMessageTemplate, missingPermissionToDeleteMessageTemplate } from "../helpers/templates"; 4 | import { getSettings } from "../helpers/api"; 5 | 6 | /** 7 | * Check if bot has permission to delete messages and send a message if it doesn’t. 8 | * @param ctx Telegram Context 9 | * @param fromCommand Whether the function was called from a command or from a callback. 10 | */ 11 | export const handleMissingPermissions = async (ctx: Context, fromCommand?: boolean) => { 12 | if (!ctx.chat) return; 13 | 14 | try { 15 | const adminRights: any = await ctx.getChatMember(ctx.me.id); 16 | const privateChat = ctx?.msg?.chat.type === "private"; 17 | 18 | const replyWithMessageAboutPermissions = async ( 19 | template: typeof hasPermissionToDeleteMessageTemplate | typeof missingPermissionToDeleteMessageTemplate 20 | ) => { 21 | const topicId = ctx.msg?.message_thread_id; 22 | await ctx 23 | .reply(template, { 24 | message_thread_id: topicId ?? undefined, 25 | reply_markup: { 26 | inline_keyboard: [ 27 | [ 28 | { 29 | text: "🙅‍♀️ Disable future warnings", 30 | callback_data: "permissions:disable-warning", 31 | }, 32 | ], 33 | [ 34 | { 35 | text: "👮 Admin Only: Grant permissions", 36 | url: "tg://resolve?domain=TwitterLinkExpanderBot&startgroup&admin=delete_messages", 37 | }, 38 | ], 39 | [ 40 | { 41 | text: "✨ Done", 42 | callback_data: "permissions:done", 43 | }, 44 | ], 45 | ], 46 | }, 47 | }) 48 | .catch(() => { 49 | console.error(`[Error] [missing-permissions.ts:49] Failed to send permissions warning template.`); 50 | return; 51 | }); 52 | }; 53 | 54 | if (fromCommand) { 55 | if (adminRights.can_delete_messages) { 56 | await replyWithMessageAboutPermissions(hasPermissionToDeleteMessageTemplate); 57 | } else { 58 | await replyWithMessageAboutPermissions(missingPermissionToDeleteMessageTemplate); 59 | } 60 | 61 | return; 62 | } 63 | 64 | if (!adminRights.can_delete_messages) { 65 | try { 66 | const settings = await getSettings(ctx.chat.id); 67 | if (settings?.ignore_permissions_warning || privateChat) return; 68 | 69 | await replyWithMessageAboutPermissions(missingPermissionToDeleteMessageTemplate); 70 | } catch (error) { 71 | console.error(error); 72 | notifyAdmin(error); 73 | } 74 | } 75 | } catch (error: any) { 76 | console.error(error); 77 | notifyAdmin(error); 78 | return; 79 | } 80 | }; 81 | -------------------------------------------------------------------------------- /actions/show-bot-activity.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { bot } from ".."; 3 | import { isBanned } from "../helpers/banned"; 4 | 5 | /** 6 | * Displays the "is typing..." animated indicator inside Telegram. 7 | * @param chatId ID of current chat. 8 | */ 9 | export const showBotActivity = async (ctx: Context, chatId: number) => { 10 | // if (isBanned(chatId)) return; 11 | 12 | // const topicId = ctx.msg?.message_thread_id; 13 | 14 | // try { 15 | // bot.api.sendChatAction(chatId, "typing", { 16 | // message_thread_id: topicId ?? undefined, 17 | // }); 18 | // } catch (e) { 19 | // console.error(`[Error-1] Could not display bot activity indicator.`); 20 | // console.error(e); 21 | // return; 22 | // } 23 | 24 | return; 25 | }; 26 | -------------------------------------------------------------------------------- /callbacks/destruct-expanded-link.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { deleteMessage } from "../actions/delete-message"; 3 | import { trackEvent } from "../helpers/analytics"; 4 | import { getButtonState } from "../helpers/button-states"; 5 | 6 | /** 7 | * Handle responses to expanded link's "❌ Delete" button 8 | * @param ctx Telegram context 9 | */ 10 | export async function handleExpandedLinkDestruction(ctx: Context) { 11 | const answer = ctx.update?.callback_query; 12 | const chatId = answer?.message?.chat.id; 13 | const messageId = answer?.message?.message_id; 14 | const data = answer?.data; 15 | 16 | // Discard malformed messages 17 | if (!answer || !chatId || !messageId || !data) return; 18 | 19 | if (data.includes("destruct:")) { 20 | const destructData = data.split(":"); 21 | const originalAuthorId = Number(destructData[1]); 22 | const timeRemaining = Number(destructData[2]); 23 | const answerGiverId = answer?.from?.id; 24 | 25 | if (answerGiverId !== originalAuthorId) { 26 | await ctx 27 | .answerCallbackQuery({ 28 | text: "This message can only be deleted by its original author.", 29 | show_alert: true, 30 | }) 31 | .catch(() => { 32 | console.error(`[Error] Cannot answer callback query.`); 33 | return; 34 | }); 35 | 36 | trackEvent(`destruct.${timeRemaining}.not-author-alert`); 37 | return; 38 | } 39 | 40 | deleteMessage(chatId, messageId); 41 | await ctx.answerCallbackQuery().catch(() => { 42 | console.error(`[Error] Cannot answer callback query.`); 43 | return; 44 | }); 45 | trackEvent(`destruct.${timeRemaining}.author`); 46 | return; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /callbacks/index.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { bot } from ".."; 3 | import { getMemberCount } from "../actions/get-member-count"; 4 | import { handleManualExpand } from "./manual-expand"; 5 | import { handleExpandedLinkDestruction } from "./destruct-expanded-link"; 6 | import { handleAutoexpandSettings } from "./settings-autoexpand"; 7 | import { handleLockSettings } from "./settings-lock"; 8 | import { handleChangelogSettings } from "./settings-changelog"; 9 | import { handlePermissionsSettings } from "./settings-permissions"; 10 | import { handleUndo } from "./undo"; 11 | import { isBanned } from "../helpers/banned"; 12 | 13 | // Multiple bot.on("callback_query") functions cannot run in parallel. 14 | // The bot will only register the first one and ignore the rest. 15 | // This file runs the bot.on("callback_query") listener and imports functions 16 | // that are specific to the callback_query data to keep it more clean. 17 | bot.on("callback_query", async (ctx: Context) => { 18 | const chatId = ctx.update?.callback_query?.message?.chat.id; 19 | const data = ctx.update?.callback_query?.data; 20 | 21 | if (!chatId || !data) return; 22 | if (isBanned(chatId)) return; 23 | 24 | // Save chat member count to database 25 | getMemberCount(chatId); 26 | 27 | // Handle expand callbacks 28 | await handleManualExpand(ctx); 29 | await handleExpandedLinkDestruction(ctx); 30 | await handleUndo(ctx); 31 | await handleAutoexpandSettings(ctx); 32 | await handleLockSettings(ctx); 33 | await handleChangelogSettings(ctx); 34 | await handlePermissionsSettings(ctx); 35 | }); 36 | -------------------------------------------------------------------------------- /callbacks/manual-expand.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { trackEvent } from "../helpers/analytics"; 3 | import { deleteMessage } from "../actions/delete-message"; 4 | import { checkIfCached, deleteFromCache, getFromCache } from "../helpers/cache"; 5 | import { expandLink } from "../actions/expand-link"; 6 | import { showBotActivity } from "../actions/show-bot-activity"; 7 | 8 | /** 9 | * Handle Yes/No button responses to expand links 10 | * @param ctx Telegram context 11 | */ 12 | export async function handleManualExpand(ctx: Context) { 13 | const answer = ctx.update?.callback_query; 14 | const chatId = answer?.message?.chat.id; 15 | const messageId = answer?.message?.message_id; 16 | const data = answer?.data; 17 | 18 | // Discard malformed messages 19 | if (!answer || !chatId || !messageId || !data) return; 20 | 21 | if (data.includes("expand:no")) { 22 | const properties = data.split(":"); // expand:yes:chatId:messageId:linkIndex:platform 23 | const originalChatId: string = properties[2]; 24 | const originalMessageId: string = properties[3]; 25 | const linkIndex: number = Number(properties[4]); 26 | const platform: string = properties[5]; 27 | const identifier = `${originalChatId}:${originalMessageId}:${linkIndex}`; 28 | 29 | await ctx.answerCallbackQuery().catch(() => { 30 | console.error(`[Error] Cannot answer callback query.`); 31 | }); 32 | // Delete message with buttons 33 | // Wipe it from cache 34 | // Track the event 35 | deleteMessage(chatId, messageId); 36 | deleteFromCache(identifier); 37 | trackEvent(`expand.no.${platform}`); 38 | return; 39 | } 40 | 41 | if (data.includes("expand:yes")) { 42 | try { 43 | const properties = data.split(":"); // expand:yes:chatId:messageId:linkIndex:platform:isDeletable 44 | const originalChatId: string = properties[2]; 45 | const originalMessageId: string = properties[3]; 46 | const linkIndex: number = Number(properties[4]); 47 | const platform: string = properties[5]; 48 | const replyId: number = Number(properties[6]); 49 | const isDeletable: boolean = properties[7] === "true"; 50 | const identifier = `${originalChatId}:${originalMessageId}:${linkIndex}`; 51 | const prevLinkIdentifier = `${originalChatId}:${originalMessageId}:${linkIndex - 1}`; 52 | const nextLinkIdentifier = `${originalChatId}:${originalMessageId}:${linkIndex + 1}`; 53 | const hasPrevLink: boolean = await checkIfCached(prevLinkIdentifier); 54 | const hasNextLink: boolean = await checkIfCached(nextLinkIdentifier); 55 | const contextFromCache: any = await getFromCache(identifier); 56 | const cachedMessage = contextFromCache?.update?.message; 57 | const urlOffset: number = 58 | cachedMessage?.entities?.[linkIndex].offset || cachedMessage?.caption_entities?.[linkIndex].offset || 0; 59 | const urlLength: number = 60 | cachedMessage?.entities?.[linkIndex].length || cachedMessage?.caption_entities?.[linkIndex].length; 61 | const message = cachedMessage?.text ?? cachedMessage?.caption ?? ""; 62 | const url: string = message.slice(urlOffset, urlOffset + urlLength); 63 | 64 | // Only expand when a message has been cached, otherwise ignore the callback 65 | // because it will throw an error when trying to delete the message. 66 | if (contextFromCache) { 67 | const entities = contextFromCache.entities() || contextFromCache.caption_entities(); 68 | const messageWithNoLinks = entities.reduce((msg: string, entity: { type: string; text: any }) => { 69 | if (entity.type === "url" && entity.text === url) { 70 | return msg.replace(entity.text, ""); 71 | } 72 | return msg; 73 | }, message); 74 | 75 | const userInfo = { 76 | username: cachedMessage.from?.username, 77 | firstName: cachedMessage.from?.first_name, 78 | lastName: cachedMessage.from?.last_name, 79 | userId: cachedMessage.from?.id, 80 | }; 81 | 82 | showBotActivity(ctx, chatId); 83 | await expandLink(ctx, url, messageWithNoLinks, userInfo, "manual", replyId); 84 | deleteMessage(chatId, messageId); // bot’s [yes][no] message 85 | deleteFromCache(identifier); 86 | 87 | // When multiple links are in the message the bot will send a reply for each link. 88 | // Delete the original message only if it's the last link in the message. 89 | if (!hasPrevLink && !hasNextLink) { 90 | if (isDeletable) await deleteMessage(originalChatId, Number(originalMessageId), ctx); 91 | } 92 | } 93 | 94 | trackEvent(`expand.yes.${platform}`); 95 | } catch (error) { 96 | console.error(`[Error] Cannot answer expand callback query.`); 97 | console.error(error); 98 | return; 99 | } 100 | 101 | await ctx.answerCallbackQuery().catch(() => { 102 | console.error(`[Error] Cannot answer callback query.`); 103 | }); 104 | return; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /callbacks/settings-autoexpand.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { trackEvent } from "../helpers/analytics"; 3 | import { getSettings, updateSettings } from "../helpers/api"; 4 | import { autoexpandSettingsTemplate } from "../helpers/templates"; 5 | import { deleteMessage } from "../actions/delete-message"; 6 | import { handleMissingPermissions } from "../actions/missing-permissions"; 7 | import { checkAdminStatus } from "../helpers/admin"; 8 | 9 | const FIELD_NAME = "autoexpand"; 10 | 11 | /** 12 | * Handle button responses to /autoexpand 13 | * @param ctx Telegram context 14 | */ 15 | export async function handleAutoexpandSettings(ctx: Context) { 16 | const answer = ctx.update?.callback_query; 17 | const chatId = answer?.message?.chat.id; 18 | const messageId = answer?.message?.message_id; 19 | const data = answer?.data; 20 | const privateChat = answer?.message?.chat.type === "private"; 21 | 22 | // Discard malformed messages 23 | if (!answer || !chatId || !messageId || !data) return; 24 | 25 | const [settings, isAdmin] = await Promise.all([getSettings(chatId), checkAdminStatus(ctx)]); 26 | if (!isAdmin && settings?.settings_lock) { 27 | // return await ctx.reply("You need to be an admin to change Autoexpand settings.").catch(() => { 28 | console.error(`[Error] [settings-autoexpand.ts:28] Failed to send message.`); 29 | return; 30 | // }); 31 | } 32 | 33 | if (data.includes("autoexpand:done")) { 34 | await ctx.answerCallbackQuery().catch(() => { 35 | console.error(`[Error] Cannot answer callback query.`); 36 | return; 37 | }); 38 | deleteMessage(chatId, messageId); 39 | return; 40 | } 41 | 42 | if (data.includes("autoexpand:off")) { 43 | updateSettings(chatId, FIELD_NAME, false); 44 | await ctx.answerCallbackQuery().catch(() => { 45 | console.error(`[Error] Cannot answer callback query.`); 46 | return; 47 | }); 48 | await ctx.api 49 | .editMessageText(chatId, messageId, autoexpandSettingsTemplate(false), { 50 | parse_mode: "MarkdownV2", 51 | reply_markup: { 52 | inline_keyboard: [ 53 | [ 54 | { 55 | text: "✅ Enable", 56 | callback_data: `autoexpand:on`, 57 | }, 58 | { 59 | text: "✨ Done", 60 | callback_data: "autoexpand:done", 61 | }, 62 | ], 63 | ], 64 | }, 65 | }) 66 | .catch(() => { 67 | console.error(`[Error1]`); 68 | return; 69 | }); 70 | 71 | trackEvent("settings.autoexpand.disable"); 72 | return; 73 | } 74 | 75 | if (data.includes("autoexpand:on")) { 76 | updateSettings(chatId, FIELD_NAME, true); 77 | await ctx.answerCallbackQuery().catch(() => { 78 | console.error(`[Error] Cannot answer callback query.`); 79 | return; 80 | }); 81 | await ctx.api 82 | .editMessageText(chatId, messageId, autoexpandSettingsTemplate(true), { 83 | parse_mode: "MarkdownV2", 84 | reply_markup: { 85 | inline_keyboard: [ 86 | [ 87 | { 88 | text: "❌ Disable", 89 | callback_data: `autoexpand:off`, 90 | }, 91 | { 92 | text: "✨ Done", 93 | callback_data: "autoexpand:done", 94 | }, 95 | ], 96 | ], 97 | }, 98 | }) 99 | .catch(() => { 100 | console.error(`[Error] Cannot edit settings.`); 101 | return; 102 | }); 103 | 104 | if (!privateChat) handleMissingPermissions(ctx); 105 | 106 | trackEvent("settings.autoexpand.enable"); 107 | return; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /callbacks/settings-changelog.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { trackEvent } from "../helpers/analytics"; 3 | import { getSettings, updateSettings } from "../helpers/api"; 4 | import { changelogSettingsTemplate } from "../helpers/templates"; 5 | import { deleteMessage } from "../actions/delete-message"; 6 | import { checkAdminStatus } from "../helpers/admin"; 7 | 8 | const FIELD_NAME = "changelog"; 9 | 10 | /** 11 | * Handle button responses to /changelog 12 | * @param ctx Telegram context 13 | */ 14 | export async function handleChangelogSettings(ctx: Context) { 15 | const answer = ctx.update?.callback_query; 16 | const chatId = answer?.message?.chat.id; 17 | const messageId = answer?.message?.message_id; 18 | const data = answer?.data; 19 | 20 | // Discard malformed messages 21 | if (!answer || !chatId || !messageId || !data) return; 22 | 23 | const [settings, isAdmin] = await Promise.all([getSettings(chatId), checkAdminStatus(ctx)]); 24 | if (!isAdmin && settings?.settings_lock) { 25 | // return await ctx.reply("You need to be an admin to change Changelog settings.").catch(() => { 26 | console.error(`[Error] [settings-changelog.ts:26] Failed to send message.`); 27 | return; 28 | // }); 29 | } 30 | 31 | if (data.includes("changelog:done")) { 32 | await ctx.answerCallbackQuery().catch(() => { 33 | console.error(`[Error] Cannot answer callback query.`); 34 | return; 35 | }); 36 | deleteMessage(chatId, messageId); 37 | return; 38 | } 39 | 40 | if (data.includes("changelog:off")) { 41 | updateSettings(chatId, FIELD_NAME, false); 42 | await ctx.answerCallbackQuery().catch(() => { 43 | console.error(`[Error] Cannot answer callback query.`); 44 | return; 45 | }); 46 | await ctx.api.editMessageText(chatId, messageId, changelogSettingsTemplate(false), { 47 | parse_mode: "MarkdownV2", 48 | reply_markup: { 49 | inline_keyboard: [ 50 | [ 51 | { 52 | text: "✅ Enable", 53 | callback_data: `changelog:on`, 54 | }, 55 | { 56 | text: "✨ Done", 57 | callback_data: "changelog:done", 58 | }, 59 | ], 60 | ], 61 | }, 62 | }); 63 | 64 | trackEvent("settings.changelog.disable"); 65 | return; 66 | } 67 | 68 | if (data.includes("changelog:on")) { 69 | updateSettings(chatId, FIELD_NAME, true); 70 | await ctx.answerCallbackQuery().catch(() => { 71 | console.error(`[Error] Cannot answer callback query.`); 72 | return; 73 | }); 74 | await ctx.api 75 | .editMessageText(chatId, messageId, changelogSettingsTemplate(true), { 76 | parse_mode: "MarkdownV2", 77 | reply_markup: { 78 | inline_keyboard: [ 79 | [ 80 | { 81 | text: "❌ Disable", 82 | callback_data: `changelog:off`, 83 | }, 84 | { 85 | text: "✨ Done", 86 | callback_data: "changelog:done", 87 | }, 88 | ], 89 | ], 90 | }, 91 | }) 92 | .catch(() => { 93 | console.error(`[Error] Cannot edit chanegelog settings.`); 94 | return; 95 | }); 96 | 97 | trackEvent("settings.changelog.enable"); 98 | return; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /callbacks/settings-lock.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { trackEvent } from "../helpers/analytics"; 3 | import { getSettings, updateSettings } from "../helpers/api"; 4 | import { lockSettingsTemplate } from "../helpers/templates"; 5 | import { deleteMessage } from "../actions/delete-message"; 6 | import { checkAdminStatus } from "../helpers/admin"; 7 | 8 | const FIELD_NAME = "settings_lock"; 9 | 10 | /** 11 | * Handle button responses to /autoexpand 12 | * @param ctx Telegram context 13 | */ 14 | export async function handleLockSettings(ctx: Context) { 15 | const answer = ctx.update?.callback_query; 16 | const chatId = answer?.message?.chat.id; 17 | const messageId = answer?.message?.message_id; 18 | const data = answer?.data; 19 | 20 | // Discard malformed messages 21 | if (!answer || !chatId || !messageId || !data) return; 22 | 23 | const [settings, isAdmin] = await Promise.all([getSettings(chatId), checkAdminStatus(ctx)]); 24 | if (!isAdmin && settings?.settings_lock) { 25 | // return await ctx.reply("You need to be an admin to change Lock settings.").catch(() => { 26 | console.error(`[Error] [settings-lock.ts:26] Failed to send message.`); 27 | return; 28 | // }); 29 | } 30 | 31 | if (data.includes("lock:done")) { 32 | await ctx.answerCallbackQuery().catch(() => { 33 | console.error(`[Error] Cannot answer callback query.`); 34 | return; 35 | }); 36 | deleteMessage(chatId, messageId); 37 | return; 38 | } 39 | 40 | if (data.includes("lock:off")) { 41 | updateSettings(chatId, FIELD_NAME, false); 42 | await ctx.answerCallbackQuery().catch(() => { 43 | console.error(`[Error] Cannot answer callback query.`); 44 | return; 45 | }); 46 | await ctx.api 47 | .editMessageText(chatId, messageId, lockSettingsTemplate(false), { 48 | parse_mode: "MarkdownV2", 49 | reply_markup: { 50 | inline_keyboard: [ 51 | [ 52 | { 53 | text: "🔒 Lock", 54 | callback_data: `lock:on`, 55 | }, 56 | { 57 | text: "✨ Done", 58 | callback_data: "lock:done", 59 | }, 60 | ], 61 | ], 62 | }, 63 | }) 64 | .catch(() => { 65 | console.error(`[Error1]`); 66 | return; 67 | }); 68 | 69 | trackEvent("settings.lock.disable"); 70 | return; 71 | } 72 | 73 | if (data.includes("lock:on")) { 74 | updateSettings(chatId, FIELD_NAME, true); 75 | await ctx.answerCallbackQuery().catch(() => { 76 | console.error(`[Error] Cannot answer callback query.`); 77 | return; 78 | }); 79 | await ctx.api 80 | .editMessageText(chatId, messageId, lockSettingsTemplate(true), { 81 | parse_mode: "MarkdownV2", 82 | reply_markup: { 83 | inline_keyboard: [ 84 | [ 85 | { 86 | text: "🔓 Unlock", 87 | callback_data: `lock:off`, 88 | }, 89 | { 90 | text: "✨ Done", 91 | callback_data: "lock:done", 92 | }, 93 | ], 94 | ], 95 | }, 96 | }) 97 | .catch(() => { 98 | console.error(`[Error] Cannot edit settings.`); 99 | return; 100 | }); 101 | 102 | trackEvent("settings.lock.enable"); 103 | return; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /callbacks/settings-permissions.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { deleteMessage } from "../actions/delete-message"; 3 | import { updateSettings } from "../helpers/api"; 4 | import { trackEvent } from "../helpers/analytics"; 5 | 6 | /** 7 | * Handle button responses to /permissions 8 | * @param ctx Telegram context 9 | */ 10 | export async function handlePermissionsSettings(ctx: Context) { 11 | const answer = ctx.update?.callback_query; 12 | const chatId = answer?.message?.chat.id; 13 | const messageId = answer?.message?.message_id; 14 | const data = answer?.data; 15 | 16 | // Discard malformed messages 17 | if (!answer || !chatId || !messageId || !data) return; 18 | 19 | if (data.includes("permissions:done")) { 20 | await ctx.answerCallbackQuery().catch(() => { 21 | console.error(`[Error] Cannot answer callback query.`); 22 | return; 23 | }); 24 | deleteMessage(chatId, messageId); 25 | return; 26 | } 27 | 28 | if (data.includes("permissions:disable-warning")) { 29 | await ctx.answerCallbackQuery().catch(() => { 30 | console.error(`[Error] Cannot answer callback query.`); 31 | return; 32 | }); 33 | deleteMessage(chatId, messageId); 34 | updateSettings(chatId, "ignore_permissions_warning", true); 35 | trackEvent("settings.permissions.disable-warning"); 36 | return; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /callbacks/undo.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { trackEvent } from "../helpers/analytics"; 3 | import { peekFromCache } from "../helpers/cache"; 4 | import { getButtonState } from "../helpers/button-states"; 5 | 6 | /** 7 | * Handle undo button for expanded links 8 | * Replaces expanded links back to their original form 9 | * @param ctx Telegram context 10 | */ 11 | export async function handleUndo(ctx: Context) { 12 | const answer = ctx.update?.callback_query; 13 | const chatId = answer?.message?.chat.id; 14 | const messageId = answer?.message?.message_id; 15 | const data = answer?.data; 16 | 17 | // Discard malformed messages 18 | if (!answer || !chatId || !messageId || !data) { 19 | console.error("[Error] Missing data in undo callback", { chatId, messageId, data }); 20 | return; 21 | } 22 | 23 | if (data === "undo") { 24 | try { 25 | const identifier = `${chatId}:${messageId}`; 26 | 27 | // Check if message is still in cache (within 35 second window) 28 | const cached = await peekFromCache(identifier); 29 | if (cached) { 30 | // Get the message text 31 | const messageText = answer.message?.text; 32 | if (!messageText) { 33 | console.error("[Error] No message text in undo callback"); 34 | return; 35 | } 36 | 37 | let platform: "twitter" | "instagram" | "tiktok" | "reddit" | null = null; 38 | let undoText = messageText; 39 | 40 | // Determine platform and handle URL replacement 41 | if (messageText.includes("kkinstagram.com")) { 42 | platform = "instagram"; 43 | undoText = messageText.replace(/kkinstagram\.com/g, "instagram.com"); 44 | } else if (messageText.includes("fxtwitter.com")) { 45 | platform = "twitter"; 46 | undoText = messageText.replace(/fxtwitter\.com/g, "twitter.com"); 47 | } else if (messageText.includes("tfxktok.com")) { 48 | platform = "tiktok"; 49 | undoText = messageText.replace(/tfxktok\.com/g, "tiktok.com"); 50 | } else if (messageText.includes("rxddit.com")) { 51 | platform = "reddit"; 52 | undoText = messageText.replace(/rxddit\.com/g, "reddit.com"); 53 | } else if ( 54 | messageText.includes("instagram.com") || 55 | messageText.includes("twitter.com") || 56 | messageText.includes("tiktok.com") || 57 | messageText.includes("reddit.com") 58 | ) { 59 | // The message already contains original URLs - it was already undone 60 | await ctx.answerCallbackQuery({ 61 | text: "✅ Link has already been reverted to the original", 62 | show_alert: false, 63 | }); 64 | return; 65 | } 66 | 67 | if (!platform) { 68 | console.error("[Error] Could not determine platform from message."); 69 | return; 70 | } 71 | 72 | try { 73 | // Extract URL from the message text 74 | const urlMatch = undoText.match(/(https?:\/\/[^\s]+)/); 75 | const url = urlMatch ? urlMatch[1] : ""; 76 | 77 | // Edit the message to show the original URL 78 | await ctx.api.editMessageText(chatId, messageId, undoText, { 79 | parse_mode: "HTML", 80 | reply_markup: { 81 | inline_keyboard: getButtonState(platform as any, 15, ctx.from?.id || 0, url).buttons, 82 | }, 83 | }); 84 | } catch (editError) { 85 | const error = editError as Error; 86 | // Message not found errors are expected if message was deleted 87 | if (error.message.includes("message to edit not found")) { 88 | console.warn("[Warning] Cannot update buttons. Message was probably deleted."); 89 | } else { 90 | console.error("[Error] Failed to edit message:", { 91 | error: error.message, 92 | parameters: { 93 | chatId, 94 | messageId, 95 | undoText, 96 | }, 97 | }); 98 | } 99 | } 100 | 101 | // Track the undo event 102 | trackEvent(`expand.undo.${platform}`); 103 | } else { 104 | // Message not in cache - the 35-second window has passed 105 | await ctx.answerCallbackQuery({ 106 | text: "This action is no longer available (35s time limit after expanding)", 107 | show_alert: true, 108 | }); 109 | } 110 | } catch (error) { 111 | console.error("[Error] Cannot process undo", error); 112 | } 113 | } 114 | 115 | // Answer the callback query to remove the loading state 116 | await ctx.answerCallbackQuery().catch(() => { 117 | console.error("[Error] Cannot answer undo callback query."); 118 | }); 119 | } 120 | -------------------------------------------------------------------------------- /commands/autoexpand.ts: -------------------------------------------------------------------------------- 1 | import { bot } from ".."; 2 | import { showBotActivity } from "../actions/show-bot-activity"; 3 | import { createSettings, getSettings } from "../helpers/api"; 4 | import { notifyAdmin } from "../helpers/notifier"; 5 | import { autoexpandSettingsTemplate } from "../helpers/templates"; 6 | import { deleteMessage } from "../actions/delete-message"; 7 | import { Context } from "grammy"; 8 | import { handleMissingPermissions } from "../actions/missing-permissions"; 9 | import { trackEvent } from "../helpers/analytics"; 10 | import { isBanned } from "../helpers/banned"; 11 | import { checkAdminStatus } from "../helpers/admin"; 12 | 13 | /** 14 | * Manage autoexpand settings 15 | */ 16 | bot.command("autoexpand", async (ctx: Context) => { 17 | const msg = ctx.update.message; 18 | const msgId = msg?.message_id; 19 | const chatId = msg?.chat.id; 20 | const privateChat = msg?.chat.type === "private"; 21 | const topicId = ctx.msg?.message_thread_id; 22 | 23 | // Discard malformed messages 24 | if (!msgId || !chatId) return; 25 | if (isBanned(chatId)) return; 26 | 27 | const [settings, isAdmin] = await Promise.all([getSettings(chatId), checkAdminStatus(ctx)]); 28 | if (!isAdmin && settings?.settings_lock) { 29 | return await bot.api 30 | .sendMessage(chatId, "You need to be an admin to use the Autoexpand command.", { 31 | message_thread_id: topicId ?? undefined, 32 | disable_notification: true, 33 | }) 34 | .catch(() => { 35 | console.error(`[Error] [autoexpand.ts:37] Failed to send message.`); 36 | return; 37 | }); 38 | } 39 | 40 | try { 41 | showBotActivity(ctx, chatId); 42 | 43 | if (settings) { 44 | deleteMessage(chatId, msgId); 45 | // Reply with template and buttons to control autoexpand settings 46 | await bot.api 47 | .sendMessage(chatId, autoexpandSettingsTemplate(settings.autoexpand), { 48 | message_thread_id: topicId ?? undefined, 49 | parse_mode: "MarkdownV2", 50 | disable_notification: true, 51 | reply_markup: { 52 | inline_keyboard: [ 53 | [ 54 | { 55 | text: settings.autoexpand ? "❌ Disable" : "✅ Enable", 56 | callback_data: `autoexpand:${settings.autoexpand ? "off" : "on"}`, 57 | }, 58 | { 59 | text: "✨ Done", 60 | callback_data: "autoexpand:done", 61 | }, 62 | ], 63 | ], 64 | }, 65 | }) 66 | .catch(() => { 67 | console.error(`[Error] [autoexpand.ts:51] Failed to send autoexpand settings template.`); 68 | return; 69 | }); 70 | 71 | if (settings.autoexpand && !privateChat) { 72 | handleMissingPermissions(ctx); 73 | } 74 | } else { 75 | deleteMessage(chatId, msgId); 76 | // Create default settings for this chat 77 | createSettings(chatId, true, true, false); 78 | // Reply with template and buttons to control autoexpand settings (default: on) 79 | await ctx.api 80 | .sendMessage(chatId, autoexpandSettingsTemplate(true), { 81 | message_thread_id: topicId ?? undefined, 82 | parse_mode: "MarkdownV2", 83 | disable_notification: true, 84 | reply_markup: { 85 | inline_keyboard: [ 86 | [ 87 | { 88 | text: "❌ Disable", 89 | callback_data: `autoexpand:off`, 90 | }, 91 | { 92 | text: "✨ Done", 93 | callback_data: "autoexpand:done", 94 | }, 95 | ], 96 | ], 97 | }, 98 | }) 99 | .catch(() => { 100 | console.error(`[Error] [autoexpand.ts:85] Failed to send autoexpand settings template.`); 101 | return; 102 | }); 103 | 104 | if (!privateChat) handleMissingPermissions(ctx); 105 | } 106 | } catch (error: any) { 107 | console.error(error); 108 | notifyAdmin(error); 109 | } 110 | 111 | trackEvent("command.autoexpand"); 112 | }); 113 | -------------------------------------------------------------------------------- /commands/changelog.ts: -------------------------------------------------------------------------------- 1 | import { bot } from ".."; 2 | import { showBotActivity } from "../actions/show-bot-activity"; 3 | import { createSettings, getSettings } from "../helpers/api"; 4 | import { notifyAdmin } from "../helpers/notifier"; 5 | import { changelogSettingsTemplate } from "../helpers/templates"; 6 | import { deleteMessage } from "../actions/delete-message"; 7 | import { Context } from "grammy"; 8 | import { trackEvent } from "../helpers/analytics"; 9 | import { isBanned } from "../helpers/banned"; 10 | import { checkAdminStatus } from "../helpers/admin"; 11 | 12 | /** 13 | * Manage changelog settings 14 | */ 15 | bot.command("changelog", async (ctx: Context) => { 16 | const msg = ctx.update.message; 17 | const msgId = msg?.message_id; 18 | const chatId = msg?.chat.id; 19 | const topicId = ctx.msg?.message_thread_id; 20 | 21 | // Discard malformed messages 22 | if (!msgId || !chatId) return; 23 | if (isBanned(chatId)) return; 24 | 25 | const [settings, isAdmin] = await Promise.all([getSettings(chatId), checkAdminStatus(ctx)]); 26 | if (!isAdmin && settings?.settings_lock) { 27 | return await bot.api 28 | .sendMessage(chatId, "You need to be an admin to use the Changelog command.", { 29 | message_thread_id: topicId ?? undefined, 30 | disable_notification: true, 31 | }) 32 | .catch(() => { 33 | console.error(`[Error] [changelog.ts:34] Failed to send message.`); 34 | return; 35 | }); 36 | } 37 | 38 | try { 39 | showBotActivity(ctx, chatId); 40 | 41 | if (settings) { 42 | deleteMessage(chatId, msgId); 43 | // Reply with template and buttons to control changelog settings 44 | await bot.api 45 | .sendMessage(chatId, changelogSettingsTemplate(settings.changelog), { 46 | message_thread_id: topicId ?? undefined, 47 | parse_mode: "MarkdownV2", 48 | disable_notification: true, 49 | reply_markup: { 50 | inline_keyboard: [ 51 | [ 52 | { 53 | text: settings.changelog ? "❌ Disable" : "✅ Enable", 54 | callback_data: `changelog:${settings.changelog ? "off" : "on"}`, 55 | }, 56 | { 57 | text: "✨ Done", 58 | callback_data: "changelog:done", 59 | }, 60 | ], 61 | ], 62 | }, 63 | }) 64 | .catch(() => { 65 | console.error(`[Error] [changelog.ts:51] Failed to send changelog settings template.`); 66 | return; 67 | }); 68 | } else { 69 | deleteMessage(chatId, msgId); 70 | // Create default settings for this chat 71 | createSettings(chatId, false, true, false); 72 | // Reply with template and buttons to control changelog settings (default: on) 73 | await ctx.api 74 | .sendMessage(chatId, changelogSettingsTemplate(true), { 75 | message_thread_id: topicId ?? undefined, 76 | parse_mode: "MarkdownV2", 77 | disable_notification: true, 78 | reply_markup: { 79 | inline_keyboard: [ 80 | [ 81 | { 82 | text: "❌ Disable", 83 | callback_data: `changelog:off`, 84 | }, 85 | { 86 | text: "✨ Done", 87 | callback_data: "changelog:done", 88 | }, 89 | ], 90 | ], 91 | }, 92 | }) 93 | .catch(() => { 94 | console.error(`[Error] [changelog.ts:79] Failed to send changelog settings template.`); 95 | return; 96 | }); 97 | } 98 | } catch (error: any) { 99 | console.error(error); 100 | notifyAdmin(error); 101 | return; 102 | } 103 | 104 | trackEvent("command.changelog"); 105 | }); 106 | -------------------------------------------------------------------------------- /commands/index.ts: -------------------------------------------------------------------------------- 1 | import "./start"; 2 | import "./permissions"; 3 | import "./autoexpand"; 4 | import "./lock"; 5 | import "./changelog"; 6 | import "./source"; 7 | -------------------------------------------------------------------------------- /commands/lock.ts: -------------------------------------------------------------------------------- 1 | import { bot } from ".."; 2 | import { showBotActivity } from "../actions/show-bot-activity"; 3 | import { createSettings, getSettings } from "../helpers/api"; 4 | import { notifyAdmin } from "../helpers/notifier"; 5 | import { lockSettingsTemplate } from "../helpers/templates"; 6 | import { deleteMessage } from "../actions/delete-message"; 7 | import { Context } from "grammy"; 8 | import { trackEvent } from "../helpers/analytics"; 9 | import { isBanned } from "../helpers/banned"; 10 | import { checkAdminStatus } from "../helpers/admin"; 11 | 12 | /** 13 | * Manage locking settings 14 | */ 15 | bot.command("lock", async (ctx: Context) => { 16 | const msg = ctx.update.message; 17 | const msgId = msg?.message_id; 18 | const chatId = msg?.chat.id; 19 | const topicId = ctx.msg?.message_thread_id; 20 | 21 | // Discard malformed messages 22 | if (!msgId || !chatId) return; 23 | if (isBanned(chatId)) return; 24 | 25 | const [settings, isAdmin] = await Promise.all([getSettings(chatId), checkAdminStatus(ctx)]); 26 | if (!isAdmin && settings?.settings_lock) { 27 | return await bot.api 28 | .sendMessage(chatId, "You need to be an admin to use the Lock command.", { 29 | message_thread_id: topicId ?? undefined, 30 | disable_notification: true, 31 | }) 32 | .catch(() => { 33 | console.error(`[Error] [lock.ts:35] Failed to send message.`); 34 | return; 35 | }); 36 | } 37 | 38 | try { 39 | showBotActivity(ctx, chatId); 40 | 41 | if (settings) { 42 | deleteMessage(chatId, msgId); 43 | // Reply with template and buttons to control changelog settings 44 | await bot.api 45 | .sendMessage(chatId, lockSettingsTemplate(settings.settings_lock), { 46 | message_thread_id: topicId ?? undefined, 47 | parse_mode: "MarkdownV2", 48 | disable_notification: true, 49 | reply_markup: { 50 | inline_keyboard: [ 51 | [ 52 | { 53 | text: settings.settings_lock ? "🔓 Unlock" : "🔒 Lock", 54 | callback_data: `lock:${settings.settings_lock ? "off" : "on"}`, 55 | }, 56 | { 57 | text: "✨ Done", 58 | callback_data: "lock:done", 59 | }, 60 | ], 61 | ], 62 | }, 63 | }) 64 | .catch(() => { 65 | console.error(`[Error] [changelog.ts:51] Failed to send settings_lock template.`); 66 | return; 67 | }); 68 | } else { 69 | deleteMessage(chatId, msgId); 70 | // Create default settings for this chat 71 | createSettings(chatId, false, true, false); 72 | // Reply with template and buttons to control settings_lock (default: off) 73 | await ctx.api 74 | .sendMessage(chatId, lockSettingsTemplate(true), { 75 | message_thread_id: topicId ?? undefined, 76 | parse_mode: "MarkdownV2", 77 | disable_notification: true, 78 | reply_markup: { 79 | inline_keyboard: [ 80 | [ 81 | { 82 | text: "🔒 Lock", 83 | callback_data: `lock:on`, 84 | }, 85 | { 86 | text: "✨ Done", 87 | callback_data: "lock:done", 88 | }, 89 | ], 90 | ], 91 | }, 92 | }) 93 | .catch(() => { 94 | console.error(`[Error] [changelog.ts:79] Failed to send changelog settings template.`); 95 | return; 96 | }); 97 | } 98 | } catch (error: any) { 99 | console.error(error); 100 | notifyAdmin(error); 101 | return; 102 | } 103 | 104 | trackEvent("command.lock"); 105 | }); 106 | -------------------------------------------------------------------------------- /commands/permissions.ts: -------------------------------------------------------------------------------- 1 | import { bot } from ".."; 2 | import { Context } from "grammy"; 3 | import { trackEvent } from "../helpers/analytics"; 4 | import { deleteMessage } from "../actions/delete-message"; 5 | import { showBotActivity } from "../actions/show-bot-activity"; 6 | import { handleMissingPermissions } from "../actions/missing-permissions"; 7 | import { isBanned } from "../helpers/banned"; 8 | 9 | bot.command("permissions", async (ctx: Context) => { 10 | if (!ctx.msg) return; 11 | 12 | try { 13 | const chatId = ctx?.msg?.chat.id; 14 | const msgId = ctx?.msg?.message_id; 15 | 16 | if (isBanned(chatId)) return; 17 | 18 | showBotActivity(ctx, chatId); 19 | deleteMessage(chatId, msgId); 20 | handleMissingPermissions(ctx, true); 21 | } catch (error) { 22 | console.error(`[Error] Cannot send permissions message.`, error); 23 | return; 24 | } 25 | 26 | trackEvent("command.permissions"); 27 | }); 28 | -------------------------------------------------------------------------------- /commands/source.ts: -------------------------------------------------------------------------------- 1 | import { bot } from ".."; 2 | import { Context } from "grammy"; 3 | import { trackEvent } from "../helpers/analytics"; 4 | import { deleteMessage } from "../actions/delete-message"; 5 | import { showBotActivity } from "../actions/show-bot-activity"; 6 | import { isBanned } from "../helpers/banned"; 7 | 8 | bot.command("source", async (ctx: Context) => { 9 | if (!ctx.msg) return; 10 | 11 | try { 12 | const chatId = ctx?.msg?.chat.id; 13 | const msgId = ctx?.msg?.message_id; 14 | const topicId = ctx.msg?.message_thread_id; 15 | 16 | if (isBanned(chatId)) return; 17 | 18 | showBotActivity(ctx, chatId); 19 | deleteMessage(chatId, msgId); 20 | ctx.reply( 21 | `This bot’s source code is available here: https://github.com/pugson/telegram-twitter-url-expand-bot 22 | 23 | For feature requests and bug reports please open an issue on GitHub. 24 | `, 25 | { 26 | message_thread_id: topicId ?? undefined, 27 | } 28 | ); 29 | } catch (error) { 30 | console.error(`[Error] Cannot send source message.`, error); 31 | return; 32 | } 33 | 34 | trackEvent("command.sourceCode"); 35 | }); 36 | -------------------------------------------------------------------------------- /commands/start.ts: -------------------------------------------------------------------------------- 1 | import { bot } from ".."; 2 | import { Context } from "grammy"; 3 | import { trackEvent } from "../helpers/analytics"; 4 | import { deleteMessage } from "../actions/delete-message"; 5 | import { showBotActivity } from "../actions/show-bot-activity"; 6 | import { isBanned } from "../helpers/banned"; 7 | import { notifyAdmin } from "../helpers/notifier"; 8 | 9 | bot.command("start", async (ctx: Context) => { 10 | if (!ctx.msg) return; 11 | 12 | try { 13 | // This needs to be wrapped in try/catch because someone can block the bot 14 | // and it will throw an error that prevents the bot from starting since it’s the entry command. 15 | const chatId = ctx?.msg?.chat.id; 16 | const msgId = ctx?.msg?.message_id; 17 | const privateChat = ctx?.msg?.chat.type === "private"; 18 | const topicId = ctx.msg?.message_thread_id; 19 | 20 | if (isBanned(chatId)) return; 21 | 22 | showBotActivity(ctx, chatId); 23 | deleteMessage(chatId, msgId); 24 | ctx 25 | .reply( 26 | `👋 Hello! I’m a bot that expands Twitter, Instagram, TikTok, Reddit, Spotify, Hacker News, Dribbble,and Posts․cv URLs. Send me a link and I’ll expand it for you. 🔗🖼️ 27 | 28 | Commands: 29 | /autoexpand - Configure link expanding 30 | /changelog - Configure receiving changelog updates 31 | 32 | You can also add me to your channel and I will edit messages with links to expand them automatically. 33 | `, 34 | privateChat 35 | ? { 36 | message_thread_id: topicId ?? undefined, 37 | reply_markup: { 38 | inline_keyboard: [ 39 | [ 40 | { 41 | text: "Add me to your group (if you’re an admin)", 42 | url: "tg://resolve?domain=TwitterLinkExpanderBot&startgroup&admin=delete_messages", 43 | }, 44 | ], 45 | [ 46 | { 47 | text: "Add me to your group (if you’re a member)", 48 | url: "tg://resolve?domain=TwitterLinkExpanderBot&startgroup", 49 | }, 50 | ], 51 | [ 52 | { 53 | text: "Add me to your channel", 54 | url: "tg://resolve?domain=TwitterLinkExpanderBot&startchannel&admin=edit_messages", 55 | }, 56 | ], 57 | ], 58 | }, 59 | } 60 | : { 61 | message_thread_id: topicId ?? undefined, 62 | } 63 | ) 64 | .catch(() => { 65 | console.error(`[Error] [start.ts:61] Failed to send start message.`); 66 | return; 67 | }); 68 | 69 | trackEvent("command.start"); 70 | } catch (error) { 71 | console.error({ 72 | message: "Error replying to the start command", 73 | error, 74 | }); 75 | 76 | // @ts-ignore 77 | if (error.description.includes("was blocked")) { 78 | const chatId = ctx?.msg?.chat.id; 79 | notifyAdmin(chatId); 80 | } 81 | return; 82 | } 83 | }); 84 | -------------------------------------------------------------------------------- /helpers/admin.ts: -------------------------------------------------------------------------------- 1 | // Thanks to @borodutch for this snippet. 2 | // https://github.com/backmeupplz/grammy-middlewares/blob/main/src/middlewares/onlyAdmin.ts 3 | import { Context } from "grammy"; 4 | 5 | export async function checkAdminStatus(ctx: Context) { 6 | try { 7 | // No chat = no service 8 | if (!ctx.chat) { 9 | return false; 10 | } 11 | // Channels and private chats are only postable by admins 12 | if (["channel", "private"].includes(ctx.chat.type)) { 13 | return true; 14 | } 15 | // Anonymous users are always admins 16 | if (ctx.from && ctx.from.username === "GroupAnonymousBot") { 17 | return true; 18 | } 19 | // Surely not an admin 20 | if (!ctx.from || !ctx.from.id) { 21 | return false; 22 | } 23 | // Check the member status 24 | const chatMember = await ctx.getChatMember(ctx.from.id); 25 | if (["creator", "administrator"].includes(chatMember.status)) { 26 | return true; 27 | } 28 | // Not an admin by default 29 | return false; 30 | } catch (e) { 31 | console.error("[Error] Unable to check admin status."); 32 | console.error(e); 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /helpers/analytics.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | async function createEvent(event: string, timestamp: string, note?: string) { 4 | await axios.post( 5 | process.env.ANALYTICS_ENDPOINT!, 6 | { 7 | event, 8 | timestamp, 9 | note, 10 | }, 11 | { 12 | headers: { 13 | Authorization: `Bearer ${process.env.ANALYTICS_KEY}`, 14 | }, 15 | } 16 | ); 17 | } 18 | 19 | /** 20 | * Sends an anonymous event to the server. 21 | * @param event Name to identify the event 22 | * @param note Optional note to add to the event 23 | */ 24 | export const trackEvent = async (event: string, note?: string) => { 25 | const isDev = process.env.DEV; 26 | const extraNote = isDev ? "DEV" : note; 27 | 28 | try { 29 | const timestamp = new Date().toISOString(); 30 | await createEvent(event, timestamp, extraNote); 31 | } catch (error) { 32 | console.error(error); 33 | return; 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /helpers/api.ts: -------------------------------------------------------------------------------- 1 | import fetch from "isomorphic-unfetch"; 2 | import { Chats, getXataClient } from "./xata"; 3 | 4 | // @ts-ignore 5 | globalThis.fetch = fetch; 6 | 7 | const xata = getXataClient(); 8 | 9 | /** 10 | * Get chat settings from the database. 11 | * @param chatId Telegram Chat ID 12 | * @returns Chat settings record 13 | */ 14 | export const getSettings = async (chatId: number) => { 15 | try { 16 | console.log("Getting settings for chat ID:", chatId); 17 | const record = await xata.db.chats 18 | .filter({ 19 | chat_id: chatId.toString(), 20 | }) 21 | .getFirst({ 22 | // cache: 1 * 60 * 1000, // TTL: 1 minute 23 | }); 24 | 25 | return record; 26 | } catch (error) { 27 | console.error(error); 28 | } 29 | }; 30 | 31 | /** 32 | * Create a new chat settings record in the database. 33 | * @param chatId Telegram Chat ID 34 | * @param autoexpandValue Autoexpand value boolean 35 | * @param changelogValue Changelog value boolean 36 | * @param settingsLockValue Settings lock value boolean 37 | * @returns Chat settings record 38 | */ 39 | export const createSettings = async ( 40 | chatId: number, 41 | autoexpandValue: boolean, 42 | changelogValue: boolean, 43 | settingsLockValue: boolean 44 | ) => { 45 | try { 46 | console.log("Creating settings for chat ID:", chatId); 47 | const record = await xata.db.chats.create({ 48 | chat_id: chatId.toString(), 49 | autoexpand: autoexpandValue, 50 | changelog: changelogValue, 51 | settings_lock: settingsLockValue, 52 | }); 53 | 54 | return record; 55 | } catch (error) { 56 | console.error(error); 57 | } 58 | }; 59 | 60 | /** 61 | * Update settings for this chat in the database. 62 | * @param id Telegram Chat ID 63 | * @param property Column name 64 | * @param value New value 65 | * @returns 66 | */ 67 | export const updateSettings = async (id: number, property: keyof Chats, value: Chats[keyof Chats]) => { 68 | try { 69 | console.log("Updating settings for chat ID:", id); 70 | const record = await xata.db.chats 71 | .filter({ chat_id: id.toString() }) 72 | .getFirst() 73 | .then((record) => { 74 | if (record) { 75 | record.update({ 76 | [`${property}`]: value, 77 | }); 78 | } else { 79 | console.warn("[Error] Unable to get records. No settings found for chat ID:", id); 80 | } 81 | }); 82 | 83 | return record; 84 | } catch (error) { 85 | console.error(error); 86 | } 87 | }; 88 | -------------------------------------------------------------------------------- /helpers/banned.ts: -------------------------------------------------------------------------------- 1 | import * as dotenv from "dotenv"; 2 | dotenv.config(); 3 | 4 | // List of malicious chats that were trying to crash the bot. 5 | const banList: number[] = [ 6 | 1947938299, -1001226058268, -1002124315683, -1001149568794, -1001493829609, 6908519864, -1001859238543, 7 | -1001709570096, -1002092544541, -1001998434278, -1001270461188, -1002120182372, 132539597, 5153608517, -1001142717501, 8 | -1001895119273, 6414405787, 2003350723, 829781933, 6164550093, -1001973927780, -1001863770641, -1002061175932, 9 | 1606851084, -1002091775588, -1001930094542, -1001857512657, -1002045266906, -1001538336813, 6650455873, 5870000919, 10 | 1612412747, -1001288121000, -1002030679797, -1001793155472, 1305106216, -1001198539389, -1001660176192, 11 | -1001509541800, -1001558911950, -1001464431621, 884080644, -1001181251587, -1001209627964, -1001638603048, 12 | -1001674636939, -1001532098446, 6445073861, 7447377344, 13 | ]; 14 | 15 | export const isBanned = (chatId: number) => banList.includes(Number(chatId)); 16 | -------------------------------------------------------------------------------- /helpers/button-states.ts: -------------------------------------------------------------------------------- 1 | import { InlineKeyboardButton } from "@grammyjs/types"; 2 | 3 | type Platform = "twitter" | "instagram" | "tiktok" | "reddit" | "instagram-share"; 4 | 5 | type ButtonState = { 6 | buttons: InlineKeyboardButton[][]; 7 | nextTimeout: number | null; 8 | }; 9 | 10 | /** 11 | * Get button state for a platform based on time remaining 12 | * @param platform Platform (twitter, instagram, tiktok, reddit) 13 | * @param timeRemaining Time remaining in seconds, or null for final state 14 | * @param userId User ID for analytics 15 | * @param url URL to open 16 | * @returns Button state with buttons and next timeout 17 | */ 18 | export function getButtonState( 19 | platform: Platform, 20 | timeRemaining: number | null, 21 | userId: number, 22 | url: string 23 | ): ButtonState { 24 | const platformName = 25 | platform === "twitter" 26 | ? "Twitter" 27 | : platform.includes("instagram") 28 | ? "Instagram" 29 | : platform === "tiktok" 30 | ? "TikTok" 31 | : platform === "reddit" 32 | ? "Reddit" 33 | : "..."; 34 | const baseButtons: InlineKeyboardButton[] = [ 35 | { 36 | text: `🔗 Open on ${platformName}`, 37 | url, 38 | }, 39 | ]; 40 | 41 | // Final state - just show open button 42 | if (timeRemaining === null) { 43 | return { 44 | buttons: [baseButtons], 45 | nextTimeout: null, 46 | }; 47 | } 48 | 49 | // Add undo button if not in final state 50 | const buttonsWithUndo = [ 51 | { 52 | text: "↩️ Undo", 53 | callback_data: "undo", 54 | }, 55 | ...baseButtons, 56 | ]; 57 | 58 | // If we have time remaining, add countdown 59 | if (timeRemaining > 0) { 60 | return { 61 | buttons: [ 62 | [ 63 | { 64 | text: `❌ Delete ${timeRemaining}s`, 65 | callback_data: `destruct:${userId}:${timeRemaining}`, 66 | }, 67 | ...buttonsWithUndo, 68 | ], 69 | ], 70 | nextTimeout: timeRemaining === 15 ? 10 : timeRemaining === 10 ? 5 : 0, 71 | }; 72 | } 73 | 74 | // No time remaining but not final state 75 | return { 76 | buttons: [buttonsWithUndo], 77 | nextTimeout: null, 78 | }; 79 | } 80 | -------------------------------------------------------------------------------- /helpers/cache.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import NodeCache from "node-cache"; 3 | 4 | const memoryCache = new NodeCache({ 5 | // Store message Context in memory for a longer duration 6 | // if necessary, otherwise the button to expand links 7 | // will not work if the message has expired from cache. 8 | stdTTL: 60 * 60 * 8, // 8 hours 9 | // Most of the time, the message will be cached only 10 | // for a few seconds while the bot is processing it, 11 | // or when the user is in the process of clicking 12 | // the button that expands links in the message. 13 | checkperiod: 300, // Check for expired keys every 5 minutes 14 | maxKeys: 1000, // Max 1000 items in cache 15 | deleteOnExpire: true, 16 | }); 17 | 18 | // Add cache stats logging every hour 19 | setInterval(() => { 20 | const stats = memoryCache.getStats(); 21 | console.log("[Cache Stats]", { 22 | keys: stats.keys, 23 | hits: stats.hits, 24 | misses: stats.misses, 25 | ksize: stats.ksize, 26 | vsize: stats.vsize, 27 | }); 28 | }, 60 * 60 * 1000); 29 | 30 | /** 31 | * Cache messages in memory to be able to process them later. 32 | * This is required to make manual link expanding work, because 33 | * Telegram does not allow bots to look up messages by Chat ID 34 | * and Message ID. Only way to do that is to save the message 35 | * Context to in-memory cache, look it up later when responding 36 | * to a callback event and immediately delete it from cache 37 | * when the operation is complete. 38 | * 39 | * - Only messages with matching links that can be expanded are cached. 40 | * - Messages are not logged anywhere. 41 | * - Messages are not stored in a database. 42 | * - Messages are not sent to any external servers. 43 | * - No one has access to the cache other than the bot when it’s running. 44 | * - Cache is cleared when the bot is stopped or restarted. 45 | * - Cache is not persisted to disk. 46 | * - Your data is private and secure. 47 | * 48 | * @param key Unique identifier for the message (chatId:messageId:linkIndex) 49 | * @param value Telegram Context 50 | */ 51 | export async function saveToCache(key: string, value: Context) { 52 | return memoryCache.set(key, value); 53 | } 54 | 55 | /** 56 | * Read message from in-memory cache for processing. 57 | * @param key Unique identifier for the message (chatId:messageId:linkIndex) 58 | * @returns Telegram Context 59 | */ 60 | export async function getFromCache(key: string) { 61 | return memoryCache.take(key); 62 | } 63 | 64 | /** 65 | * Read message from in-memory cache without removing it. 66 | * @param key Unique identifier for the message (chatId:messageId:linkIndex) 67 | * @returns Telegram Context 68 | */ 69 | export async function peekFromCache(key: string) { 70 | return memoryCache.get(key); 71 | } 72 | 73 | /** 74 | * Delete message from in-memory cache immediately. 75 | * @param key Unique identifier for the message (chatId:messageId:linkIndex) 76 | */ 77 | export async function deleteFromCache(key: string) { 78 | return memoryCache.del(key); 79 | } 80 | 81 | /** 82 | * Check if message exists inside in-memory cache. 83 | * @param key Unique identifier for the message (chatId:messageId:linkIndex) 84 | * @returns boolean 85 | */ 86 | export async function checkIfCached(key: string) { 87 | return memoryCache.has(key); 88 | } 89 | -------------------------------------------------------------------------------- /helpers/hacker-news-metadata.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | export const getHackerNewsMetadata = async (postId: string | undefined) => { 4 | if (!postId) return; 5 | 6 | try { 7 | const response = await axios.get(`https://hn-metadata-api.vercel.app/${postId}`); 8 | return response.data; 9 | } catch (error) { 10 | console.error(error); 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /helpers/instagram-share.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | interface MetadataResponse { 4 | data: { 5 | url: string; 6 | [key: string]: any; 7 | }; 8 | } 9 | 10 | /** 11 | * Resolves an Instagram share link to its full URL 12 | * @param shareUrl Instagram share URL to resolve 13 | * @returns Resolved Instagram URL with original instagram.com domain 14 | */ 15 | export async function resolveInstagramShare(shareUrl: string): Promise { 16 | try { 17 | // Ensure the URL ends with a trailing slash to avoid unnecessary redirects 18 | // (e.g., "https://www.instagram.com/share/xxx" might redirect to "https://www.instagram.com/share/xxx/"). 19 | const normalizedShareUrl = shareUrl.replace(/\/?$/, '/'); 20 | 21 | const response = await axios.get( 22 | `https://og.metadata.vision/${encodeURIComponent(normalizedShareUrl)}` 23 | ); 24 | 25 | if (response.data?.data?.url) { 26 | return response.data.data.url; 27 | } 28 | 29 | return null; 30 | } catch (error) { 31 | if (axios.isAxiosError(error)) { 32 | console.error("[Error] Failed to resolve Instagram share URL:", { 33 | status: error.response?.status, 34 | statusText: error.response?.statusText, 35 | url: shareUrl 36 | }); 37 | } else { 38 | console.error("[Error] Unexpected error resolving Instagram share URL:", error); 39 | } 40 | return null; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /helpers/link-regex.ts: -------------------------------------------------------------------------------- 1 | /** This regex will match the following URL structures: 2 | * 3 | * Twitter (and x.com) status URLs, in the format: 4 | - https://www.twitter.com/username/status/status_id 5 | - https://twitter.com/username/status/status_id 6 | - https://mobile.twitter.com/username/status/status_id 7 | - https://mobile.twitter.com/username/statuses/status_id 8 | - https://www.twitter.com/username/statuses/status_id 9 | 10 | * Instagram post URLs, in the format: 11 | - https://mobile.instagram.com/p/post_id 12 | - https://www.instagram.com/stories/username/post_id 13 | - https://www.instagram.com/p/post_id 14 | - https://www.instagram.com/reel/post_id 15 | - https://instagram.com/p/post_id 16 | - https://instagram.com/reel/post_id 17 | - https://mobile.instagram.com/reel/post_id 18 | 19 | * TikTok video URLs, in the format: 20 | - https://www.tiktok.com/@username/video/video_id 21 | - https://tiktok.com/@username/video/video_id 22 | - https://www.tiktok.com/t/video_id 23 | - https://vm.tiktok.com/video_id 24 | - https://id.tiktok.com/video_id 25 | - https://en.tiktok.com/video_id 26 | - https://mobile.tiktok.com/@username/video/video_id 27 | - https://lite.tiktok.com/@username/video/video_id 28 | 29 | * Posts.cv URLs, in the format: 30 | - https://posts.cv/username/post_id 31 | 32 | * Hacker News URLs, in the format: 33 | - https://news.ycombinator.com/item?id=post_id 34 | 35 | * Dribbble URLs, in the format: 36 | - https://dribbble.com/shots/shot_id 37 | 38 | * Bluesky URLs, in the format: 39 | - https://bsky.app/username/post_id 40 | - https://bsky.app/profile/username/post/post_id 41 | 42 | * Reddit URLs, in the format: 43 | - https://www.reddit.com/r/:subreddit/comments/:id/:slug/:comment 44 | - https://reddit.com/r/:subreddit/comments/:id/:slug 45 | - https://reddit.com/r/:subreddit/comments/:id 46 | - https://reddit.com/r/:subreddit/s/:id 47 | - https://reddit.com/:id 48 | 49 | * Spotify URLs, in the format: 50 | - https://open.spotify.com/track/track_id 51 | - https://open.spotify.com/album/album_id 52 | - https://open.spotify.com/playlist/playlist_id 53 | - https://open.spotify.com/artist/artist_id 54 | - https://open.spotify.com/episode/episode_id 55 | - https://open.spotify.com/show/show_id 56 | 57 | */ 58 | export const LINK_REGEX: RegExp = 59 | /https?:\/\/(?:www\.)?(?:mobile\.)?(?:(?:twitter|x)\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)(?:\?.*)?|instagram\.com\/(?:p|reel|reels|share|stories\/[^\/]+)\/([A-Za-z0-9-_]+)(?:\?.*)?|(?:lite\.|www\.|)?tiktok\.com\/(?:@|v\/)?(\w+)\/(video\/)?(\d+)(?:\?.*)?|(?:vm\.|id\.|en\.|lite\.)tiktok\.com\/([A-Za-z0-9-_]+)(?:\?.*)?|www\.tiktok\.com\/(@[\w.-]+\/video\/\d+|v\/\d+|t\/\w+)(?:\?.*)?|posts\.cv\/([A-Za-z0-9_]+)\/([A-Za-z0-9]+)(?:\?.*)?|news\.ycombinator\.com\/item\?id=\d+(?:\?.*)?|dribbble\.com\/shots\/([A-Za-z0-9-_]+)(?:\?.*)?|bsky\.app\/([A-Za-z0-9_]+)\/([A-Za-z0-9]+)(?:\?.*)?|bsky\.app\/profile\/([A-Za-z0-9_]+)\/post\/([A-Za-z0-9]+)(?:\?.*)?|reddit\.com\/(?:r\/[^\/]+\/(?:comments|s)\/[A-Za-z0-9]+(?:\/[^\/]*)?(?:\/[^\/]*)?|[A-Za-z0-9]+)(?:\?.*)?|open\.spotify\.com\/(?:track|album|playlist|episode|show|artist)\/([A-Za-z0-9]+)(?:\?.*)?)/im; 60 | -------------------------------------------------------------------------------- /helpers/notifier.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | /** 4 | * Notify the admin on Telegram when an error occurs. 5 | * @param message Message to send in chat. 6 | * */ 7 | export const notifyAdmin = async (message: any): Promise => { 8 | try { 9 | await axios.post(`https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMessage`, { 10 | chat_id: process.env.ADMIN_TELEGRAM_ID, 11 | text: JSON.stringify(message), 12 | }); 13 | } catch (error) { 14 | console.error(`[Error] Could not send Adming Telegram notification.`); 15 | console.error(error); 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /helpers/og-metadata.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | export const getOGMetadata = async (link: string) => { 4 | if (!link) return; 5 | 6 | try { 7 | const response = await axios.get(`https://og.metadata.vision/${link}`, { 8 | timeout: 60_000, 9 | }); 10 | return response.data.data; 11 | } catch (error) { 12 | console.error(error); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /helpers/platforms.ts: -------------------------------------------------------------------------------- 1 | const checkLink = (link: string, platform: string) => { 2 | const isMatch = link.includes(platform); 3 | return isMatch; 4 | }; 5 | 6 | export const isTweet = (link: string) => checkLink(link, "twitter.com") || checkLink(link, "x.com"); 7 | export const isInstagram = (link: string) => checkLink(link, "instagram.com") && !link.includes("/share/"); 8 | export const isInstagramShare = (link: string) => link.includes("instagram.com/share/"); 9 | export const isTikTok = (link: string) => checkLink(link, "tiktok.com"); 10 | export const isPosts = (link: string) => checkLink(link, "posts.cv"); 11 | export const isHackerNews = (link: string) => checkLink(link, "news.ycombinator.com"); 12 | export const isDribbble = (link: string) => checkLink(link, "dribbble.com"); 13 | export const isBluesky = (link: string) => checkLink(link, "bsky.app"); 14 | export const isReddit = (link: string) => checkLink(link, "reddit.com"); 15 | export const isSpotify = (link: string) => checkLink(link, "open.spotify.com"); 16 | 17 | // Spotify helpers 18 | export const isSpotifyTrack = (link: string) => checkLink(link, "open.spotify.com/track"); 19 | export const isSpotifyAlbum = (link: string) => checkLink(link, "open.spotify.com/album"); 20 | export const isSpotifyPlaylist = (link: string) => checkLink(link, "open.spotify.com/playlist"); 21 | export const isSpotifyArtist = (link: string) => checkLink(link, "open.spotify.com/artist"); 22 | export const isSpotifyEpisode = (link: string) => checkLink(link, "open.spotify.com/episode"); 23 | export const isSpotifyShow = (link: string) => checkLink(link, "open.spotify.com/show"); 24 | -------------------------------------------------------------------------------- /helpers/templates.ts: -------------------------------------------------------------------------------- 1 | //! IMPORTANT ! 2 | //! Indentation and line breaks need to be preserved 3 | //! to display properly in Telegram 4 | 5 | import { Context } from "grammy"; 6 | import { 7 | isBluesky, 8 | isDribbble, 9 | isHackerNews, 10 | isInstagram, 11 | isPosts, 12 | isReddit, 13 | isSpotify, 14 | isSpotifyTrack, 15 | isSpotifyAlbum, 16 | isSpotifyPlaylist, 17 | isSpotifyArtist, 18 | isSpotifyEpisode, 19 | isSpotifyShow, 20 | isTikTok, 21 | } from "./platforms"; 22 | import { getHackerNewsMetadata } from "./hacker-news-metadata"; 23 | import { notifyAdmin } from "./notifier"; 24 | 25 | export const hasPermissionToDeleteMessageTemplate = `✅ I have permissions to automatically delete original messages when expanding links.`; 26 | export const missingPermissionToDeleteMessageTemplate = `🔐 An admin of this chat needs to give me permissions to automatically delete messages when expanding links.`; 27 | 28 | /** 29 | * Message sent when a user sends the /autoexpand command. 30 | * @param enabled 31 | * @returns 32 | */ 33 | export const autoexpandSettingsTemplate = (enabled: boolean) => { 34 | return `Autoexpand is ${enabled ? "✅ *ON*" : "❌ *OFF*"} for this chat\\. 35 | 36 | I will ${ 37 | enabled ? "expand" : "reply to" 38 | } Twitter, Instagram, Bluesky, TikTok, Reddit, Hacker News, Dribbble, and Posts․cv links\\. 39 | 40 | ${ 41 | enabled 42 | ? "Original messages will be automatically deleted after expanding if you gave me admin permissions to delete messages\\. If you write any text in the original message it will be included in my reply\\." 43 | : "Someone will have to click a button to expand each link\\." 44 | }`; 45 | }; 46 | 47 | /** 48 | * Message sent when a user sends the /lock command. 49 | * @param enabled 50 | * @returns 51 | */ 52 | export const lockSettingsTemplate = (locked: boolean) => { 53 | return `Settings lock is ${locked ? "✅ *ON*" : "❌ *OFF*"} for this chat\\. 54 | 55 | As an admin you have the option to lock bot settings to prevent members from changing them\\. 56 | `; 57 | }; 58 | 59 | /** 60 | * Message sent when a user sends the /changelog command. 61 | * @param enabled 62 | */ 63 | export const changelogSettingsTemplate = (enabled: boolean) => { 64 | return `This chat is ${enabled ? "*subscribed* ✅ to" : "*unsubscribed* ❌ from"} changelog messages\\. 65 | 66 | ${ 67 | enabled 68 | ? "When a major update is released, I will post about it here\\." 69 | : "I will not post any release notes in here\\." 70 | } 71 | `; 72 | }; 73 | 74 | /** 75 | * Message sent when a link is detected in chat but autoexpand is disabled. 76 | * @param link 77 | * @returns Expand this (platform)? 78 | */ 79 | export const askToExpandTemplate = (link: string) => { 80 | const insta = isInstagram(link); 81 | const tiktok = isTikTok(link); 82 | const posts = isPosts(link); 83 | const hn = isHackerNews(link); 84 | const dribbble = isDribbble(link); 85 | const bluesky = isBluesky(link); 86 | const reddit = isReddit(link); 87 | const spotify = isSpotify(link); 88 | 89 | if (insta) { 90 | return `Expand this Instagram post?`; 91 | } 92 | 93 | if (tiktok) { 94 | return `Expand this TikTok?`; 95 | } 96 | 97 | if (posts) { 98 | return `Expand this Post?`; 99 | } 100 | 101 | if (hn) { 102 | return `Expand this Hacker News post?`; 103 | } 104 | 105 | if (dribbble) { 106 | return `Expand this Dribbble shot?`; 107 | } 108 | 109 | if (bluesky) { 110 | return `Expand this Bluesky post?`; 111 | } 112 | 113 | if (reddit) { 114 | return `Expand this Reddit post?`; 115 | } 116 | 117 | if (spotify) { 118 | const track = isSpotifyTrack(link); 119 | const album = isSpotifyAlbum(link); 120 | const playlist = isSpotifyPlaylist(link); 121 | const artist = isSpotifyArtist(link); 122 | const episode = isSpotifyEpisode(link); 123 | const show = isSpotifyShow(link); 124 | 125 | if (track) { 126 | return `Expand this Spotify track?`; 127 | } 128 | 129 | if (album) { 130 | return `Expand this Spotify album?`; 131 | } 132 | 133 | if (playlist) { 134 | return `Expand this Spotify playlist?`; 135 | } 136 | 137 | if (artist) { 138 | return `Expand this Spotify artist?`; 139 | } 140 | 141 | if (episode) { 142 | return `Expand this Spotify episode?`; 143 | } 144 | 145 | if (show) { 146 | return `Expand this Spotify show?`; 147 | } 148 | } 149 | 150 | return `Expand this Tweet?`; 151 | }; 152 | 153 | /** 154 | * This is what gets sent in a bot message when a user 155 | * clicks the expand button or the links are autoexpanded. 156 | */ 157 | export const expandedMessageTemplate = async ( 158 | ctx: Context, 159 | username?: string, 160 | userId?: number, 161 | firstName?: string, 162 | lastName?: string, 163 | text?: string, 164 | link?: string 165 | ) => { 166 | // TODO: this function is a clusterfuck of ugly template literals. refactor in the future. 167 | const bothNames = firstName && lastName; 168 | const nameTemplate = bothNames ? `${firstName} ${lastName}` : firstName ?? lastName; 169 | const usernameOrFullNameTag = username ? `@${username}` : `${nameTemplate}`; 170 | const isHackerNewsLink = link ? isHackerNews(link) : false; 171 | let includedLink = link; 172 | 173 | // Replace message template with HN metadata inline 174 | // This is ugly as hell but it works. 175 | if (isHackerNewsLink) { 176 | try { 177 | const hnPostId = link?.split("id=")[1]; 178 | const metadata = await getHackerNewsMetadata(hnPostId); 179 | const { title, user, time_ago, comments_count, url } = metadata.post; 180 | 181 | includedLink = `${title ? title : "Comment"} 182 | ${comments_count} replies | ${time_ago} by ${user} 183 | ${link} 184 | 185 | ${url ? url : ""}`; 186 | } catch (error) { 187 | console.error(error); 188 | notifyAdmin(error); 189 | } 190 | } 191 | 192 | // Check if the original author of the message has a public profile. 193 | // @ts-expect-error forward_from is not defined for Message type 194 | if (ctx.msg?.forward_from) { 195 | // @ts-expect-error forward_from is not defined for Message type 196 | const forwardUserId = ctx.msg?.forward_from?.id; 197 | // @ts-expect-error forward_from is not defined for Message type 198 | const forwardUsername = ctx.msg?.forward_from?.username; 199 | // @ts-expect-error forward_from is not defined for Message type 200 | const forwardFirstName = ctx.msg?.forward_from?.first_name; 201 | // @ts-expect-error forward_from is not defined for Message type 202 | const forwardLastName = ctx.msg?.forward_from?.last_name; 203 | const bothNames = forwardFirstName && forwardLastName; 204 | const nameTemplate = bothNames ? `${forwardFirstName} ${forwardLastName}` : forwardFirstName ?? forwardLastName; 205 | 206 | // Link to the original author by username if they have one. 207 | if (forwardUsername) { 208 | return `Forwarded from @${forwardUsername} by ${usernameOrFullNameTag} 209 | ${text} 210 | 211 | ${includedLink}`; 212 | } 213 | 214 | // Link to the original author by ID if they don’t have a username. 215 | return `Forwarded from ${nameTemplate} by ${usernameOrFullNameTag} 216 | ${text} 217 | 218 | ${includedLink}`; 219 | } 220 | 221 | // Check if the original author of the message has a private profile. 222 | // @ts-expect-error forward_sender_name is not defined for Message type 223 | if (ctx.msg?.forward_sender_name) { 224 | // @ts-expect-error forward_sender_name is not defined for Message type 225 | return `Forwarded from ${ctx.msg?.forward_sender_name} by ${usernameOrFullNameTag} 226 | ${text} 227 | 228 | ${includedLink}`; 229 | } 230 | 231 | // Check if the original author of the message is a channel. 232 | // @ts-expect-error forward_from_chat is not defined for Message type 233 | if (ctx.msg?.forward_from_chat) { 234 | // @ts-ignore 235 | const forwardName = ctx.msg?.forward_from_chat?.title; 236 | // @ts-ignore 237 | const forwardUsername = ctx.msg?.forward_from_chat?.username; 238 | 239 | // Link to the original channel by username if they have one. 240 | if (forwardUsername) { 241 | return `Forwarded from @${forwardUsername} by ${usernameOrFullNameTag} 242 | ${text} 243 | 244 | ${includedLink}`; 245 | } 246 | 247 | // Make the channel name italic if they don’t have a username. 248 | return `Forwarded from ${forwardName} by ${usernameOrFullNameTag} 249 | ${text} 250 | 251 | ${includedLink}`; 252 | } 253 | 254 | // If the message was not forwarded, handle it normally. 255 | return `${usernameOrFullNameTag} 💬 ${text} 256 | 257 | ${includedLink}`; 258 | }; 259 | -------------------------------------------------------------------------------- /helpers/xata.ts: -------------------------------------------------------------------------------- 1 | // Generated by Xata Codegen 0.30.1. Please do not edit. 2 | import { buildClient } from "@xata.io/client"; 3 | import type { BaseClientOptions, SchemaInference, XataRecord } from "@xata.io/client"; 4 | 5 | const tables = [ 6 | { 7 | name: "chats", 8 | columns: [ 9 | { name: "chat_id", type: "string", unique: true }, 10 | { 11 | name: "autoexpand", 12 | type: "bool", 13 | notNull: true, 14 | defaultValue: "false", 15 | }, 16 | { name: "chat_size", type: "int" }, 17 | { name: "changelog", type: "bool", notNull: true, defaultValue: "true" }, 18 | { 19 | name: "ignore_permissions_warning", 20 | type: "bool", 21 | notNull: true, 22 | defaultValue: "false", 23 | }, 24 | { 25 | name: "settings_lock", 26 | type: "bool", 27 | notNull: true, 28 | defaultValue: "false", 29 | }, 30 | ], 31 | }, 32 | ] as const; 33 | 34 | export type SchemaTables = typeof tables; 35 | export type InferredTypes = SchemaInference; 36 | 37 | export type Chats = InferredTypes["chats"]; 38 | export type ChatsRecord = Chats & XataRecord; 39 | 40 | export type DatabaseSchema = { 41 | chats: ChatsRecord; 42 | }; 43 | 44 | const DatabaseClient = buildClient(); 45 | 46 | const defaultOptions = { 47 | databaseURL: process.env.XATA_DB_URL, 48 | }; 49 | 50 | export class XataClient extends DatabaseClient { 51 | constructor(options?: BaseClientOptions) { 52 | super({ ...defaultOptions, ...options }, tables); 53 | } 54 | } 55 | 56 | let instance: XataClient | undefined = undefined; 57 | 58 | export const getXataClient = () => { 59 | if (instance) return instance; 60 | 61 | instance = new XataClient(); 62 | return instance; 63 | }; 64 | -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | import { Bot as TelegramBot } from "grammy"; 2 | import { notifyAdmin } from "./helpers/notifier"; 3 | import * as dotenv from "dotenv"; 4 | import { errorHandler } from "./middleware/error-handler"; 5 | dotenv.config(); 6 | 7 | if (!process.env.TELEGRAM_BOT_TOKEN) { 8 | throw new Error("TELEGRAM_BOT_TOKEN env variable is not defined"); 9 | } 10 | 11 | export const bot = new TelegramBot(process.env.TELEGRAM_BOT_TOKEN); 12 | 13 | // Catch all errors with middleware 14 | bot.catch(errorHandler); 15 | 16 | try { 17 | bot.api.setMyCommands([ 18 | { 19 | command: "autoexpand", 20 | description: "Manage link autoexpand settings for this chat.", 21 | }, 22 | { 23 | command: "lock", 24 | description: "[Admin] Lock / unlock bot settings for this chat.", 25 | }, 26 | { 27 | command: "changelog", 28 | description: "Manage changelog settings for this chat.", 29 | }, 30 | { 31 | command: "permissions", 32 | description: "Check if the bot has needed permissions.", 33 | }, 34 | { 35 | command: "source", 36 | description: "Check the source code of this bot on GitHub.", 37 | }, 38 | ]); 39 | } catch (error) { 40 | console.error("[Error] Could not set bot commands.", error); 41 | notifyAdmin(error); 42 | } 43 | 44 | // Import all listeners from their index files 45 | import "./link-listener"; 46 | import "./link-listener-channel"; 47 | import "./commands"; 48 | import "./callbacks"; 49 | 50 | bot.start().catch((error) => { 51 | console.error("[Error] Could not start bot.", error); 52 | notifyAdmin(error); 53 | }); 54 | 55 | console.info("[ Bot started... ]"); 56 | notifyAdmin(`[ Bot started... ]`); 57 | -------------------------------------------------------------------------------- /link-listener-channel.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { bot } from "."; 3 | import { LINK_REGEX } from "./helpers/link-regex"; 4 | import { isDribbble, isInstagram, isPosts, isReddit, isTikTok } from "./helpers/platforms"; 5 | import { trackEvent } from "./helpers/analytics"; 6 | import { isBanned } from "./helpers/banned"; 7 | 8 | bot.on("channel_post::url", async (ctx: Context) => { 9 | const post = ctx.update.channel_post; 10 | const caption = post?.caption; 11 | const message = post?.text ?? caption ?? ""; 12 | 13 | if (ctx && ctx.chat && isBanned(ctx.chat?.id)) return; 14 | if (!LINK_REGEX.test(message)) return; 15 | 16 | const platform = isInstagram(message) 17 | ? "instagram" 18 | : isTikTok(message) 19 | ? "tiktok" 20 | : isPosts(message) 21 | ? "posts" 22 | : isDribbble(message) 23 | ? "dribbble" 24 | : isReddit(message) 25 | ? "reddit" 26 | : "twitter"; 27 | const expandedLinksMessage = message 28 | .replace("twitter.com/", "fxtwitter.com/") 29 | .replace("x.com/", "fxtwitter.com/") 30 | .replace("instagram.com/", "kkinstagram.com/") 31 | .replace("lite.tiktok.com/", "tfxktok.com/") 32 | .replace("tiktok.com/", "tfxktok.com/") 33 | .replace("posts.cv/", "postscv.com/") 34 | .replace("dribbble.com/", "dribbbletv.com/") 35 | .replace("reddit.com/", "rxddit.com/"); 36 | 37 | try { 38 | if (caption) { 39 | await ctx 40 | .editMessageCaption({ 41 | caption: expandedLinksMessage, 42 | }) 43 | .catch(() => { 44 | console.error("[Error1] Channel message cannot be edited."); 45 | return; 46 | }); 47 | trackEvent(`edit.channel.caption`); 48 | } else { 49 | await ctx.editMessageText(expandedLinksMessage).catch(() => { 50 | console.error("[Error2] Channel message cannot be edited."); 51 | return; 52 | }); 53 | trackEvent(`edit.channel.message`); 54 | } 55 | 56 | trackEvent(`expand.channel.${platform}`); 57 | } catch (error) { 58 | console.error("[Error] Channel message cannot be edited."); 59 | return; 60 | } 61 | }); 62 | -------------------------------------------------------------------------------- /link-listener.ts: -------------------------------------------------------------------------------- 1 | import { Context } from "grammy"; 2 | import { bot } from "."; 3 | import { askToExpand } from "./actions/ask-to-expand"; 4 | import { saveToCache } from "./helpers/cache"; 5 | import { LINK_REGEX } from "./helpers/link-regex"; 6 | import { createSettings, getSettings } from "./helpers/api"; 7 | import { expandLink } from "./actions/expand-link"; 8 | import { deleteMessage } from "./actions/delete-message"; 9 | import { 10 | isDribbble, 11 | isHackerNews, 12 | isInstagram, 13 | isInstagramShare, 14 | isPosts, 15 | isReddit, 16 | isSpotify, 17 | isTikTok, 18 | } from "./helpers/platforms"; 19 | import { trackEvent } from "./helpers/analytics"; 20 | import { showBotActivity } from "./actions/show-bot-activity"; 21 | import { isBanned } from "./helpers/banned"; 22 | 23 | bot.on("message::url", async (ctx: Context) => { 24 | if (!ctx.msg) return; 25 | // User context 26 | const userInfo = { 27 | username: ctx.from?.username, 28 | firstName: ctx.from?.first_name, 29 | lastName: ctx.from?.last_name, 30 | userId: ctx.from?.id, 31 | }; 32 | 33 | // Message context 34 | const chatId = ctx.msg?.chat.id; 35 | 36 | if (isBanned(chatId)) return; 37 | 38 | const msgId = ctx.msg?.message_id; 39 | const isDeletable = !ctx.msg?.caption; // deletable if not a caption of media 40 | const entities = ctx.entities(); // all links in message 41 | const message = ctx.msg?.text ?? ctx.msg?.caption ?? ""; // text or caption 42 | 43 | // Get autoexpand settings for this chat 44 | const settings = await getSettings(chatId); 45 | const autoexpand = settings?.autoexpand; 46 | 47 | // Create default settings for this chat if they don’t exist 48 | if (!settings) { 49 | await createSettings(chatId, false, true, false); 50 | } 51 | 52 | // Loop through all links in message 53 | entities.forEach(async (entity, index) => { 54 | const url = entity.text; 55 | const matchingLink = LINK_REGEX.test(url); 56 | 57 | // Ignore if not a link from supported sites 58 | if (!matchingLink) return; 59 | 60 | const messageWithNoLinks = entities.reduce((msg, e) => { 61 | if (e.type === "url" && e.text === url) { 62 | return msg.replace(e.text, ""); 63 | } 64 | return msg; 65 | }, message); 66 | 67 | showBotActivity(ctx, chatId); 68 | const identifier = `${ctx.msg?.chat?.id}:${ctx.msg?.message_id}:${index}`; 69 | 70 | if (autoexpand) { 71 | // Expand link automatically with provided context 72 | await expandLink(ctx, url, messageWithNoLinks, userInfo, "auto"); 73 | // Delete message if it’s not a caption 74 | if (isDeletable) deleteMessage(chatId, msgId, ctx); 75 | 76 | // Track autoexpand event and platform 77 | const insta = isInstagram(url); 78 | const instaShare = isInstagramShare(url); 79 | const tiktok = isTikTok(url); 80 | const posts = isPosts(url); 81 | const hn = isHackerNews(url); 82 | const dribbble = isDribbble(url); 83 | const reddit = isReddit(url); 84 | const spotify = isSpotify(url); 85 | const platform = insta 86 | ? "instagram" 87 | : instaShare 88 | ? "instagram-share" 89 | : tiktok 90 | ? "tiktok" 91 | : posts 92 | ? "posts" 93 | : hn 94 | ? "hackernews" 95 | : dribbble 96 | ? "dribbble" 97 | : reddit 98 | ? "reddit" 99 | : spotify 100 | ? "spotify" 101 | : "twitter"; 102 | trackEvent(`expand.auto.${platform}`); 103 | } else { 104 | // Save message context to cache then ask to expand 105 | await saveToCache(identifier, ctx); 106 | await askToExpand(ctx, identifier, url, isDeletable); 107 | } 108 | }); 109 | }); 110 | -------------------------------------------------------------------------------- /middleware/error-handler.ts: -------------------------------------------------------------------------------- 1 | import { ErrorHandler } from "grammy"; 2 | import { notifyAdmin } from "../helpers/notifier"; 3 | 4 | /** 5 | * Error handler middleware for the bot 6 | * Catches all errors and prevents them from crashing the bot 7 | */ 8 | export const errorHandler: ErrorHandler = (err) => { 9 | const message = err.message || ""; 10 | 11 | // Known errors that we can safely ignore 12 | if (message.includes("message to edit not found") || message.includes("message is not modified")) { 13 | console.warn("[Warning] Expected error:", message); 14 | return; 15 | } 16 | 17 | // Log unexpected errors and notify admin 18 | console.error("[Error] Unexpected error in bot:", err); 19 | notifyAdmin(`Unexpected error in bot: ${err.message}`).catch(console.error); 20 | }; 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "telegram-twitter-url-expand-bot", 3 | "version": "4.12.7", 4 | "description": "Replaces Twitter, Instagram, Bluesky, TikTok, Reddit, Spotify, Hacker News links in Telegram chats + channels with an expanded preview and inline video.", 5 | "main": "index.ts", 6 | "repository": "https://github.com/pugson/telegram-twitter-url-expand-bot.git", 7 | "author": "pugson ", 8 | "dependencies": { 9 | "@grammyjs/types": "^2.12.1", 10 | "@xata.io/client": "^0.25.2", 11 | "axios": "^1.3.2", 12 | "dotenv": "^16.0.1", 13 | "grammy": "^1.14.1", 14 | "isomorphic-unfetch": "^4.0.2", 15 | "node-cache": "^5.1.2", 16 | "ts-node": "^10.9.1", 17 | "typescript": "^4.9.5" 18 | }, 19 | "scripts": { 20 | "start": "ts-node index.ts", 21 | "dev": "DEV=true ts-node-dev --respawn index.ts", 22 | "dev:debug": "DEV=true DEBUG=\"grammy*\" yarn dev" 23 | }, 24 | "devDependencies": { 25 | "@types/node": "^18.13.0", 26 | "ts-node-dev": "^2.0.0" 27 | }, 28 | "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610" 29 | } 30 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@cspotcode/source-map-support@^0.8.0": 6 | version "0.8.1" 7 | resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" 8 | integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== 9 | dependencies: 10 | "@jridgewell/trace-mapping" "0.3.9" 11 | 12 | "@grammyjs/types@3.19.0": 13 | version "3.19.0" 14 | resolved "https://registry.yarnpkg.com/@grammyjs/types/-/types-3.19.0.tgz#7435f34ca607649b98a6d8c76f364b2067da6293" 15 | integrity sha512-N0MS+RJG+AGSNuka1GWVj88oyK1oti4I0eQq6jGo4hic3P9MwFfnHjGQuIExZ3tlJUrZYwC/T7gk4Tu3+guJyg== 16 | 17 | "@grammyjs/types@^2.12.1": 18 | version "2.12.1" 19 | resolved "https://registry.yarnpkg.com/@grammyjs/types/-/types-2.12.1.tgz#18d021e00928d75c6ee15c520231fd209cdf00b4" 20 | integrity sha512-1hO6esfdo42mSvyArPHrlgSY/fgerTuVNAbSD5ZKHS/w5ZyrkA4pRp3VHK2XE3fm9/uMBT/39i8pPvx0+Kbxjg== 21 | 22 | "@jridgewell/resolve-uri@^3.0.3": 23 | version "3.1.1" 24 | resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721" 25 | integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA== 26 | 27 | "@jridgewell/sourcemap-codec@^1.4.10": 28 | version "1.4.15" 29 | resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" 30 | integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== 31 | 32 | "@jridgewell/trace-mapping@0.3.9": 33 | version "0.3.9" 34 | resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" 35 | integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== 36 | dependencies: 37 | "@jridgewell/resolve-uri" "^3.0.3" 38 | "@jridgewell/sourcemap-codec" "^1.4.10" 39 | 40 | "@tsconfig/node10@^1.0.7": 41 | version "1.0.9" 42 | resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" 43 | integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== 44 | 45 | "@tsconfig/node12@^1.0.7": 46 | version "1.0.11" 47 | resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" 48 | integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== 49 | 50 | "@tsconfig/node14@^1.0.0": 51 | version "1.0.3" 52 | resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" 53 | integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== 54 | 55 | "@tsconfig/node16@^1.0.2": 56 | version "1.0.4" 57 | resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" 58 | integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== 59 | 60 | "@types/node@^18.13.0": 61 | version "18.19.79" 62 | resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.79.tgz#82fde7ac17809f4738a494b22273f0f7e6754f6e" 63 | integrity sha512-90K8Oayimbctc5zTPHPfZloc/lGVs7f3phUAAMcTgEPtg8kKquGZDERC8K4vkBYkQQh48msiYUslYtxTWvqcAg== 64 | dependencies: 65 | undici-types "~5.26.4" 66 | 67 | "@types/strip-bom@^3.0.0": 68 | version "3.0.0" 69 | resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2" 70 | integrity sha512-xevGOReSYGM7g/kUBZzPqCrR/KYAo+F0yiPc85WFTJa0MSLtyFTVTU6cJu/aV4mid7IffDIWqo69THF2o4JiEQ== 71 | 72 | "@types/strip-json-comments@0.0.30": 73 | version "0.0.30" 74 | resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1" 75 | integrity sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ== 76 | 77 | "@xata.io/client@^0.25.2": 78 | version "0.25.3" 79 | resolved "https://registry.yarnpkg.com/@xata.io/client/-/client-0.25.3.tgz#671839cf2ce26e520b61cd9a6656b0652f3843c0" 80 | integrity sha512-JM3FWFRFNG4W+F4PO0jNVf2byMqJP319iH3SrOQh8Hi+AI+WUW2PyNVShCt5cwykjxhJVzeEd9xUnq++HVVdWA== 81 | 82 | abort-controller@^3.0.0: 83 | version "3.0.0" 84 | resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" 85 | integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== 86 | dependencies: 87 | event-target-shim "^5.0.0" 88 | 89 | acorn-walk@^8.1.1: 90 | version "8.3.1" 91 | resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.1.tgz#2f10f5b69329d90ae18c58bf1fa8fccd8b959a43" 92 | integrity sha512-TgUZgYvqZprrl7YldZNoa9OciCAyZR+Ejm9eXzKCmjsF5IKp/wgQ7Z/ZpjpGTIUPwrHQIcYeI8qDh4PsEwxMbw== 93 | 94 | acorn@^8.4.1: 95 | version "8.11.3" 96 | resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" 97 | integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== 98 | 99 | anymatch@~3.1.2: 100 | version "3.1.3" 101 | resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" 102 | integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== 103 | dependencies: 104 | normalize-path "^3.0.0" 105 | picomatch "^2.0.4" 106 | 107 | arg@^4.1.0: 108 | version "4.1.3" 109 | resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" 110 | integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== 111 | 112 | asynckit@^0.4.0: 113 | version "0.4.0" 114 | resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" 115 | integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== 116 | 117 | axios@^1.3.2: 118 | version "1.8.2" 119 | resolved "https://registry.yarnpkg.com/axios/-/axios-1.8.2.tgz#fabe06e241dfe83071d4edfbcaa7b1c3a40f7979" 120 | integrity sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg== 121 | dependencies: 122 | follow-redirects "^1.15.6" 123 | form-data "^4.0.0" 124 | proxy-from-env "^1.1.0" 125 | 126 | balanced-match@^1.0.0: 127 | version "1.0.2" 128 | resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" 129 | integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== 130 | 131 | binary-extensions@^2.0.0: 132 | version "2.2.0" 133 | resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" 134 | integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== 135 | 136 | brace-expansion@^1.1.7: 137 | version "1.1.11" 138 | resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" 139 | integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== 140 | dependencies: 141 | balanced-match "^1.0.0" 142 | concat-map "0.0.1" 143 | 144 | braces@~3.0.2: 145 | version "3.0.2" 146 | resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" 147 | integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== 148 | dependencies: 149 | fill-range "^7.0.1" 150 | 151 | buffer-from@^1.0.0: 152 | version "1.1.2" 153 | resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" 154 | integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== 155 | 156 | call-bind-apply-helpers@^1.0.1, call-bind-apply-helpers@^1.0.2: 157 | version "1.0.2" 158 | resolved "https://registry.yarnpkg.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz#4b5428c222be985d79c3d82657479dbe0b59b2d6" 159 | integrity sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ== 160 | dependencies: 161 | es-errors "^1.3.0" 162 | function-bind "^1.1.2" 163 | 164 | chokidar@^3.5.1: 165 | version "3.5.3" 166 | resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" 167 | integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== 168 | dependencies: 169 | anymatch "~3.1.2" 170 | braces "~3.0.2" 171 | glob-parent "~5.1.2" 172 | is-binary-path "~2.1.0" 173 | is-glob "~4.0.1" 174 | normalize-path "~3.0.0" 175 | readdirp "~3.6.0" 176 | optionalDependencies: 177 | fsevents "~2.3.2" 178 | 179 | clone@2.x: 180 | version "2.1.2" 181 | resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" 182 | integrity sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w== 183 | 184 | combined-stream@^1.0.8: 185 | version "1.0.8" 186 | resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" 187 | integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== 188 | dependencies: 189 | delayed-stream "~1.0.0" 190 | 191 | concat-map@0.0.1: 192 | version "0.0.1" 193 | resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" 194 | integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== 195 | 196 | create-require@^1.1.0: 197 | version "1.1.1" 198 | resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" 199 | integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== 200 | 201 | data-uri-to-buffer@^4.0.0: 202 | version "4.0.1" 203 | resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz#d8feb2b2881e6a4f58c2e08acfd0e2834e26222e" 204 | integrity sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A== 205 | 206 | debug@^4.3.4: 207 | version "4.4.0" 208 | resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" 209 | integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== 210 | dependencies: 211 | ms "^2.1.3" 212 | 213 | delayed-stream@~1.0.0: 214 | version "1.0.0" 215 | resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" 216 | integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== 217 | 218 | diff@^4.0.1: 219 | version "4.0.2" 220 | resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" 221 | integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== 222 | 223 | dotenv@^16.0.1: 224 | version "16.4.7" 225 | resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.7.tgz#0e20c5b82950140aa99be360a8a5f52335f53c26" 226 | integrity sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ== 227 | 228 | dunder-proto@^1.0.1: 229 | version "1.0.1" 230 | resolved "https://registry.yarnpkg.com/dunder-proto/-/dunder-proto-1.0.1.tgz#d7ae667e1dc83482f8b70fd0f6eefc50da30f58a" 231 | integrity sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A== 232 | dependencies: 233 | call-bind-apply-helpers "^1.0.1" 234 | es-errors "^1.3.0" 235 | gopd "^1.2.0" 236 | 237 | dynamic-dedupe@^0.3.0: 238 | version "0.3.0" 239 | resolved "https://registry.yarnpkg.com/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz#06e44c223f5e4e94d78ef9db23a6515ce2f962a1" 240 | integrity sha512-ssuANeD+z97meYOqd50e04Ze5qp4bPqo8cCkI4TRjZkzAUgIDTrXV1R8QCdINpiI+hw14+rYazvTRdQrz0/rFQ== 241 | dependencies: 242 | xtend "^4.0.0" 243 | 244 | es-define-property@^1.0.1: 245 | version "1.0.1" 246 | resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.1.tgz#983eb2f9a6724e9303f61addf011c72e09e0b0fa" 247 | integrity sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g== 248 | 249 | es-errors@^1.3.0: 250 | version "1.3.0" 251 | resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" 252 | integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== 253 | 254 | es-object-atoms@^1.0.0, es-object-atoms@^1.1.1: 255 | version "1.1.1" 256 | resolved "https://registry.yarnpkg.com/es-object-atoms/-/es-object-atoms-1.1.1.tgz#1c4f2c4837327597ce69d2ca190a7fdd172338c1" 257 | integrity sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA== 258 | dependencies: 259 | es-errors "^1.3.0" 260 | 261 | es-set-tostringtag@^2.1.0: 262 | version "2.1.0" 263 | resolved "https://registry.yarnpkg.com/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz#f31dbbe0c183b00a6d26eb6325c810c0fd18bd4d" 264 | integrity sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA== 265 | dependencies: 266 | es-errors "^1.3.0" 267 | get-intrinsic "^1.2.6" 268 | has-tostringtag "^1.0.2" 269 | hasown "^2.0.2" 270 | 271 | event-target-shim@^5.0.0: 272 | version "5.0.1" 273 | resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" 274 | integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== 275 | 276 | fetch-blob@^3.1.2, fetch-blob@^3.1.4: 277 | version "3.2.0" 278 | resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.2.0.tgz#f09b8d4bbd45adc6f0c20b7e787e793e309dcce9" 279 | integrity sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ== 280 | dependencies: 281 | node-domexception "^1.0.0" 282 | web-streams-polyfill "^3.0.3" 283 | 284 | fill-range@^7.0.1: 285 | version "7.0.1" 286 | resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" 287 | integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== 288 | dependencies: 289 | to-regex-range "^5.0.1" 290 | 291 | follow-redirects@^1.15.6: 292 | version "1.15.9" 293 | resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" 294 | integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== 295 | 296 | form-data@^4.0.0: 297 | version "4.0.2" 298 | resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.2.tgz#35cabbdd30c3ce73deb2c42d3c8d3ed9ca51794c" 299 | integrity sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w== 300 | dependencies: 301 | asynckit "^0.4.0" 302 | combined-stream "^1.0.8" 303 | es-set-tostringtag "^2.1.0" 304 | mime-types "^2.1.12" 305 | 306 | formdata-polyfill@^4.0.10: 307 | version "4.0.10" 308 | resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" 309 | integrity sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g== 310 | dependencies: 311 | fetch-blob "^3.1.2" 312 | 313 | fs.realpath@^1.0.0: 314 | version "1.0.0" 315 | resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" 316 | integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== 317 | 318 | fsevents@~2.3.2: 319 | version "2.3.2" 320 | resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" 321 | integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== 322 | 323 | function-bind@^1.1.1: 324 | version "1.1.1" 325 | resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" 326 | integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== 327 | 328 | function-bind@^1.1.2: 329 | version "1.1.2" 330 | resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" 331 | integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== 332 | 333 | get-intrinsic@^1.2.6: 334 | version "1.3.0" 335 | resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz#743f0e3b6964a93a5491ed1bffaae054d7f98d01" 336 | integrity sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ== 337 | dependencies: 338 | call-bind-apply-helpers "^1.0.2" 339 | es-define-property "^1.0.1" 340 | es-errors "^1.3.0" 341 | es-object-atoms "^1.1.1" 342 | function-bind "^1.1.2" 343 | get-proto "^1.0.1" 344 | gopd "^1.2.0" 345 | has-symbols "^1.1.0" 346 | hasown "^2.0.2" 347 | math-intrinsics "^1.1.0" 348 | 349 | get-proto@^1.0.1: 350 | version "1.0.1" 351 | resolved "https://registry.yarnpkg.com/get-proto/-/get-proto-1.0.1.tgz#150b3f2743869ef3e851ec0c49d15b1d14d00ee1" 352 | integrity sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g== 353 | dependencies: 354 | dunder-proto "^1.0.1" 355 | es-object-atoms "^1.0.0" 356 | 357 | glob-parent@~5.1.2: 358 | version "5.1.2" 359 | resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" 360 | integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== 361 | dependencies: 362 | is-glob "^4.0.1" 363 | 364 | glob@^7.1.3: 365 | version "7.2.3" 366 | resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" 367 | integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== 368 | dependencies: 369 | fs.realpath "^1.0.0" 370 | inflight "^1.0.4" 371 | inherits "2" 372 | minimatch "^3.1.1" 373 | once "^1.3.0" 374 | path-is-absolute "^1.0.0" 375 | 376 | gopd@^1.2.0: 377 | version "1.2.0" 378 | resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1" 379 | integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg== 380 | 381 | grammy@^1.14.1: 382 | version "1.35.0" 383 | resolved "https://registry.yarnpkg.com/grammy/-/grammy-1.35.0.tgz#d418e14bdc612b6897259d5793e7d8cfcbac0ff3" 384 | integrity sha512-Qlu5kVaekL4w5clWSpQcRxwJJoEeU13g8DTALuNbZsDAJuFJNXBuI8EqR6U1m1of7j9NEMQz59sXu+0/KsKjyg== 385 | dependencies: 386 | "@grammyjs/types" "3.19.0" 387 | abort-controller "^3.0.0" 388 | debug "^4.3.4" 389 | node-fetch "^2.7.0" 390 | 391 | has-symbols@^1.0.3, has-symbols@^1.1.0: 392 | version "1.1.0" 393 | resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.1.0.tgz#fc9c6a783a084951d0b971fe1018de813707a338" 394 | integrity sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ== 395 | 396 | has-tostringtag@^1.0.2: 397 | version "1.0.2" 398 | resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz#2cdc42d40bef2e5b4eeab7c01a73c54ce7ab5abc" 399 | integrity sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw== 400 | dependencies: 401 | has-symbols "^1.0.3" 402 | 403 | has@^1.0.3: 404 | version "1.0.3" 405 | resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" 406 | integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== 407 | dependencies: 408 | function-bind "^1.1.1" 409 | 410 | hasown@^2.0.2: 411 | version "2.0.2" 412 | resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" 413 | integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== 414 | dependencies: 415 | function-bind "^1.1.2" 416 | 417 | inflight@^1.0.4: 418 | version "1.0.6" 419 | resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" 420 | integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== 421 | dependencies: 422 | once "^1.3.0" 423 | wrappy "1" 424 | 425 | inherits@2: 426 | version "2.0.4" 427 | resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" 428 | integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== 429 | 430 | is-binary-path@~2.1.0: 431 | version "2.1.0" 432 | resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" 433 | integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== 434 | dependencies: 435 | binary-extensions "^2.0.0" 436 | 437 | is-core-module@^2.9.0: 438 | version "2.11.0" 439 | resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144" 440 | integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== 441 | dependencies: 442 | has "^1.0.3" 443 | 444 | is-extglob@^2.1.1: 445 | version "2.1.1" 446 | resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" 447 | integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== 448 | 449 | is-glob@^4.0.1, is-glob@~4.0.1: 450 | version "4.0.3" 451 | resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" 452 | integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== 453 | dependencies: 454 | is-extglob "^2.1.1" 455 | 456 | is-number@^7.0.0: 457 | version "7.0.0" 458 | resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" 459 | integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== 460 | 461 | isomorphic-unfetch@^4.0.2: 462 | version "4.0.2" 463 | resolved "https://registry.yarnpkg.com/isomorphic-unfetch/-/isomorphic-unfetch-4.0.2.tgz#5fc04eeb1053b7b702278e2cf7a3f246cb3a9214" 464 | integrity sha512-1Yd+CF/7al18/N2BDbsLBcp6RO3tucSW+jcLq24dqdX5MNbCNTw1z4BsGsp4zNmjr/Izm2cs/cEqZPp4kvWSCA== 465 | dependencies: 466 | node-fetch "^3.2.0" 467 | unfetch "^5.0.0" 468 | 469 | make-error@^1.1.1: 470 | version "1.3.6" 471 | resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" 472 | integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== 473 | 474 | math-intrinsics@^1.1.0: 475 | version "1.1.0" 476 | resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9" 477 | integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g== 478 | 479 | mime-db@1.52.0: 480 | version "1.52.0" 481 | resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" 482 | integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== 483 | 484 | mime-types@^2.1.12: 485 | version "2.1.35" 486 | resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" 487 | integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== 488 | dependencies: 489 | mime-db "1.52.0" 490 | 491 | minimatch@^3.1.1: 492 | version "3.1.2" 493 | resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" 494 | integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== 495 | dependencies: 496 | brace-expansion "^1.1.7" 497 | 498 | minimist@^1.2.6: 499 | version "1.2.8" 500 | resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" 501 | integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== 502 | 503 | mkdirp@^1.0.4: 504 | version "1.0.4" 505 | resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" 506 | integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== 507 | 508 | ms@^2.1.3: 509 | version "2.1.3" 510 | resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" 511 | integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== 512 | 513 | node-cache@^5.1.2: 514 | version "5.1.2" 515 | resolved "https://registry.yarnpkg.com/node-cache/-/node-cache-5.1.2.tgz#f264dc2ccad0a780e76253a694e9fd0ed19c398d" 516 | integrity sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg== 517 | dependencies: 518 | clone "2.x" 519 | 520 | node-domexception@^1.0.0: 521 | version "1.0.0" 522 | resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" 523 | integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== 524 | 525 | node-fetch@^2.7.0: 526 | version "2.7.0" 527 | resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" 528 | integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== 529 | dependencies: 530 | whatwg-url "^5.0.0" 531 | 532 | node-fetch@^3.2.0: 533 | version "3.3.0" 534 | resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.3.0.tgz#37e71db4ecc257057af828d523a7243d651d91e4" 535 | integrity sha512-BKwRP/O0UvoMKp7GNdwPlObhYGB5DQqwhEDQlNKuoqwVYSxkSZCSbHjnFFmUEtwSKRPU4kNK8PbDYYitwaE3QA== 536 | dependencies: 537 | data-uri-to-buffer "^4.0.0" 538 | fetch-blob "^3.1.4" 539 | formdata-polyfill "^4.0.10" 540 | 541 | normalize-path@^3.0.0, normalize-path@~3.0.0: 542 | version "3.0.0" 543 | resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" 544 | integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== 545 | 546 | once@^1.3.0: 547 | version "1.4.0" 548 | resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" 549 | integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== 550 | dependencies: 551 | wrappy "1" 552 | 553 | path-is-absolute@^1.0.0: 554 | version "1.0.1" 555 | resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" 556 | integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== 557 | 558 | path-parse@^1.0.7: 559 | version "1.0.7" 560 | resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" 561 | integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== 562 | 563 | picomatch@^2.0.4, picomatch@^2.2.1: 564 | version "2.3.1" 565 | resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" 566 | integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== 567 | 568 | proxy-from-env@^1.1.0: 569 | version "1.1.0" 570 | resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" 571 | integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== 572 | 573 | readdirp@~3.6.0: 574 | version "3.6.0" 575 | resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" 576 | integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== 577 | dependencies: 578 | picomatch "^2.2.1" 579 | 580 | resolve@^1.0.0: 581 | version "1.22.1" 582 | resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" 583 | integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== 584 | dependencies: 585 | is-core-module "^2.9.0" 586 | path-parse "^1.0.7" 587 | supports-preserve-symlinks-flag "^1.0.0" 588 | 589 | rimraf@^2.6.1: 590 | version "2.7.1" 591 | resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" 592 | integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== 593 | dependencies: 594 | glob "^7.1.3" 595 | 596 | source-map-support@^0.5.12: 597 | version "0.5.21" 598 | resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" 599 | integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== 600 | dependencies: 601 | buffer-from "^1.0.0" 602 | source-map "^0.6.0" 603 | 604 | source-map@^0.6.0: 605 | version "0.6.1" 606 | resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" 607 | integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== 608 | 609 | strip-bom@^3.0.0: 610 | version "3.0.0" 611 | resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" 612 | integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== 613 | 614 | strip-json-comments@^2.0.0: 615 | version "2.0.1" 616 | resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" 617 | integrity sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ== 618 | 619 | supports-preserve-symlinks-flag@^1.0.0: 620 | version "1.0.0" 621 | resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" 622 | integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== 623 | 624 | to-regex-range@^5.0.1: 625 | version "5.0.1" 626 | resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" 627 | integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== 628 | dependencies: 629 | is-number "^7.0.0" 630 | 631 | tr46@~0.0.3: 632 | version "0.0.3" 633 | resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" 634 | integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== 635 | 636 | tree-kill@^1.2.2: 637 | version "1.2.2" 638 | resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc" 639 | integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A== 640 | 641 | ts-node-dev@^2.0.0: 642 | version "2.0.0" 643 | resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-2.0.0.tgz#bdd53e17ab3b5d822ef519928dc6b4a7e0f13065" 644 | integrity sha512-ywMrhCfH6M75yftYvrvNarLEY+SUXtUvU8/0Z6llrHQVBx12GiFk5sStF8UdfE/yfzk9IAq7O5EEbTQsxlBI8w== 645 | dependencies: 646 | chokidar "^3.5.1" 647 | dynamic-dedupe "^0.3.0" 648 | minimist "^1.2.6" 649 | mkdirp "^1.0.4" 650 | resolve "^1.0.0" 651 | rimraf "^2.6.1" 652 | source-map-support "^0.5.12" 653 | tree-kill "^1.2.2" 654 | ts-node "^10.4.0" 655 | tsconfig "^7.0.0" 656 | 657 | ts-node@^10.4.0: 658 | version "10.9.1" 659 | resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" 660 | integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== 661 | dependencies: 662 | "@cspotcode/source-map-support" "^0.8.0" 663 | "@tsconfig/node10" "^1.0.7" 664 | "@tsconfig/node12" "^1.0.7" 665 | "@tsconfig/node14" "^1.0.0" 666 | "@tsconfig/node16" "^1.0.2" 667 | acorn "^8.4.1" 668 | acorn-walk "^8.1.1" 669 | arg "^4.1.0" 670 | create-require "^1.1.0" 671 | diff "^4.0.1" 672 | make-error "^1.1.1" 673 | v8-compile-cache-lib "^3.0.1" 674 | yn "3.1.1" 675 | 676 | ts-node@^10.9.1: 677 | version "10.9.2" 678 | resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f" 679 | integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ== 680 | dependencies: 681 | "@cspotcode/source-map-support" "^0.8.0" 682 | "@tsconfig/node10" "^1.0.7" 683 | "@tsconfig/node12" "^1.0.7" 684 | "@tsconfig/node14" "^1.0.0" 685 | "@tsconfig/node16" "^1.0.2" 686 | acorn "^8.4.1" 687 | acorn-walk "^8.1.1" 688 | arg "^4.1.0" 689 | create-require "^1.1.0" 690 | diff "^4.0.1" 691 | make-error "^1.1.1" 692 | v8-compile-cache-lib "^3.0.1" 693 | yn "3.1.1" 694 | 695 | tsconfig@^7.0.0: 696 | version "7.0.0" 697 | resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7" 698 | integrity sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw== 699 | dependencies: 700 | "@types/strip-bom" "^3.0.0" 701 | "@types/strip-json-comments" "0.0.30" 702 | strip-bom "^3.0.0" 703 | strip-json-comments "^2.0.0" 704 | 705 | typescript@^4.9.5: 706 | version "4.9.5" 707 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" 708 | integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== 709 | 710 | undici-types@~5.26.4: 711 | version "5.26.5" 712 | resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" 713 | integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== 714 | 715 | unfetch@^5.0.0: 716 | version "5.0.0" 717 | resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-5.0.0.tgz#8a5b6e5779ebe4dde0049f7d7a81d4a1af99d142" 718 | integrity sha512-3xM2c89siXg0nHvlmYsQ2zkLASvVMBisZm5lF3gFDqfF2xonNStDJyMpvaOBe0a1Edxmqrf2E0HBdmy9QyZaeg== 719 | 720 | v8-compile-cache-lib@^3.0.1: 721 | version "3.0.1" 722 | resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" 723 | integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== 724 | 725 | web-streams-polyfill@^3.0.3: 726 | version "3.2.1" 727 | resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz#71c2718c52b45fd49dbeee88634b3a60ceab42a6" 728 | integrity sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q== 729 | 730 | webidl-conversions@^3.0.0: 731 | version "3.0.1" 732 | resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" 733 | integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== 734 | 735 | whatwg-url@^5.0.0: 736 | version "5.0.0" 737 | resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" 738 | integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== 739 | dependencies: 740 | tr46 "~0.0.3" 741 | webidl-conversions "^3.0.0" 742 | 743 | wrappy@1: 744 | version "1.0.2" 745 | resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" 746 | integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== 747 | 748 | xtend@^4.0.0: 749 | version "4.0.2" 750 | resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" 751 | integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== 752 | 753 | yn@3.1.1: 754 | version "3.1.1" 755 | resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" 756 | integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== 757 | --------------------------------------------------------------------------------