Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/core/admin.py

70 lines
2.2 KiB
Python
Raw Normal View History

2021-02-25 12:36:19 +00:00
import os
import sys
2021-04-28 12:21:33 +00:00
import json
2021-02-25 12:36:19 +00:00
2021-04-28 12:21:33 +00:00
from core.elements import Target
2021-02-25 12:36:19 +00:00
from core.template import sendMessage, wait_confirm
from database import BotDB as database
2021-02-25 12:36:19 +00:00
async def add_su(kwargs: dict):
command = kwargs['trigger_msg'].split(' ')
await sendMessage(kwargs, database.add_superuser(command[1]))
2021-02-25 12:36:19 +00:00
async def del_su(kwargs: dict):
command = kwargs['trigger_msg'].split(' ')
await sendMessage(kwargs, database.del_superuser(command[1]))
2021-02-25 12:36:19 +00:00
async def add_base_su(kwargs: dict):
await sendMessage(kwargs, database.add_superuser('2596322644'))
async def set_modules(kwargs: dict):
command = kwargs['trigger_msg'].split(' ')
command_second_word = command[1]
command_third_word = command[2]
command_forth_word = command[3]
msg = database.update_modules(command_second_word, command_third_word, command_forth_word)
await sendMessage(kwargs, msg)
async def restart_bot(kwargs: dict):
await sendMessage(kwargs, '你确定吗?')
confirm = await wait_confirm(kwargs)
if confirm:
2021-04-28 12:21:33 +00:00
update = os.path.abspath('.cache_restart_author')
write_version = open(update, 'w')
write_version.write(json.dumps({'From': kwargs[Target].target_from, 'ID': kwargs[Target].id}))
write_version.close()
2021-02-25 12:36:19 +00:00
await sendMessage(kwargs, '已执行。')
python = sys.executable
os.execl(python, python, *sys.argv)
async def update_bot(kwargs: dict):
await sendMessage(kwargs, '你确定吗?')
confirm = await wait_confirm(kwargs)
if confirm:
result = os.popen('git pull', 'r')
2021-03-07 15:34:15 +00:00
await sendMessage(kwargs, result.read())
2021-03-23 15:04:21 +00:00
async def update_and_restart_bot(kwargs: dict):
await sendMessage(kwargs, '你确定吗?')
confirm = await wait_confirm(kwargs)
if confirm:
2021-04-28 12:21:33 +00:00
update = os.path.abspath('.cache_restart_author')
write_version = open(update, 'w')
write_version.write(json.dumps({'From': kwargs[Target].target_from, 'ID': kwargs[Target].id}))
write_version.close()
2021-03-23 15:04:21 +00:00
result = os.popen('git pull', 'r')
await sendMessage(kwargs, result.read())
python = sys.executable
os.execl(python, python, *sys.argv)
2021-03-07 15:34:15 +00:00
async def echo_msg(kwargs: dict):
await sendMessage(kwargs, kwargs['trigger_msg'])