fix : 忘记存储群组了QAQ
This commit is contained in:
@@ -142,6 +142,7 @@ class djtuWebsocket (Client) :
|
|||||||
new_group = False
|
new_group = False
|
||||||
if new_group :
|
if new_group :
|
||||||
groups.groups.append(gid)
|
groups.groups.append(gid)
|
||||||
|
groups.save()
|
||||||
# 解析指令
|
# 解析指令
|
||||||
commands:dict[str,types.MethodType|types.FunctionType] = {
|
commands:dict[str,types.MethodType|types.FunctionType] = {
|
||||||
r'吃什么' : lambda :"是啊吃什么"
|
r'吃什么' : lambda :"是啊吃什么"
|
||||||
|
|||||||
@@ -5,9 +5,18 @@ class GroupCtl :
|
|||||||
|
|
||||||
path = os.path.join(os.getcwd(),"joined_group.cfg")
|
path = os.path.join(os.getcwd(),"joined_group.cfg")
|
||||||
groups:list[str] = []
|
groups:list[str] = []
|
||||||
|
|
||||||
def __init__(self) -> None:
|
|
||||||
fd = os.open(self.path,os.O_CREAT|os.W_OK)
|
|
||||||
with open(fd) as file :
|
|
||||||
self.groups.append(file.readline())
|
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
with open(self.openfile()) as awa:
|
||||||
|
self.groups = awa.readlines()
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
# 重新加载
|
||||||
|
fd = self.openfile()
|
||||||
|
os.truncate(self.path,0)
|
||||||
|
os.write(fd,bytes('\n'.join(self.groups),'utf-8'))
|
||||||
|
os.close(fd)
|
||||||
|
|
||||||
|
def openfile(self):
|
||||||
|
return os.open(self.path,os.O_RDWR|os.O_CREAT)
|
||||||
|
|
||||||
Reference in New Issue
Block a user