2020-01-29 14:31:01 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Yuuki_Libs
|
2020-02-01 13:58:50 +08:00
|
|
|
(c) 2020 Star Inc.
|
2020-01-29 14:31:01 +08:00
|
|
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2020-02-07 22:11:44 +08:00
|
|
|
"""
|
|
|
|
from .reader import Yuuki_WebDataReader
|
2020-02-29 00:59:18 +08:00
|
|
|
from ..tools import Yuuki_DynamicTools
|
2020-02-07 22:11:44 +08:00
|
|
|
|
2020-02-26 21:54:58 +08:00
|
|
|
|
2020-02-07 22:11:44 +08:00
|
|
|
class Yuuki_WebAdminAPI:
|
2020-02-28 22:15:27 +08:00
|
|
|
def __init__(self, Yuuki, WebAdmin_Handle):
|
2020-02-08 14:09:44 +08:00
|
|
|
self.Yuuki = Yuuki
|
2020-02-28 22:15:27 +08:00
|
|
|
self.WebAdmin = WebAdmin_Handle
|
2020-02-08 14:09:44 +08:00
|
|
|
self.YuukiData = self.Yuuki.data
|
|
|
|
self.Yuuki_DataHandle = Yuuki_WebDataReader(self.YuukiData)
|
2020-02-07 22:11:44 +08:00
|
|
|
self.events = {
|
|
|
|
"": self.nothing,
|
|
|
|
"get_logs": self.get_logs,
|
2020-02-08 14:09:44 +08:00
|
|
|
"get_helpers": self.get_helpers,
|
2020-02-07 22:11:44 +08:00
|
|
|
"get_groups_joined": self.get_groups_joined,
|
2020-02-08 17:21:27 +08:00
|
|
|
"shutdown": self.shutdown,
|
2020-02-07 22:11:44 +08:00
|
|
|
}
|
|
|
|
|
2020-02-09 17:09:13 +08:00
|
|
|
def action(self, *, task="", data=None):
|
2020-02-08 00:55:19 +08:00
|
|
|
return self.events[task](data)
|
2020-02-07 22:11:44 +08:00
|
|
|
|
2020-02-08 00:55:19 +08:00
|
|
|
def get_groups_joined(self, data):
|
|
|
|
if data:
|
|
|
|
pass
|
2020-02-08 14:09:44 +08:00
|
|
|
return self.YuukiData.getData(["Global", "GroupJoined"])
|
2020-02-07 22:11:44 +08:00
|
|
|
|
2020-02-08 13:36:30 +08:00
|
|
|
def get_helpers(self, data):
|
|
|
|
if data:
|
|
|
|
pass
|
2020-03-14 13:21:15 +08:00
|
|
|
return self.Yuuki.Connect.helper
|
2020-02-08 13:36:30 +08:00
|
|
|
|
2020-02-08 00:55:19 +08:00
|
|
|
def get_logs(self, data):
|
|
|
|
return self.Yuuki_DataHandle.get_logs(data)
|
2020-02-07 22:11:44 +08:00
|
|
|
|
2020-02-08 17:21:27 +08:00
|
|
|
def shutdown(self, data):
|
|
|
|
if data:
|
|
|
|
pass
|
2020-02-29 00:59:18 +08:00
|
|
|
return Yuuki_DynamicTools(self.Yuuki).sendText(
|
|
|
|
"u085311ecd9e3e3d74ae4c9f5437cbcb5",
|
|
|
|
"[Yuuki] Remote Shutdown"
|
|
|
|
)
|
2020-02-08 17:21:27 +08:00
|
|
|
|
2020-02-28 22:15:27 +08:00
|
|
|
def command_shutdown(self):
|
2020-02-28 22:56:10 +08:00
|
|
|
self.WebAdmin.wa_shutdown()
|
2020-02-28 22:15:27 +08:00
|
|
|
|
2020-02-07 22:11:44 +08:00
|
|
|
@staticmethod
|
|
|
|
def nothing(data):
|
|
|
|
if data:
|
|
|
|
pass
|