From 39b82cd9d6166ba494de55c553ae9eaf4cc79e0c Mon Sep 17 00:00:00 2001 From: lifegpc Date: Tue, 19 Jan 2021 16:29:26 +0800 Subject: [PATCH] update README and support specify config file --- README.md | 9 +++++++++ readset.py | 6 ++++-- rssbot.py | 8 ++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f21edff..7bb4022 100644 --- a/README.md +++ b/README.md @@ -50,3 +50,12 @@ rssbotLib=rssbot.dll 可选参数。RSS更新发生错误后,再次更新的间隔时间。默认值为`30`。单位为分。 ### botOwnerList 可选参数。具有特殊权限的用户ID,这些用户可以使用部分特殊功能。可以使用`,`分隔两个不同的ID。 +特殊权限: +- 可以强制更新RSS +## 命令行参数 +```text +--rebuild-hashlist 重建hashList +--exit-after-rebuild 再重建hashList后退出 +-c/--config 从指定文件中读取配置 +``` + diff --git a/readset.py b/readset.py index fe6544f..00809ad 100644 --- a/readset.py +++ b/readset.py @@ -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': diff --git a/rssbot.py b/rssbot.py index 92d53c1..3ed579e 100644 --- a/rssbot.py +++ b/rssbot.py @@ -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'):