mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2026-01-03 11:04:51 +00:00
Add pickle when restart
This commit is contained in:
parent
8df34e6dce
commit
f6523c1ff8
2 changed files with 11 additions and 1 deletions
|
|
@ -8,6 +8,8 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import importlib
|
import importlib
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
|
import pickle
|
||||||
import traceback
|
import traceback
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
||||||
|
|
@ -68,6 +70,11 @@ async def start_bot():
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOGGER.error(str(e))
|
LOGGER.error(str(e))
|
||||||
|
if os.path.exists("restart.pickle"):
|
||||||
|
with open('restart.pickle', 'rb') as status:
|
||||||
|
chat_id, message_id = pickle.load(status)
|
||||||
|
os.remove("restart.pickle")
|
||||||
|
await app.edit_message_text(chat_id=chat_id, message_id=message_id, text="<b>Bot restarted successfully!</b>")
|
||||||
asyncio.create_task(auto_clean())
|
asyncio.create_task(auto_clean())
|
||||||
await idle()
|
await idle()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import asyncio
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import pickle
|
||||||
import traceback
|
import traceback
|
||||||
from inspect import getfullargspec
|
from inspect import getfullargspec
|
||||||
|
|
||||||
|
|
@ -199,7 +200,9 @@ async def update_restart(_, message):
|
||||||
await message.reply_text(f"<code>{out}</code>")
|
await message.reply_text(f"<code>{out}</code>")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return await message.reply_text(str(e))
|
return await message.reply_text(str(e))
|
||||||
await message.reply_text("<b>Updated with default branch, restarting now.</b>")
|
msg = await message.reply_text("<b>Updated with default branch, restarting now.</b>")
|
||||||
|
with open('restart.pickle', 'wb') as status:
|
||||||
|
pickle.dump([message.chat.id, msg.id], status)
|
||||||
os.execvp(sys.executable, [sys.executable, "-m", "misskaty"])
|
os.execvp(sys.executable, [sys.executable, "-m", "misskaty"])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue