Giter Site home page Giter Site logo

microcosmbot's Introduction

MicroCosmBot

MicroCosmBot is a telegram bot for creating token gated telegram group chats for cosmos assets.

Apps and Packages

  • web: the NextJS web application that also runs the telegram bot
  • bot: all the bot logic
  • eslint-config-custom: eslint configurations (includes eslint-config-next and eslint-config-prettier)
  • tsconfig: tsconfig.jsons used throughout the monorepo
  • tailwind-config: tailwind.config.jss used through web and docs application as well as package/ui components

Each package/app is 100% TypeScript.

Development Setup

  • Setup a mysql8 database. Copy the connection string to your env in DATABASE_URL. Run npx prisma db push from the packages/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 to apps/web/.env and fill in the values.
  • Run your bot locally with turbo dev in the apps/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

Deployment

  • 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 the result 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.
  • 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.

Cron

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.

Utilities

This turborepo has some additional tools already setup for you:

Build

To build all apps and packages, run the following command:

cd nouns-stream
yarn build

Develop

To develop all apps and packages, run the following command:

cd nouns-stream
yarn dev

Testing

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

Remote Caching

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

Useful Links

Learn more about the power of Turborepo:

License

This project is licensed under the GPL licence. See LICENSE.md for details.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Contributor wish list:

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

microcosmbot's People

Contributors

abigpotostew avatar jhernandezb avatar

Stargazers

Barton Rhodes avatar marty avatar

Watchers

 avatar  avatar

Forkers

jhernandezb

microcosmbot's Issues

Set a maximum number of linked wallets

Microcosm bott supports linking multiple wallets which is a great way to access multiple channels without having your NFTs in a single account.

But to prevent abuse, a user should only be allowed to link up to say 20 wallets to their TG account.

Sorry, this link has expired

After several attempts of "Connect New Wallet" and "Use Existing Wallets" with successful verification of the wallet addresses, I am getting the "Sorry, this link has expired" after selecting the unique invite link that is provided in the MicroCosmBot Telegram DM. I am unable to join the Bad Kids Telegram group chat. Thanks for the support.

Add support for custom invite link slugs

Right now invite links use the id of the group in the format https://t.me/microcosmbotdotxyz_bot?start=cljxj51n20002mi084asju6f8

The start field value could be a custom unique value such as https://t.me/microcosmbotdotxyz_bot?start=bad_kids where bad_kids is a url friendly slug configured by the group admin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.