mirror of
https://github.com/hyper-neptune/yuuki.git
synced 2024-11-15 10:54:45 +08:00
36 lines
1 KiB
Python
36 lines
1 KiB
Python
#!/usr/bin/python3
|
|
# coding=UTF-8
|
|
|
|
import os, time
|
|
|
|
class Yuuki_Data:
|
|
def __init__(self):
|
|
self.LogType = {
|
|
"JoinGroup":"<li>%s: %s(%s) -> Inviter: %s</li>"
|
|
}
|
|
|
|
self.LogPath = "logs/"
|
|
self.LogName = "{}.html"
|
|
|
|
self.initHeader = "<title>{} - SYB</title>" \
|
|
"<meta charset='utf-8' />"
|
|
|
|
if not os.path.isdir(self.LogPath):
|
|
os.mkdir(self.LogPath)
|
|
|
|
for Type in self.LogType:
|
|
name = self.LogPath + self.LogName.format(Type)
|
|
if not os.path.isfile(name):
|
|
with open(name, "w") as f:
|
|
f.write(self.initHeader.format(Type))
|
|
|
|
def logFile(self, Type, Mode):
|
|
return open(self.LogPath + self.LogName.format(Type), Mode)
|
|
|
|
def updateLog(self, Type, Data):
|
|
with self.logFile(Type, "a") as f:
|
|
f.write(self.LogType[Type] % Data)
|
|
|
|
def getTime(self, format="%b %d %Y %H:%M:%S %Z"):
|
|
Time = time.localtime(time.time())
|
|
return time.strftime(format, Time)
|