MicroCosmBot is a telegram bot for creating token gated telegram group chats for cosmos assets.
web
: the NextJS web application that also runs the telegram botbot
: all the bot logiceslint-config-custom
:eslint
configurations (includeseslint-config-next
andeslint-config-prettier
)tsconfig
:tsconfig.json
s used throughout the monorepotailwind-config
:tailwind.config.js
s used throughweb
anddocs
application as well aspackage/ui
components
Each package/app is 100% TypeScript.
- Setup a mysql8 database. Copy the connection string to your env in
DATABASE_URL
. Runnpx prisma db push
from thepackages/db
directory to deploy the schema. - Acquire a telegram bot token from @BotFather
- Enable bot group settings via botfather.
- Create a webhook to your localhost web port. I can recommend https://tunnelmole.com/ --
tmole 3000
. Set this tunnel url to your BASEURL env variable. - Copy
apps/web/.env.sample
toapps/web/.env
and fill in the values. - Run your bot locally with
turbo dev
in theapps/web
directory. - Call the config api to tell the bot where to send updates.
curl -X GET http://localhost:3000/api/bot/<your bot key>/config
- You will now receive bot updates from telegram to your local machine.
- For testing the background checks, create an upstash QStash. Save QSTASH_URL, QSTASH_TOKEN, QSTASH_CURRENT_SIGNING_KEY, and QSTASH_NEXT_SIGNING_KEY from qstash
- Get your bot info and store the JSON in
NEXT_PUBLIC_GETME_BOT_INFO
(one time)- Call the telegram api
https://api.telegram.org/bot<your-bot-api-key>/getMe
and copy theresult
field object in the environment variable. - This helps speed up the api calls because grammy will not have to call this each time a function boots.
- Call the telegram api
- Setup
https://console.upstash.com/qstash
which is used for the cron job to periodically check nft token ownership. Copy the key to your env. - Deploy to vercel through the git integration.
A vercel cron job enqueues a job that checks the nft token ownership of all users in the database. If a user no longer owns the token, they are removed from the database and banned from the group. This is to ensure that only users who own the token can be in the group.
Configure how often this runs in vercel.json
. The default is every 2 hours.
This turborepo has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
To build all apps and packages, run the following command:
cd nouns-stream
yarn build
To develop all apps and packages, run the following command:
cd nouns-stream
yarn dev
The web
and docs
NextJS projects are setup to run with Vitetest and web3
is setup to run test via Forge.
To test all apps and packages, run the following command:
cd nouns-stream
yarn test
To run tests in watch mode, run the following command:
cd nouns-stream
yarn test:watch
Turborepo can use a technique known as Remote Caching to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can create one, then enter the following commands:
cd microcosms
npx turbo login
This will authenticate the Turborepo CLI with your Vercel account.
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your turborepo:
npx turbo link
Learn more about the power of Turborepo:
This project is licensed under the GPL licence. See LICENSE.md for details.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Contributor wish list:
- Internationalization - help me make this bot available in other languages! See https://grammy.dev/plugins/i18n.html#usage
- Multi chain support - help me make this bot available on other chains!
6dp: factory/neutron1ffus553eet978k024lmssw0czsxwr97mggyv85lpcsdkft8v9ufsz3sa07/astro factory/neutron1zlf3hutsa4qnmue53lz2tfxrutp8y2e3rj4nkghg3rupgl4mqy8s5jgxsn/xASTRO
ideas:
- change the auth type to sign arbitrary if it's non mobile
- allow admin to configure how the greetings work