1
0
Fork 0

Add Pull command

This commit is contained in:
Swee 2024-10-10 16:56:35 -07:00
parent 401b9487b0
commit 9dea7fbabe

View file

@ -126,6 +126,22 @@ async def on_message(message):
else:
mess = await message.reply(embed=guilded.Embed(title=":sweebot-fail: Permission denied."))
print("[" + RED + "FAIL" + RESET + "] Not restarting script, Permission Denied for " + message.author.name)
elif command[0] == "pull":
if "full" in getperms(message.author.id):
mess = await message.reply(embed=guilded.Embed(title=":sweebot-loading: Pulling from Git...", description="```[Starting, please stand by...]```"))
print("[" + BLUE + "..." + RESET + "] Pulling from git... (initiated by " + message.author.name + ")")
sleep(1)
p = subprocess.Popen("/home/swee/update-sb4g.sh", stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = ""
for line in iter(p.stdout.readline, b''):
output+=line.decode()
await mess.edit(embed=guilded.Embed(title=":sweebot-loading: Pulling from Git...", description="```\n" + output + "\n```"))
p.stdout.close()
p.wait()
await mess.edit(embed=guilded.Embed(title=":sweebot-success: Done, restarting bot...", description="```\n" + output + "\n```"))
else:
mess = await message.reply(embed=guilded.Embed(title=":sweebot-fail: Permission denied."))
print("[" + RED + "FAIL" + RESET + "] Not restarting script, Permission Denied for " + message.author.name)
elif command[0] == "spammy-shell":
if "full" in getperms(message.author.id):
mess = await message.reply("```No output (yet)```")