I have a code similar to this, and I want the function "do_something" to be executed when I run the project. Its job is to prepare the database, etc.
I don't know how do it. I would it if you could guide me. I have read the rocketry documentation, but I couldn't find what I need.
from pyrogram import Client
from rocketry import Rocketry
import asyncio
api = Client("api")
cli = Client("cli")
rocktry = Rocketry()
async def do_something():
await api.send_message(123456, "loading ....")
# code
await api.send_message(123456, "bot is ready!")
async def main():
await asyncio.gather(api.start(), cli.start(), rocketry.serve())
api.run(main())
The idea that came to my mind is to set the value of a variable to false and then check in my code if the variable's value is false, perform this action, and afterwards set the value of that variable to true.