![]() ![]() Now that we have a working API, the next step is to containerize our app. Now, let’s containerize this entire workflow for easy deployment on our VPS. You should be able to see your bot come online in your server too. You’ll see the following output with the server running: Now, run the bot with the following shell command: $ uvicorn run_bot:app -reload -port 8443 -host 0.0.0.0 Let’s wrap this up in our asynchronous API now, shall we? from fastapi import FastAPI app = FastAPI() def main(): return "The bot is alive!" # run the bot as a FastAPI async function async def run(): """ to run the bot as a FastAPI async func """ try:Īsyncio.create_task(bot.start(TOKEN)) except: await bot.logout() Next, we want to capture the text from an incoming message, and we do that with the on_message function: async def on_message(message): # Do not reply to self if thor = bot.user: return # Do not reply to any other bot if : return # get the message content msg = () # reply to the ping message if "!ping" in msg: await message.reply("Pong!", mention_author=False)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |