Extract news under topics of interest (MEV, security, development) from DefiLlama Round Up and forward to DefiLlama Round Up for Devs.
functions_framework
: Google Cloud Functions framework.telethon
: Telegram library for MTProto and Bot API.ipdb
: debugging tool.
black
: code formatting.ruff
: linting.mypy
: static type checking.poetry
: package management.pre-commit
: pre-commit hooks.just
: manage commands.direnv
: autoloading vritual environment.
- Create a Google Cloud account and a project.
- Set up a Scheduler for the daily cron job.
- Set up a Pub/Sub topic.
- Install the
gcloud
command line tool.
The script itself is quite simple. Actually, more work is done on figuring out and setting up the environment where it runs. I chose to deploy the bot on Google Cloud Functions (a serverless platform). The following chart describe the overall architecture.
flowchart LR
A("Daily Cron Jub<br>(Cloud Scheduler)")
B("Topic<br>(Cloud Pub/Sub)")
C("Bot Script<br>(Cloud Functions)")
A -- publish --> B
C -- subscribe --> B
The cron job will publish an event to the topic daily, triggering the bot function to execute its logic to crawl the Round Up content from DefiLlama's website, extract relevant news, and then send an excerpt to the channel.
- Create a bot account.
- Create a user account with no-SIM signup. (We'll be uploading the secret credentials to Google Cloud to log in as this user, so better not use the personal account.)
- Follow the instructions from Telethon to create session keys for both of the above accounts.
just deploy
: deploy the bot.just trigger
: manually trigger the deployed bot (often used for testing).
Note The first time deploying the bot to Google Cloud, some warnings and errors will pop up asking for permissions, e.g. granting default service account access to Secret Manager. Simply follow the hints and set up the required permissions to proceed.
Absolutely welcome. Also feel free to reach out to discuss the project or anything else!
Dual licensed under either MIT License or Apache License, Version 2.0.