Browse Source

Restart only if there is a update (#120)

ÁÑÑÍHÌLÅTØR SPÄRK 5 years ago
parent
commit
ad03d6991a
1 changed files with 5 additions and 6 deletions
  1. 5 6
      wbb/modules/sudoers.py

+ 5 - 6
wbb/modules/sudoers.py

@@ -196,16 +196,15 @@ async def broadcast_message(_, message):
 
 
 # Update
 # Update
 
 
-
 @app.on_message(filters.command("update") & filters.user(SUDOERS))
 @app.on_message(filters.command("update") & filters.user(SUDOERS))
 async def update_restart(_, message):
 async def update_restart(_, message):
     try:
     try:
-        await message.reply_text(
-            f'```{subprocess.check_output(["git", "pull"]).decode("UTF-8")}```'
-        )
+        out = subprocess.check_output(["git", "pull"]).decode("UTF-8")
+        if "Already up to date." in str(out):
+            return await message.reply_text("Its already up-to date!")
+        await message.reply_text(f"```{out}```")
     except Exception as e:
     except Exception as e:
         return await message.reply_text(str(e))
         return await message.reply_text(str(e))
     m = await message.reply_text(
     m = await message.reply_text(
-        "**Updated with default branch, restarting now.**"
-    )
+        "**Updated with default branch, restarting now.**")
     await restart(m)
     await restart(m)