diff --git a/README.md b/README.md index a293358..a15bdac 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,13 @@ This is R0b3's bot, originally built as a Discord bot to display 3D printer status. It now also runs as a Matrix bot, both operating simultaneously in the same process. # Features -* Query & Monitor OctoPrint 3D Printer Status using the `$printstat` command (Requires that your printer is connected to [Octoprint](https://octoprint.org/))
+* Query & Monitor OctoPrint 3D Printer Status using the `$octostat` command (Requires that your printer is connected to [Octoprint](https://octoprint.org/))
![](images/Discord_Printstat_Command.png) * Query & Monitor Bambu Lab Printer Status using the `$bambustat` command (Requires a Bambu Lab printer accessible on the local network via MQTT) * Displays print state, progress percentage, time remaining, current layer, bed temp, nozzle temp, and chamber temp * Optionally captures and attaches a camera snapshot from the printer's RTSPS stream (requires [ffmpeg](https://ffmpeg.org/) on the host) - * Updates the bot's Discord status to show live Bambu print progress while a print is running + * Updates the bot's Discord status to show live print progress; alternates between OctoPi and Bambu status every 30 seconds when both printers are running simultaneously +* Query both printers at once using the `$printstat` command * Play a selection of sound clips to voice channel members using the various commands (`$trololo`, `$oops`, `$promoted`, etc) — Discord only * **Matrix support** — the bot can connect to a self-hosted Matrix homeserver (Synapse/Dendrite) and respond to the same text commands in E2E-encrypted rooms diff --git a/r0b3bot.py b/r0b3bot.py index d60b37c..07c162c 100644 --- a/r0b3bot.py +++ b/r0b3bot.py @@ -471,12 +471,12 @@ async def play_sound(ctx, member : discord.Member, soundFile, command): # OctoPrint Commands # @bot.command() -async def printstat(ctx): +async def octostat(ctx): datestring = datetime.now() datestring = datestring.strftime("%m/%d/%Y-%H:%M:%S") - print(f"[{datestring}]: {ctx.message.author.display_name} called $printstat") + print(f"[{datestring}]: {ctx.message.author.display_name} called $octostat") # We haven't yet changed the state of the light, setting this to False turned_on_light = False @@ -730,6 +730,14 @@ async def bambustat(ctx): await ctx.send(embed=embed) +@bot.command() +async def printstat(ctx): + datestring = datetime.now().strftime("%m/%d/%Y-%H:%M:%S") + print(f"[{datestring}]: {ctx.message.author.display_name} called $printstat") + await octostat.callback(ctx) + await bambustat.callback(ctx) + + @bot.command() async def info(ctx): embed = discord.Embed(title="R0b3BOT", description="Derpy Derp of a Bot :P", color=0xeee657) @@ -811,13 +819,17 @@ async def help(ctx): await ctx.send(embed=embed) embed = discord.Embed(title="OctoPi Printer Status", color=0xeee657) - embed.add_field(name=f"{BOT_COMMAND_PREFIX}printstat", value="Uploads a snapshot of Rich's OctoPrint 3D printer and current stats", inline=False) + embed.add_field(name=f"{BOT_COMMAND_PREFIX}octostat", value="Uploads a snapshot of Rich's OctoPrint 3D printer and current stats", inline=False) await ctx.send(embed=embed) embed = discord.Embed(title="Bambu Lab Printer Status", color=0x00B4D8) embed.add_field(name=f"{BOT_COMMAND_PREFIX}bambustat", value="Displays the current status of the Bambu Lab printer (temps, progress, time remaining)", inline=False) await ctx.send(embed=embed) + embed = discord.Embed(title="All Printers Status", color=0x9B59B6) + embed.add_field(name=f"{BOT_COMMAND_PREFIX}printstat", value="Shows status of both the OctoPi and Bambu Lab printers in one command", inline=False) + await ctx.send(embed=embed) + # Function to run shell command and return stdout or sterr async def run(cmd): proc = await asyncio.create_subprocess_shell(