-
Notifications
You must be signed in to change notification settings - Fork 0
/
initial.py
115 lines (86 loc) · 2.75 KB
/
initial.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
"""
系统初始化-》 包含各种文件的初始化与重置函数
"""
import os
import time
from iosetting import JsonParser
def initial():
try:
with open('./files/INITIAL', mode='r'):
pass
except FileNotFoundError:
print('正在初始化')
_initial()
def _initial():
if not os.path.exists('./files'):
print('正在创建files文件夹')
os.mkdir('./files')
if not os.path.exists('./logging'):
print('正在创建logging文件夹')
os.mkdir('./logging')
with open('./files/INITIAL', mode='x'):
pass
with open('./files/temp',mode='x'):
pass
INITIAL_initial()
try:
with open('./files/ban_word.txt', mode='r'):
pass
except FileNotFoundError:
print('正在初始化屏蔽词文件')
ban_word_initial()
try:
print('正在初始化设置文件')
with open('./files/settings.txt', mode='r'):
pass
except FileNotFoundError:
settings_initial()
def INITIAL_initial():
initial_dict = {
'what': '登录信息',
'id': None,
'pw': None,
'sessdata': None,
'bili_jct': None,
'buvid3': None,
'ac_time_value': None,
}
JsonParser.dump('./files/INITIAL', initial_dict, mode='w')
def ban_word_initial():
ban_word_dict = {
'what': "屏蔽词字典",
'info': "在设置时,'-'(减号)开头的词作为匹配屏蔽,其他的视为完全匹配屏蔽。",
'all_match': ['。', '赞', ],
'regex_match': ['红包', ],
}
JsonParser.dump('./files/ban_word.txt', ban_word_dict, mode='w')
# ban_word_init_lines = [
# '$ 在该文件下写入的所有词会被屏蔽,每行只写一个词,只屏蔽完全一致的弹幕',
# '$ 本文件中$(美元)符号开头的句子会被视为注释',
# '$ 更改屏蔽词需要重启应用(如果已经启动的话)',
# '$ 更多操作请参看README.MD文件(可以直接以文本形式打开)',
# '。',
# '赞',
# "$ '-'(减号)开头的会作为匹配词屏蔽。",
# "$ 系统会屏蔽所有包含匹配词的弹幕,请谨慎选择",
# '-红包',
# ]
def settings_initial():
dicts = {
'basic_setting': {
'what': '直播间主属性',
'rid': 34162,
'min_level': 1,
},
'sys_setting': {
'what': '系统行为设置',
'login': True,
'save_account': False,
'debug': False,
},
'running': {
'what': '运行中属性',
'volume': 90,
}
}
JsonParser.dump('./files/settings.txt', dicts, mode='w')