瀏覽代碼

add allowlist parameter

subDesTagesMitExtraKaese 8 月之前
父節點
當前提交
40b9765fea
共有 3 個文件被更改,包括 17 次插入2 次删除
  1. 13 1
      README.md
  2. 3 0
      main.py
  3. 1 1
      whisper.cpp

+ 13 - 1
README.md

@@ -29,4 +29,16 @@ services:
 ## Configuration
 The bot will download the model file on first run to reduce image size. Available models are `tiny.en`, `tiny`, `base.en`, `base`, `small.en`, `small`, `medium.en`, `medium`, and `large`. The default is `ASR_MODEL=tiny`.
 
-You can authenticate using tokens instead of a password by setting `LOGIN_TOKEN=<login-token>` or `ACCESS_TOKEN=<access-token>` instead of `PASSWORD=<password>`.
+You can authenticate using tokens instead of a password by setting `LOGIN_TOKEN=<login-token>` or `ACCESS_TOKEN=<access-token>` instead of `PASSWORD=<password>`.
+
+- **ASR_MODEL**: You can choose a docker tag with the corresponding model pre downloaded or set it with `ASR_MODEL`. Available models are `tiny.en`, `tiny`, `base.en`, `base`, `small.en`, `small`, `medium.en`, `medium`, and `large`. The default is `ASR_MODEL=tiny`.
+
+- **Authentication**:
+  - You can authenticate using tokens instead of a password:
+    - Set `LOGIN_TOKEN=<login-token>` or `ACCESS_TOKEN=<access-token>` instead of `PASSWORD=<password>`.
+
+- **Allowlist**:
+  - To restrict commands to specific users, you can set up an allowlist using regular expressions of Matrix user IDs. This feature allows you to specify which users are allowed to send commands to the bot.
+    - If the `ALLOWLIST` environment variable is defined, the bot will parse it and use it as the allowlist.
+    - Example: `ALLOWLIST=^@user1:example.com$,^@user2:example.com$`
+    - If `ALLOWLIST` is not defined, the bot will only allow commands from users of the bot's homeserver.

+ 3 - 0
main.py

@@ -23,6 +23,9 @@ config.encryption_enabled = True
 config.emoji_verify = False
 config.ignore_unverified_devices = True
 config.store_path = '/data/crypto_store/'
+if 'ALLOWLIST' in os.environ:
+  config.allowlist = os.environ['ALLOWLIST'].split(',')
+
 bot = botlib.Bot(creds, config)
 
 asr = ASR(os.getenv('ASR_MODEL', os.getenv('PRELOAD_MODEL', 'tiny')), os.getenv('ASR_LANGUAGE', 'en'))

+ 1 - 1
whisper.cpp

@@ -1 +1 @@
-Subproject commit 3b8c2dff5729585f931a885fe9389f94253da71a
+Subproject commit fff24a0148fe194df4997a738eeceddd724959c3