Years ago, I wrote a very simple bot for the messaging app Telegram. All the bot was designed to do was post surreal AI generated images from https://inspirobot.me/, and send insults scraped from https://generatorfun.com. The project died a few years ago when I took up my first serious role in IT, but I think that I still have more to learn from it.
For instance, the deployment pipeline of my bot was incredibly simple. It was me using scp to copy the project folder to a free-tier cloud server, then ssh-ing in to run the python file. This worked great for a small chatroom with my friends, but now I can see all the things that could be made better.
This is part one of a series of developer blog posts I’m planning on making. Here are some of the notes I wrote down while I was working today.
This project has some potential to be a real portfolio piece
I think I should use it to practice some simple python skills.
Then I’ll also use it to practice my devops skills as well.
TODO:
First, I want to get a MVP ready to go. I think I’ve got it mostly done.
- inspiration works
- insult works
- tomorrow morning we’ll know if goodmorning works
- this sunday we’ll know if goalsWeekly is working
- no new features besides this until we get the rest of the pipeline locked in!
Next, let’s secure the code. This is the small and obvious things:
- remove roomID and bottoken from code
- remove above from git history also (oops!)
Let’s establish environments, and where code should go after it’s written.
- I wrote code on my laptop and pushed it to github. Is this my dev environment?
- I scp’d my code from my laptop to my prod environment. Is there a smarter way to do this?
- How do I test this code? Do I need to make a second telegram bot for this?
Let’s also establish unit tests of each function in my main.py
Less important, but let’s refactor code so it’s cleaner and more professional looking.
- main.py is our only directly run python script
- well, besides manual.py
- main.py calls other python scripts if it would be useful to separate them for organizational purposes
Setup CI/CD pipeline!
- How do I go from publishing new code to having it uploaded to pyhost and running the latest version like a pro?
- automated download of new code on pyhost once pushed to git?
- picking scheduled time that it’s okay to stop the bot, upgrade source, and restart the bot
- automated testing of the bot. Do all it’s functions work as I expect?
- How clean can I make this? Can I make this all happen with just a few button presses in VSCode?