22 lines
553 B
Python
22 lines
553 B
Python
import os
|
|
|
|
# 记录加入的群组
|
|
class GroupCtl :
|
|
|
|
path = os.path.join(os.getcwd(),"joined_group.cfg")
|
|
groups:list[str] = []
|
|
|
|
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)
|
|
|