update README and support specify config file
This commit is contained in:
@@ -50,3 +50,12 @@ rssbotLib=rssbot.dll
|
||||
可选参数。RSS更新发生错误后,再次更新的间隔时间。默认值为`30`。单位为分。
|
||||
### botOwnerList
|
||||
可选参数。具有特殊权限的用户ID,这些用户可以使用部分特殊功能。可以使用`,`分隔两个不同的ID。
|
||||
特殊权限:
|
||||
- 可以强制更新RSS
|
||||
## 命令行参数
|
||||
```text
|
||||
--rebuild-hashlist 重建hashList
|
||||
--exit-after-rebuild 再重建hashList后退出
|
||||
-c/--config <file> 从指定文件中读取配置
|
||||
```
|
||||
|
||||
|
||||
@@ -57,15 +57,17 @@ class settings:
|
||||
|
||||
class commandline:
|
||||
def __init__(self, commandline: List[str] = None):
|
||||
self._config = 'settings.txt'
|
||||
self._rebuildHashlist = False
|
||||
self._exitAfterRebuild = False
|
||||
if commandline is not None:
|
||||
self.parse(commandline)
|
||||
|
||||
def parse(self, commandline: List[str]):
|
||||
cml = getopt(commandline, '', [
|
||||
'rebuild-hashlist', 'exit-after-rebuild'])
|
||||
cml = getopt(commandline, 'c:', ['rebuild-hashlist', 'exit-after-rebuild', 'config='])
|
||||
for i in cml[0]:
|
||||
if i[0] in ['-c', '--config']:
|
||||
self._config = i[1]
|
||||
if i[0] == '--rebuild-hashlist':
|
||||
self._rebuildHashlist = True
|
||||
if i[0] == '--exit-after-rebuild':
|
||||
|
||||
@@ -420,13 +420,13 @@ class main:
|
||||
self._upi = i['update_id'] + 1
|
||||
|
||||
def start(self):
|
||||
self._setting = settings(self, 'settings.txt')
|
||||
if self._setting._token is None:
|
||||
print('没有机器人token')
|
||||
return -1
|
||||
self._commandLine = commandline()
|
||||
if len(sys.argv) > 1:
|
||||
self._commandLine.parse(sys.argv[1:])
|
||||
self._setting = settings(self, self._commandLine._config)
|
||||
if self._setting._token is None:
|
||||
print('没有机器人token')
|
||||
return -1
|
||||
self._telegramBotApiServer = self._setting._telegramBotApiServer
|
||||
self._db = database(self, self._setting._databaseLocation)
|
||||
if not exists('settings.txt'):
|
||||
|
||||
Reference in New Issue
Block a user